#include "ArmorForm.h"
using namespace ObjDataEdit;

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

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

	BaseForm::OnActive();

	FirstTime = false;

    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_DEF;
//	CB_AbilityList10->SelectedIndex = EM_WearEqType_MDEF;
	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    ArmorForm::OnSelectObj( bool LockOk )
{
    _ObjDB.GameData.Classification = EM_ObjectClass_Item;
//   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.Coloring = 1;
	TempMode[5] = Mode._Mode;

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

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

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

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

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

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

	Mode._Mode = 0;
	Mode.UseWithoutFail = 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 );
   }
   _ObjDB.GameData.Classification = EM_ObjectClass_Item;
   //_ObjDB.GameData.PricesType	= EM_ACPriceType_GameMoney;

}
//輸出時額外設定
void    ArmorForm::OnOutputObjSetting( DB_GameObjDbStruct* TempObj )
{
    //設定初始資訊
    TempObj->GameData.MaxHeap = 1;
    TempObj->GameData.Item.Class = EM_Item_Armor;
    TempObj->GameData.Classification = EM_ObjectClass_Item;
	TempObj->GameData.Item.IsItemToItem = false;
	TempObj->GameData.Item.ImageEfficacyType = EM_ImageEfficacyType_None ;
	TempObj->GameData.Item.CastingTime = 0;
	//TempObj->GameData.PricesType	= EM_ACPriceType_GameMoney;
	TempObj->GameData.Item.iFurnitureStorageSize = 0;

	TempObj->GameData.Item.ItemToItemLimit.Init();

	TempObj->GameData.Mode.HideCount = false;


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

	if( TempObj->GameData.Item.RefineTableID == 0)
	{
		//設定衝等參考的表
		switch( TempObj->GameData.Item.ArmorPos )
		{
		case EM_ArmorPos_Head:			//頭
			TempObj->GameData.Item.RefineTableID = 740060;
			break;
		case EM_ArmorPos_Gloves:		//手套
			TempObj->GameData.Item.RefineTableID = 740080;
			break;
		case EM_ArmorPos_Shoes:			//鞋子
			TempObj->GameData.Item.RefineTableID = 740100;
			break;
		case EM_ArmorPos_Clothes:		//上衣
			TempObj->GameData.Item.RefineTableID = 740120;
			break;
		case EM_ArmorPos_Pants:			//褲子
			TempObj->GameData.Item.RefineTableID = 740140;
			break;
		case EM_ArmorPos_Back:			//背部
			TempObj->GameData.Item.RefineTableID = 740160;
			break;
		case EM_ArmorPos_Belt:			//腰帶
			TempObj->GameData.Item.RefineTableID = 740180;
			break;
		case EM_ArmorPos_Shoulder:		//肩甲
			TempObj->GameData.Item.RefineTableID = 740200;
			break;
		case EM_ArmorPos_Necklace:		//項鍊 
			TempObj->GameData.Item.RefineTableID = 740220;
			break;
		case EM_ArmorPos_Ring:			//戒子
			TempObj->GameData.Item.RefineTableID = 740240;
			break;
		case EM_ArmorPos_Earring:		//耳飾
			TempObj->GameData.Item.RefineTableID = 740260;
			break;
		case EM_ArmorPos_SecondHand:	//副手
			TempObj->GameData.Item.RefineTableID = 740280;
			break;
		case EM_ArmorPos_MagicTool:		//法寶
			TempObj->GameData.Item.RefineTableID = 740300;
			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->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	DEF = Value->Fin.DEF;
	float	MDEF =Value->Fin.MDEF;

	GameObjectArmorENUM		Type = TempObj->GameData.Item.ArmorType ;
	GameObjectArmorPosENUM	Pos  = TempObj->GameData.Item.ArmorPos;

	switch( Type )
	{
	case EM_Armor_HeavyArmed:
	case EM_Armor_LightArmed:
	case EM_Armor_Leather:
	case EM_Armor_Clothes:
	case EM_Armor_Robe:
		DEF = DEF / 100 * RoleDataEx::ArmorArg[0][ Pos ][ Type ];
		MDEF= MDEF / 100 * RoleDataEx::ArmorArg[1][ Pos ][ Type ];
		break;
	case EM_Armor_Shield:
		DEF = DEF / 100 * RoleDataEx::ArmorArg[0][ EM_ArmorPos_SecondHand ][ 0 ];
		MDEF = MDEF / 100 * RoleDataEx::ArmorArg[1][ EM_ArmorPos_SecondHand ][ 0 ];
		break;
	case EM_Armor_Implement:
		DEF = DEF / 100 * RoleDataEx::ArmorArg[0][ EM_ArmorPos_SecondHand ][ 1 ];
		MDEF = MDEF / 100 * RoleDataEx::ArmorArg[1][ EM_ArmorPos_SecondHand ][ 1 ];
		break;

	default:
		DEF = 0;
		MDEF = 0;
	}
	DEF += TempObj->GameData.Item.DDef;
	MDEF+= TempObj->GameData.Item.DMDef;

/*	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_DEF;
	TempObj->GameData.Item.Ability.EqTypeValue[ 0 ] = (int)(DEF + 0.5 );
	if( (int)(MDEF + 0.5 ) != 0 )
	{
		TempObj->GameData.Item.Ability.EqType[ 1 ]		= EM_WearEqType_MDEF;
		TempObj->GameData.Item.Ability.EqTypeValue[ 1 ] = (int)(MDEF + 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_ARMOR;
	TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_EMPTY;
	TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_EMPTY;
	
	switch( TempObj->GameData.Item.ArmorType )
	{
	case EM_Armor_HeavyArmed:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_HEAVYARMED;
		break;
	case EM_Armor_LightArmed:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_LIGHTARMED;
		break;
	case EM_Armor_Leather	:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_LEATHER;
		break;
	case EM_Armor_Clothes	:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_CLOTHES;
		break;
	case EM_Armor_Robe		:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_ROBE;
		break;
	case EM_Armor_Shield	:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_SECONDHAND;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_SECONDHAND_SHIELD;
		break;
	case EM_Armor_Implement	:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_SECONDHAND;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_SECONDHAND_IMPLEMENT;
		break;
	}

	//位置設定
	switch( TempObj->GameData.Item.ArmorPos )
	{
	case EM_ArmorPos_Head       :   //頭
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_HEAD;
		break;
	case EM_ArmorPos_Gloves	    :   //手套
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_GLOVES;
		break;
	case EM_ArmorPos_Shoes	    :   //鞋子
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_SHOES;
		break;
	case EM_ArmorPos_Clothes	:   //上衣
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_CLOTHES;
		break;
	case EM_ArmorPos_Pants	    :   //褲子
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_PANTS;
		break;
	case EM_ArmorPos_Back	    :   //背部
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_BACK;
		break;
	case EM_ArmorPos_Belt	    :   //腰帶
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_BELT;
		break;
	case EM_ArmorPos_Shoulder   :   //肩甲
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_X_SHOULDER;
		break;

	case EM_ArmorPos_Necklace   :   //項鍊 
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_DRESS;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_DRESS_NECKLACE;
		break;
	case EM_ArmorPos_Ring       :   //戒子
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_DRESS;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_DRESS_RING;
		break;
	case EM_ArmorPos_Earring    :   //耳飾
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_DRESS;
		TempObj->GameData.ACSearchType[2] = _DEF_ACSEARCHTYPE_ARMOR_DRESS_EARRING;
		break;
	case EM_ArmorPos_MagicTool:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_MAGICTOOL;
		break;
	case EM_ArmorPos_Ornament:
		TempObj->GameData.ACSearchType[1] = _DEF_ACSEARCHTYPE_ARMOR_ORNAMENT;
		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.ArmorType )
	{
	case EM_Armor_HeavyArmed:
		TempObj->GameData.ItemEqType.HeavyArmed = 1;
		break;
	case EM_Armor_LightArmed:
		TempObj->GameData.ItemEqType.LightArmed = 1;
		break;
	case EM_Armor_Leather	:
		TempObj->GameData.ItemEqType.Leather = 1;
		break;
	case EM_Armor_Clothes	:
		TempObj->GameData.ItemEqType.Clothes = 1;
		break;
	case EM_Armor_Robe		:
		TempObj->GameData.ItemEqType.Robe = 1;
		break;
	case EM_Armor_Shield	:
		TempObj->GameData.ItemEqType.Shield = 1;
		break;
	case EM_Armor_Implement	:
		TempObj->GameData.ItemEqType.Implement = 1;
		break;
	}
	//-----------------------------------------------------
	//標準價計算
	if( TempObj->GameData.Item.IsStandardCost && TempObj->GameData.PricesType == EM_ACPriceType_GameMoney )
	{
		float	StandardCost = 0;
		switch( Type )
		{
		case EM_Armor_HeavyArmed:
		case EM_Armor_LightArmed:
		case EM_Armor_Leather:
		case EM_Armor_Clothes:
		case EM_Armor_Robe:
			StandardCost = RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] * RoleDataEx::ArmorArg[2][ Pos ][ Type ];
			break;
		case EM_Armor_Shield:
			StandardCost = RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] * RoleDataEx::ArmorArg[2][ EM_ArmorPos_SecondHand ][ 0 ];
			break;
		case EM_Armor_Implement:
			StandardCost = RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] * RoleDataEx::ArmorArg[2][ EM_ArmorPos_SecondHand ][ 1 ];
			break;
		default:
			StandardCost = float( RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] );
		}
		TempObj->GameData.Cost = int( StandardCost + 0.5f );
	}


}
void    ArmorForm::OnTimeProc( )
{   
	/*
    static int LIncMagic = 0;

    DB_GameObjDbStruct __pin * TempObj = &_ObjDB;

    if( LIncMagic == TempObj->GameData.Item.IncMagic_Onuse )
        return ;
     
    LIncMagic = TempObj->GameData.Item.IncMagic_Onuse;

    LB_IncMagic->Text = SearchObjName( LIncMagic );
	*/
}
void    ArmorForm::OnValueChange()
{
	OnSelectObj( true );
	DB_GameObjDbStruct __pin * TempObj = &_ObjDB;

	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 );

	RoleValueData* Value = &(Global::ValueCal);
	Value->Init_BaseEQValue();
	Value->Init_MidValue();

	//資料更新
	Value->Ability = &Global::Ability;


	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	DEF = Value->Fin.DEF;
	float	MDEF= Value->Fin.MDEF;

	GameObjectArmorENUM		Type = _ObjDB.GameData.Item.ArmorType ;
	GameObjectArmorPosENUM	Pos  = _ObjDB.GameData.Item.ArmorPos;

	switch( Type )
	{
	case EM_Armor_HeavyArmed:
	case EM_Armor_LightArmed:
	case EM_Armor_Leather:
	case EM_Armor_Clothes:
	case EM_Armor_Robe:
		DEF = DEF / 100 * RoleDataEx::ArmorArg[0][ Pos ][ Type ];
		MDEF = MDEF / 100 * RoleDataEx::ArmorArg[1][ Pos ][ Type ];
		break;
	case EM_Armor_Shield:
		DEF = DEF / 100 * RoleDataEx::ArmorArg[0][ EM_ArmorPos_SecondHand ][ 0 ];
		MDEF = MDEF / 100 * RoleDataEx::ArmorArg[1][ EM_ArmorPos_SecondHand ][ 0 ];
		break;
	case EM_Armor_Implement:
		DEF = DEF / 100 * RoleDataEx::ArmorArg[0][ EM_ArmorPos_SecondHand ][ 1 ];
		MDEF = MDEF / 100 * RoleDataEx::ArmorArg[1][ EM_ArmorPos_SecondHand ][ 1 ];
		break;
	default:
		DEF = 0;
		MDEF = 0;
	}
	DEF += + TempObj->GameData.Item.DDef;
	MDEF += + TempObj->GameData.Item.DMDef;

	TB_DEF->Text = String::Format( "{0}" , __box( int( DEF+0.5 ) ) );
	TB_MDEF->Text = String::Format( "{0}" , __box( int( MDEF+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;
		}
	}
	//////////////////////////////////////////////////////////////////////////
	LB_EqTypeOnAttackMagicID->Text = SearchObjName( TempObj->GameData.Item.Ability.OnAttackMagicID );  
	LB_CardName->Text = SearchObjName( TempObj->GameData.Item.CardID );

	//標準價計算
	float	StandardCost = 0;
	switch( Type )
	{
	case EM_Armor_HeavyArmed:
	case EM_Armor_LightArmed:
	case EM_Armor_Leather:
	case EM_Armor_Clothes:
	case EM_Armor_Robe:
		StandardCost = RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] * RoleDataEx::ArmorArg[2][ Pos ][ Type ];
		break;
	case EM_Armor_Shield:
		StandardCost = RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] * RoleDataEx::ArmorArg[2][ EM_ArmorPos_SecondHand ][ 0 ];
		break;
	case EM_Armor_Implement:
		StandardCost = RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] * RoleDataEx::ArmorArg[2][ EM_ArmorPos_SecondHand ][ 1 ];
		break;
	default:
		StandardCost = float( RoleDataEx::StandardCostTable[ TempObj->GameData.Limit.Level - 1 ] );
	}

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

	if(		TempObj->GameData.Item.IsStandardCost 
		&&	TempObj->GameData.PricesType == EM_ACPriceType_GameMoney )
	{
		//TB_Cost->Enabled = false;
		//TB_Cost->Hide();

	}
	else
	{
		//TB_Cost->Show();
		//TB_Cost->Enabled = true;
	}


	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 );

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


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

System::Void ArmorForm::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.Coloring = 1;
	TempMode[5] = Mode._Mode;

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

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

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

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

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

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

	Mode._Mode = 0;
	Mode.UseWithoutFail = 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     ArmorForm::ObjSize(  )
{
    GameObjDbStruct *P = NULL;
    int Size = sizeof( GameObjDbStruct ) - sizeof( P->Temp ) + sizeof( P->Item ) + 3;
    Size = Size & 0xfffffC;
    return Size;
}