/*
 *  Arcanum Editor - ROM area editor
 *  Copyright (C) 1999  Lucas Wall <kthulhu@usa.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *
 *  If you make changes to the source and want to make the public you can
 *  mail the diferences to me <kthulhu@usa.net> and I'll add them to the
 *  main distribution. Of course your name will be added to the program with
 *  information about the changes you made.
 *
 *
 *  Packed on Thu Aug 19 03:02:20 1999
 *
 */


/*
 * File: MobData.cpp
 *
 * Changes:
 *
 * 19/08/99 Lucas Wall <kthulhu@usa.net>
 *          First source release. Its quite messy and has no
 *          comments. I never planed to release the source code... :-)
 *
 */


// MobData.cpp: implementation of the CMobData class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "arcaed.h"
#include "MobData.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


template <> void AFXAPI DestructElements <CSkillData*> ( CSkillData** pElements, int nCount )
{
    for ( int i = 0; i < nCount; i++, pElements++ )
    {
		delete *pElements;
    }
}

template <> void AFXAPI DestructElements <CMobProg*> ( CMobProg** pElements, int nCount )
{
    for ( int i = 0; i < nCount; i++, pElements++ )
    {
		delete *pElements;
    }
}

template <> void AFXAPI DestructElements <CMobData*> ( CMobData** pElements, int nCount )
{
    for ( int i = 0; i < nCount; i++, pElements++ )
    {
		delete *pElements;
    }
}

template <> void AFXAPI DestructElements <CSkillPrac*> ( CSkillPrac** pElements, int nCount )
{
    for ( int i = 0; i < nCount; i++, pElements++ )
    {
		delete *pElements;
    }
}

//////////////////////////////////////////////////////////////////////
// CSkillData Class
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSkillData::CSkillData()
{
	m_percent = 0;
	m_skill = "";
}

CSkillData::~CSkillData()
{

}

const CSkillData& CSkillData::operator= ( const CSkillData& skill )
{
	m_percent = skill.m_percent;
	m_skill = skill.m_skill;

	return *this;
}

//////////////////////////////////////////////////////////////////////
// CMobProg Class
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMobProg::CMobProg()
{
	m_type = "";
	m_vnum = 0;
	m_trigphrase = "";
}

CMobProg::~CMobProg()
{
}

const CMobProg& CMobProg::operator= ( const CMobProg& mobprog )
{
	m_type = mobprog.m_type;
	m_vnum = mobprog.m_vnum;
	m_trigphrase = mobprog.m_trigphrase;

	return *this;
}

CSkillPrac::CSkillPrac()
{
	m_skill = "";
	m_gold = 0;
	m_mult = 100;
	m_maxlevel = 5;
	m_teach = FALSE;
}

CSkillPrac::~CSkillPrac()
{
}

const CSkillPrac& CSkillPrac::operator= ( const CSkillPrac& skillp )
{
	m_skill = skillp.m_skill;
	m_gold = skillp.m_gold;
	m_mult = skillp.m_mult;
	m_maxlevel = skillp.m_maxlevel;
	m_teach = skillp.m_teach;

	return *this;
}

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMobData::CMobData()
{
	int i;

	m_vnum = 0;

	m_name = "";
	m_short_descr = "";
	m_long_descr = "";
	m_description = "";

	m_race = "";
	m_act_flags = 0;
	m_affect_flags = 0;
	m_off_flags = 0;
	m_imm_flags = 0;
	m_res_flags = 0;
	m_vuln_flags = 0;
	m_form = 0;
	m_parts = 0;

	if ( tables.m_mobflags.GetSize() > 0 )
	{
		m_race = tables.m_mobflags[0]->m_race;
		m_act_flags = tables.m_mobflags[0]->m_act;
		m_affect_flags = tables.m_mobflags[0]->m_aff;
		m_off_flags = tables.m_mobflags[0]->m_off;
		m_imm_flags = tables.m_mobflags[0]->m_imm;
		m_res_flags = tables.m_mobflags[0]->m_res;
		m_vuln_flags = tables.m_mobflags[0]->m_vul;
		m_form = tables.m_mobflags[0]->m_for;
		m_parts = tables.m_mobflags[0]->m_par;
	}


	m_alignment = 0;
	m_group = 0;
	m_level = 0;
	m_hitroll = 0;

	m_hit_dice_number = 0;
	m_hit_dice_type = 0;
	m_hit_dice_bonus = 0;

	m_mana_dice_number = 0;
	m_mana_dice_type = 0;
	m_mana_dice_bonus = 0;

	m_damage_dice_number = 0;
	m_damage_dice_type = 0;
	m_damage_dice_bonus = 0;
	m_dam_type = "";
	if ( tables.m_attack_types.GetSize() > 0 )
		m_dam_type = tables.m_attack_types[0]->m_text;

	m_ac_pierce = 0;
	m_ac_bash = 0;
	m_ac_slash = 0;
	m_ac_exotic = 0;

	m_start_pos = "";
	if ( tables.m_pos.GetSize() > 0 )
		m_start_pos = tables.m_pos[0]->m_text;
	m_default_pos = "";
	if ( tables.m_pos.GetSize() > 0 )
		m_default_pos = tables.m_pos[0]->m_text;
	m_sex = "";
	if ( tables.m_sex.GetSize() > 0 )
		m_sex = tables.m_sex[0]->m_text;

	m_wealth = 0;

	m_size = "";
	if ( tables.m_size.GetSize() > 0 )
		m_size = tables.m_size[0]->m_text;
	m_material.LoadString( IDS_UNKNOWN );

	m_clan = "";
	m_rank = 1;

	for ( i = 0; i < tables.m_mercmsg.GetSize(); i++ )
		m_mercmsg.Add( CString( "" ) );

	m_specfun = "";
	m_shopdata = NULL;

	m_class = "";
}

CMobData::~CMobData()
{
	if ( m_shopdata != NULL ) 
		delete m_shopdata;
}