#include "WeaponForm.h"


using namespace ObjDataEdit;

//######################################################################################################
//主要需要繼承的涵式
ReaderClass< DB_GameObjDbStruct >* WeaponForm::ObjReader( )
{
	return GameObjDbStructEx::ObjReader_Weapon( );
}
void    WeaponForm::OnActive()
{
    static bool FirstTime = true;

	Reload_AttrTable();
    //設定種族職業資訊
    if( FirstTime  == false )
        return;

	FirstTime = false;

	BaseForm::OnActive();

    CLB_RaceLimit->Items->Clear();
    for( unsigned int i = 0 ; i < Global::RaceName.size() ; i++ )
    {
		String* Str =  Global::RaceName[i].c_str();
        System::Object* AddItem[] = new System::Object*[1];
        AddItem[0] = Str;
        CLB_RaceLimit->Items->AddRange(AddItem);

    }

    CLB_VocLimit->Items->Clear();
    for( unsigned int i = 0 ; i < Global::JobName.size() ; i++ )
    {
        String* Str =  Global::JobName[i].c_str();
        System::Object* AddItem[] = new System::Object*[1];
        AddItem[0] = Str;
        CLB_VocLimit->Items->AddRange(AddItem);

    }

    CLB_SexLimit->Items->Clear();
    for( unsigned int i = 0 ; i < Global::SexName.size() ; i++ )
    {
        String* Str =  Global::SexName[i].c_str();
        System::Object* AddItem[] = new System::Object*[1];
        AddItem[0] = Str;
        CLB_SexLimit->Items->AddRange(AddItem);

    }

	CB_AbilityList1->Items->Clear();
	CB_AbilityList2->Items->Clear();
	CB_AbilityList3->Items->Clear();
	CB_AbilityList4->Items->Clear();
	CB_AbilityList5->Items->Clear();
	CB_AbilityList6->Items->Clear();
	CB_AbilityList7->Items->Clear();
	CB_AbilityList8->Items->Clear();
//	CB_AbilityList9->Items->Clear();
//	CB_AbilityList10->Items->Clear();

	for( int i = 0 ; i < EM_WearEqType_MaxCount ; i++ )
	{
		String* Str = GameObjDbStructEx::GetWearEqTypeENUMString( (WearEqTypeENUM)i );
		CB_AbilityList1->Items->Add( Str );
		CB_AbilityList2->Items->Add( Str );
		CB_AbilityList3->Items->Add( Str );
		CB_AbilityList4->Items->Add( Str );
		CB_AbilityList5->Items->Add( Str );
		CB_AbilityList6->Items->Add( Str );
		CB_AbilityList7->Items->Add( Str );
		CB_AbilityList8->Items->Add( Str );
//		CB_AbilityList9->Items->Add( Str );
//		CB_AbilityList10->Items->Add( Str );
	}   
	
//	CB_AbilityList9->SelectedIndex = EM_WearEqType_DMG;
//	CB_AbilityList10->SelectedIndex = EM_WearEqType_MATK;
	SqlDataReader* myReader;

	sqlCommand_Base->CommandText = "select keystr,content from StringDB where LEFT(KeyStr,14) = 'SYS_STORE_TYPE' order by KeyStr";
	myReader = sqlCommand_Base->ExecuteReader();
	CB_SellType->Items->Clear();

	for( int i = 0 ; ; i++ )
	{                
		if( myReader->Read() == false )
			break;
		//int     Value =  myReader->GetInt32( 0 );
		String* KeyStr   = myReader->GetString( 0 );
		String* Content  = myReader->GetString( 1 );

		string tempStr = DotNetStr::StringToChar( KeyStr );
		const char* cKeyStr = tempStr.c_str();
		const char* cNumStr = strlen("SYS_STORE_TYPE_") + cKeyStr;
		if( i != atol( cNumStr ) )
			break;

		CB_SellType->Items->Add( Content );
	}
	myReader->Close();

	sqlCommand_Base->CommandText = "Select ID , Name from Table_String Where Type = '裝備唯一' ORDER BY  ID";
	myReader = sqlCommand_Base->ExecuteReader();
	CB_WearUniqueType->Items->Clear();
	CB_WearUniqueType->Items->Add( S"無" );
	while( myReader->Read() )
	{                
		String* Str = myReader->GetString( 1 );
		CB_WearUniqueType->Items->Add( Str );
	}
	myReader->Close();

	//GB_UseItem->Size = System::Drawing::Point( 325 , 56 );
	
	// 幣值設定
	{
		vector< std::string >	vecPriceType;
		sqlCommand_Base->CommandText = "Select Note from Table_SysKeyValue Where KeyStr LIKE 'SYS_PRICETYPE_ICONID_%' ORDER BY KeyStr";
		myReader = sqlCommand_Base->ExecuteReader();

		while( myReader->Read() )		
		{
			std::string sContent		=	DotNetStr::StringToChar( myReader->GetString( 0 ) );
			vecPriceType.push_back( sContent );
		}
		myReader->Close();

		CB_PricesType->Items->Clear();

		for( vector< std::string >::iterator it = vecPriceType.begin(); it != vecPriceType.end(); it++ )
		{
			String*		sContent		= new String( (*it).c_str() );
			CB_PricesType->Items->Add( sContent );
		}
	}
	
}
void    WeaponForm::OnValueChange()
{
	DB_GameObjDbStruct __pin * TempObj = &_ObjDB;

	OnSelectObj( true );

	if( comboBox1->SelectedIndex ==  EM_WeaponPos_Manufacture )
	{
		GB_Manufactory->Show();
	}
	else
	{
		GB_Manufactory->Hide();
	}
	if( comboBox1->SelectedIndex == EM_WeaponPos_Ammo )
	{
		CB_MaxHeap->Show();
		label12->Show();

		label18->Show();
		comboBox11->Show();
	}
	else
	{
		CB_MaxHeap->Hide();
		label12->Hide();

		label18->Hide();
		comboBox11->Hide();
	}


	LB_Recipe->Text		= SearchObjName( TempObj->GameData.Item.SrcRecipe );
	LB_IncMagic->Text	= SearchObjName( TempObj->GameData.Item.IncMagic_Onuse );
	LB_SuitID->Text		= SearchObjName( TempObj->GameData.Item.SuitID );
	LB_EqTypeOnAttackMagicID->Text = SearchObjName( TempObj->GameData.Item.Ability.OnAttackMagicID );  
	LB_CardName->Text = SearchObjName( TempObj->GameData.Item.CardID );

	RoleValueData* Value = &(Global::ValueCal);
	Value->Init_BaseEQValue();
	Value->Init_MidValue();
	//資料更新
	Value->Ability = &Global::Ability;

	//int AddLV[ 10 ] = { 0 , 1 , 2 , 3 , 5 , 9 , 12 , 15 , 20 , 35 };

	Value->Race    = EM_Race1;
	Value->Voc     = EM_Vocation_GameMaster;
	Value->Sex     = EM_Sex_Boy; 
	Value->Voc_Sub = EM_Vocation_None;
	Value->Level   = _ObjDB.GameData.Limit.Level + RoleDataEx::AddLv_byRare[ _ObjDB.GameData.Rare ] ;
	Value->Ability->STR = 0;
	Value->Ability->STA = 0;
	Value->Ability->INT = 0;
	Value->Ability->MND = 0;
	Value->Ability->AGI = 0;

	Value->SkillValue = &Value->MaxSkillValue;
	Value->ReSetTable( );
	Value->Calculate( );

	float DMG = 0;
	float MAtk = 0;

	if( _ObjDB.GameData.Item.WeaponType != -1 )
	{
		DMG = ( Value->Fin.DMG + 2 )* ( RoleValueData::WeaponBaseDmg[ _ObjDB.GameData.Item.WeaponType ] * _ObjDB.GameData.Item.AttackSpeed*0.1f ) + TempObj->GameData.Item.DDmg;
		MAtk = Value->Fin.MATK * RoleValueData::WeaponBaseMAtk[ _ObjDB.GameData.Item.WeaponType ] + TempObj->GameData.Item.DMDmg ;
//		DMG = Value->Fin.DMG;
//		MAtk = Value->Fin.Main_DMG;
	}

//	NUD_DmgValue->Value = DMG;
//	NUD_MAtkValue->Value = MAtk;
	TB_DMG->Text = String::Format( "{0}" , __box( int( DMG + 0.5 ) ) );
	TB_MDmg->Text = String::Format( "{0}" , __box( int( MAtk + 0.5 ) ) );

	//////////////////////////////////////////////////////////////////////////
	static ItemUseType_ENUM LastUseType = (ItemUseType_ENUM)-1;

	if( LastUseType != TempObj->GameData.Item.UseType )
	{
		PL_UseSrvScript->Visible = false;
		PL_UseCliScript->Visible = false;

		switch( TempObj->GameData.Item.UseType )
		{
		case EM_ItemUseType_None:
			GB_UseItem->Visible = false;
			break;
		case EM_ItemUseType_Magic:
			GB_UseItem->Visible = true;
			break;
		case EM_ItemUseType_CliScript:
			GB_UseItem->Visible = true;
			PL_UseCliScript->Visible = true;
			break;
		case EM_ItemUseType_SrvScript:
			GB_UseItem->Visible = true;
			PL_UseSrvScript->Visible = true;
			break;
		}
	}
	//////////////////////////////////////////////////////////////////////////
	//標準價計算
	float	StandardCost = 	RoleDataEx::StandardCostTable[  _ObjDB.GameData.Limit.Level - 1 ] * RoleValueData::WeaponBaseCostRate[ _ObjDB.GameData.Item.WeaponType ];

	TB_StandardCost->Text = String::Format( "{0}" , __box( int( StandardCost+0.5 ) ) );

	if(		TempObj->GameData.Item.IsStandardCost 
		&&	TempObj->GameData.PricesType == EM_ACPriceType_GameMoney )
	{
		//TB_Cost->Hide();
	}
	else
	{
		//TB_Cost->Show();
	}

	char	Buf[256];
	ItemDropStruct* DropAbility = TempObj->GameData.Item.DropItemAbility;
	sprintf( Buf , "%.3f%%" , float( DropAbility[0].Rate ) / 1000 );
	DropAbilityEx1->Text = Buf;
	sprintf( Buf , "%.3f%%" , float( DropAbility[1].Rate ) / 1000 );
	DropAbilityEx2->Text = Buf;
	sprintf( Buf , "%.3f%%" , float( DropAbility[2].Rate ) / 1000 );
	DropAbilityEx3->Text = Buf;
	sprintf( Buf , "%.3f%%" , float( DropAbility[3].Rate ) / 1000 );
	DropAbilityEx4->Text = Buf;
	sprintf( Buf , "%.3f%%" , float( DropAbility[4].Rate ) / 1000 );
	DropAbilityEx5->Text = Buf;
	sprintf( Buf , "%.3f%%" , float( DropAbility[5].Rate ) / 1000 );
	DropAbilityEx6->Text = Buf;

	DropAbilityName1->Text = SearchObjName( DropAbility[0].OrgID );
	DropAbilityName2->Text = SearchObjName( DropAbility[1].OrgID );
	DropAbilityName3->Text = SearchObjName( DropAbility[2].OrgID );
	DropAbilityName4->Text = SearchObjName( DropAbility[3].OrgID );
	DropAbilityName5->Text = SearchObjName( DropAbility[4].OrgID );
	DropAbilityName6->Text = SearchObjName( DropAbility[5].OrgID );

	//////////////////////////////////////////////////////////////////////////
	NUD_AttackSpeed->Minimum = int( RoleValueData::WeaponBaseDelayTime[ _ObjDB.GameData.Item.WeaponType ] * 0.75 );
	NUD_AttackSpeed->Maximum = int( RoleValueData::WeaponBaseDelayTime[ _ObjDB.GameData.Item.WeaponType ] * 1.25 );

	if( CB_PricesType->SelectedIndex == 0 )
	{
		TB_SpecialMoneyCost->Visible = false;
	}
	else
	{
		TB_SpecialMoneyCost->Visible = true;
	}

}

void    WeaponForm::OnSelectObj( bool LockOk )
{
    _ObjDB.GameData.Classification = EM_ObjectClass_Item;
	//_ObjDB.GameData.PricesType	= EM_ACPriceType_GameMoney;
//    panel1->Enabled = LockOk;

    ObjectModeStruct Mode;
    int TempMode[20];

    Mode._Mode = 0;
    Mode.Sell = 1;
    TempMode[0] = Mode._Mode;

    Mode._Mode = 0;
    Mode.Logoutdel = 1;
    TempMode[1] = Mode._Mode;

    Mode._Mode = 0;
    Mode.Expense = 1;
    TempMode[2] = Mode._Mode;

    Mode._Mode = 0;
    Mode.PickupBound = 1;
    TempMode[3] = Mode._Mode;

    Mode._Mode = 0;
    Mode.EQSoulBound = 1;
    TempMode[4] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DurableStart0 = 1;
	TempMode[5] = Mode._Mode;

	Mode._Mode = 0;
	Mode.ChangeZoneDel = 1;
	TempMode[6] = Mode._Mode;

	Mode._Mode = 0;
	Mode.PkNoDrop = 1;
	TempMode[7] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DepartmentStore = 1;
	TempMode[8] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DepartmentStore_Free = 1;
	TempMode[9] = Mode._Mode;
	
	Mode._Mode = 0;
	Mode.SpecialSuit = 1;
	TempMode[10] = Mode._Mode;

	Mode._Mode = 0;
	Mode.UseWithoutFail = 1;
	TempMode[11] = Mode._Mode;

	Mode._Mode = 0;
	Mode.HideRefineLight = 1;
	TempMode[12] = Mode._Mode;

	Mode._Mode = 0;
	Mode.Unique = 1;
	TempMode[13] = Mode._Mode;

	Mode._Mode = 0;
	Mode.NoNPCAbility = 1;
	TempMode[14] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisableRefine = 1;
	TempMode[15] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisablePowerQuality = 1;
	TempMode[16] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisableMagicBox = 1;
	TempMode[17] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisableDigHode = 1;
	TempMode[18] = Mode._Mode;


    for( int i = 0 ; i < CLBModeFlag->Items->Count ; i ++ )
    {
        if( TempMode[i] & _ObjDB.GameData.Mode._Mode )
            CLBModeFlag->SetItemChecked( i , true );
        else
            CLBModeFlag->SetItemChecked( i , false );
    }
	NUD_AttackSpeed->Minimum = 0;
	NUD_AttackSpeed->Maximum = 100;
}
//輸出時額外設定
void    WeaponForm::OnOutputObjSetting( DB_GameObjDbStruct* TempObj )
{
    //設定初始資訊
	if( EM_WeaponPos_Ammo != TempObj->GameData.Item.WeaponPos )
		TempObj->GameData.MaxHeap = 1;
    TempObj->GameData.Item.Class = EM_Item_Weapon;
    TempObj->GameData.Classification = EM_ObjectClass_Item;
	TempObj->GameData.Item.IsItemToItem = false;
	TempObj->GameData.Item.CastingTime = 0;

	int PricesType = TempObj->GameData.PricesType;
	//TempObj->GameData.PricesType	= EM_ACPriceType_GameMoney;
	TempObj->GameData.Item.iFurnitureStorageSize = 0;
	TempObj->GameData.Item.ItemToItemLimit.Init();

	if(		TempObj->GameData.BuyUnit == 0 
		||	TempObj->GameData.BuyUnit > TempObj->GameData.MaxHeap )
		TempObj->GameData.BuyUnit = TempObj->GameData.MaxHeap;

	TempObj->GameData.Mode.HideCount = false;


	if( TempObj->GameData.Item.RefineTableID == 0 )
	{
		//設定衝等參考的表
		switch( TempObj->GameData.Item.WeaponType )
		{
		case EM_Weapon_Unarmed:			// Unarmed空手
		case EM_Weapon_Blade:           // 劍
		case EM_Weapon_Dagger:          // 匕首
		case EM_Weapon_Axe:             // 斧
		case EM_Weapon_Bludgeon:        // 鎚棍棒
		case EM_Weapon_Claymore:        // 雙手劍	
		case EM_Weapon_2H_Axe:          // 雙手斧
		case EM_Weapon_2H_Hammer:       // 雙手鎚
		case EM_Weapon_Polearm:			// 槍(長矛)
			TempObj->GameData.Item.RefineTableID = 740000 ;
			break;

		case EM_Weapon_Wand:            // 權杖
		case EM_Weapon_Staff:           // 杖
			TempObj->GameData.Item.RefineTableID = 740020 ;
			break;

		case EM_Weapon_Bow:				// 遠程武器 弓
		case EM_Weapon_CossBow:			// 遠程武器 十字弓
		case EM_Weapon_Gun:
			TempObj->GameData.Item.RefineTableID = 740040 ;
			break;

		default:
			TempObj->GameData.Item.RefineTableID = 0 ;
			break;
		}
	}


//	if( TempObj->GameData.Item.StandardType == EM_Yes )
//	{
	RoleValueData* Value = &(Global::ValueCal);
	Value->Init_BaseEQValue();
	Value->Init_MidValue();
	//資料更新
	Value->Ability = &Global::Ability;

	//int AddLV[ 10 ] = { 0 , 1 , 2 , 3 , 5 , 9 , 12 , 15 , 20 , 35 };

	Value->Race    = EM_Race1;
	Value->Voc     = EM_Vocation_GameMaster;
	Value->Voc_Sub = EM_Vocation_None;

	Value->Sex     = EM_Sex_Boy; 
	Value->Level   = TempObj->GameData.Limit.Level + RoleDataEx::AddLv_byRare[ TempObj->GameData.Rare ] ;
	Value->Ability->STR = 0;
	Value->Ability->STA = 0;
	Value->Ability->INT = 0;
	Value->Ability->MND = 0;
	Value->Ability->AGI = 0;

	Value->SkillValue = &Value->MaxSkillValue;
	Value->ReSetTable( );
	Value->Calculate( );

	float DMG = 0;
	float MAtk = 0;
	if( TempObj->GameData.Item.WeaponType != -1 )
	{
		DMG = ( Value->Fin.DMG + 2 ) * ( RoleValueData::WeaponBaseDmg[ TempObj->GameData.Item.WeaponType ] * TempObj->GameData.Item.AttackSpeed*0.1f ) + TempObj->GameData.Item.DDmg;
		MAtk = Value->Fin.MATK * RoleValueData::WeaponBaseMAtk[ TempObj->GameData.Item.WeaponType ] + TempObj->GameData.Item.DMDmg ;
	}

/*	for( int i = 2 ; i < Max_WearEqType_Count ; i++ )
	{
		TempObj->GameData.Item.Ability.EqType[ i ]		= EM_WearEqType_None;
		TempObj->GameData.Item.Ability.EqTypeValue[ i ] = 0;
	}
	*/

	TempObj->GameData.Item.Ability.EqType[ 0 ]		= EM_WearEqType_DMG;
	TempObj->GameData.Item.Ability.EqTypeValue[ 0 ] = (int)(DMG + 0.5 );
		
	if( int(MAtk + 0.5 ) != 0 )
	{
		TempObj->GameData.Item.Ability.EqType[ 1 ]		= EM_WearEqType_MDMG;
		TempObj->GameData.Item.Ability.EqTypeValue[ 1 ] = (int)(MAtk + 0.5 );
	}
	else
	{
		TempObj->GameData.Item.Ability.EqType[ 1 ]		= EM_WearEqType_None;
		TempObj->GameData.Item.Ability.EqTypeValue[ 1 ] = 0;
	}

	if( TempObj->GameData.Mode.SpecialSuit == true )
	{
		for( int i = 0 ; i < Max_WearEqType_Count ; i++ )
		{
			TempObj->GameData.Item.Ability.EqType[ i ]		= EM_WearEqType_None;
			TempObj->GameData.Item.Ability.EqTypeValue[ i ] = 0;
		}
		TempObj->GameData.Item.HoleBase = 0;
	}

	//設定拍賣類別
	TempObj->GameData.ACSearchType[0] = _DEF_ACSEARCHTYPE_WEAPON;
	TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_EMPTY;
	TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_EMPTY;

	switch( TempObj->GameData.Item.WeaponType )
	{

	case EM_Weapon_Blade:				// 劍
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_SWORD;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_ONEHAND;
		break;
	case EM_Weapon_Claymore:			// 雙手劍
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_SWORD;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_TWOEHAND;
		break;

	case EM_Weapon_Axe:					// 斧
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_AXE;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_ONEHAND;
		break;

	case EM_Weapon_2H_Axe:				// 雙手斧
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_AXE;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_TWOEHAND;
		break;

	case EM_Weapon_Bludgeon:			// 鎚棍棒
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_HAMMER;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_ONEHAND;
		break;

	case EM_Weapon_2H_Hammer:			// 雙手鎚
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_HAMMER;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_TWOEHAND;
		break;

	case EM_Weapon_Dagger:				// 匕首
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_DAGGER;
		break;

	case EM_Weapon_Bow:					// 遠程武器 弓
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_LONGWEAPON;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_BOW;
		break;

	case EM_Weapon_CossBow:				// 遠程武器 十字弓
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_LONGWEAPON;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_COSSBOW;
		break;

	case EM_Weapon_Wand:				// 權杖
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_STAFF;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_ONEHAND;
		break;

	case EM_Weapon_Staff:				// 杖
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_STAFF;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_TWOEHAND;
		break;
	
	case EM_Weapon_Ammo_Bow:			// 子彈 弓
	case  EM_Weapon_Ammo_Gun:			// 子彈 槍
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_LONGWEAPON;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_WEAPON_X_AMMO;
		break;

	case EM_Weapon_Throw:				// 投擲類武器
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_THROW;
		break;
	
	case EM_Weapon_Polearm:				// 槍(長矛)
	case EM_Weapon_Gun:					// 遠程武器 槍
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_WEAPON_OTHER;
		break;
	}
	//-----------------------------------------------------
	//限制設定
	//-----------------------------------------------------
	if( TempObj->GameData.Limit.Race._Race == 0 )
		TempObj->GameData.Limit.Race._Race = -1;

	if( TempObj->GameData.Limit.Sex._Sex == 0 )
		TempObj->GameData.Limit.Sex._Sex = -1;

	if( TempObj->GameData.Limit.Voc._Voc == 0 )
		TempObj->GameData.Limit.Voc._Voc = -1;

	if( TempObj->GameData.Limit.Level <= 0 )
		TempObj->GameData.Limit.Level = 1;
	//-----------------------------------------------------
	//物品設定裝備類型
	//-----------------------------------------------------
	TempObj->GameData.ItemEqType._Skill = 0;
	switch( TempObj->GameData.Item.WeaponType )
	{
	case EM_Weapon_Blade:				// 劍
		TempObj->GameData.ItemEqType.Blade = 1;
		break;
	case EM_Weapon_Claymore:			// 雙手劍
		TempObj->GameData.ItemEqType.Claymore = 1;
		break;
	case EM_Weapon_Axe:					// 斧
		TempObj->GameData.ItemEqType.Axe = 1;
		break;
	case EM_Weapon_2H_Axe:				// 雙手斧
		TempObj->GameData.ItemEqType.Axe_2H = 1;
		break;
	case EM_Weapon_Bludgeon:			// 鎚棍棒
		TempObj->GameData.ItemEqType.Bludgeon = 1;
		break;
	case EM_Weapon_2H_Hammer:			// 雙手鎚
		TempObj->GameData.ItemEqType.Hammer_2H = 1;
		break;
	case EM_Weapon_Dagger:				// 匕首
		TempObj->GameData.ItemEqType.Dagger = 1;
		break;
	case EM_Weapon_Bow:					// 遠程武器 弓
		TempObj->GameData.ItemEqType.Bow = 1;
		break;
	case EM_Weapon_CossBow:				// 遠程武器 十字弓
		TempObj->GameData.ItemEqType.CossBow = 1;
		break;
	case EM_Weapon_Wand:				// 權杖
		TempObj->GameData.ItemEqType.Wand = 1;
		break;
	case EM_Weapon_Staff:				// 杖
		TempObj->GameData.ItemEqType.Staff = 1;
		break;
	case EM_Weapon_Ammo_Bow:			// 子彈 弓
		TempObj->GameData.ItemEqType.Bow = 1;
		break;
//	case EM_Weapon_Ammo_CossBow:		// 子彈 十字弓
//		TempObj->GameData.ItemEqType.CossBow = 1;
//		break;
	case EM_Weapon_Ammo_Gun:			// 子彈 槍
		TempObj->GameData.ItemEqType.Gun = 1;
		break;
	case EM_Weapon_Throw:				// 投擲類武器
		TempObj->GameData.ItemEqType.Throw = 1;
		break;
	case EM_Weapon_Polearm:				// 槍(長矛)
		TempObj->GameData.ItemEqType.Polearm = 1;
		break;
	case EM_Weapon_Gun:					// 遠程武器 槍
		TempObj->GameData.ItemEqType.Gun = 1;
		break;
	}

	//------------------------------------------------------------------------
	//標準價計算
	if( TempObj->GameData.Item.IsStandardCost && TempObj->GameData.PricesType == EM_ACPriceType_GameMoney )
	{
		float	StandardCost = 0;
		StandardCost = RoleDataEx::StandardCostTable[  TempObj->GameData.Limit.Level- 1 ] * RoleValueData::WeaponBaseCostRate[TempObj->GameData.Item.WeaponType];
		TempObj->GameData.Cost = int( StandardCost + 0.5f );
	}
}

void    WeaponForm::OnTimeProc()
{

}
//######################################################################################################

System::Void WeaponForm::OnChangeMode(System::Object *  sender, System::EventArgs *  e)
{

    CheckedListBox* CBox = static_cast<CheckedListBox*>(sender);

    ObjectModeStruct Mode;
    int TempMode[20];

    Mode._Mode = 0;
    Mode.Sell = 1;
    TempMode[0] = Mode._Mode;

    Mode._Mode = 0;
    Mode.Logoutdel = 1;
    TempMode[1] = Mode._Mode;

    Mode._Mode = 0;
    Mode.Expense = 1;
    TempMode[2] = Mode._Mode;

    Mode._Mode = 0;
    Mode.PickupBound = 1;
    TempMode[3] = Mode._Mode;

    Mode._Mode = 0;
    Mode.EQSoulBound = 1;
    TempMode[4] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DurableStart0 = 1;
	TempMode[5] = Mode._Mode;

	Mode._Mode = 0;
	Mode.ChangeZoneDel = 1;
	TempMode[6] = Mode._Mode;

	Mode._Mode = 0;
	Mode.PkNoDrop = 1;
	TempMode[7] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DepartmentStore = 1;
	TempMode[8] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DepartmentStore_Free = 1;
	TempMode[9] = Mode._Mode;

	Mode._Mode = 0;
	Mode.SpecialSuit = 1;
	TempMode[10] = Mode._Mode;

	Mode._Mode = 0;
	Mode.UseWithoutFail = 1;
	TempMode[11] = Mode._Mode;

	Mode._Mode = 0;
	Mode.HideRefineLight = 1;
	TempMode[12] = Mode._Mode;

	Mode._Mode = 0;
	Mode.Unique = 1;
	TempMode[13] = Mode._Mode;

	Mode._Mode = 0;
	Mode.NoNPCAbility = 1;
	TempMode[14] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisableRefine = 1;
	TempMode[15] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisablePowerQuality = 1;
	TempMode[16] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisableMagicBox = 1;
	TempMode[17] = Mode._Mode;

	Mode._Mode = 0;
	Mode.DisableDigHode = 1;
	TempMode[18] = Mode._Mode;


    int Flag = 0;
    for( int i = CBox->Items->Count-1 ; i >= 0 ; i -- )
    {

        if( CBox->GetItemChecked( i ) == true )
            Flag = Flag + TempMode[ i ];
    }

	if( _ObjDB.GameData.Mode._Mode == Flag )
		return;

	if( CheckModifyAndCheckOut() == false )
		return;

	if( CB_Lock->Checked == true )
		_ObjDB.IsModify = true;

    _ObjDB.GameData.Mode._Mode = Flag;

}

int     WeaponForm::ObjSize(  )
{
    GameObjDbStruct *P = NULL;
    int Size = sizeof( GameObjDbStruct ) - sizeof( P->Temp ) + sizeof( P->Item ) + 3;
    Size = Size & 0xfffffC;
    return Size;
}