@LabelIndex 6886
@StringIndex 1358
class 0 castle_keeper : citizen {
parameter:
	string	ShopName = ";
	string	fnHi = "castle_keeper001.htm";
	string	fnBye = "castle_keeper002.htm";
	string	fnEmpty = "castle_keeper005.htm";
	string	fnNoAuthority = "";
	string	fnMedalLevel = "";
	string	fnGetMedalSuccess = "";
	string	fnNoReward = "";
	int	item_medal = 9911;
	int	num_oath = 1;
	int	item_proof = 9910;
	int	num_proof = 30;
	string	fnChangeItem = "";
	string	fnDecreaseCountFailed = "";
	string	fnNotEnoughToChange = "";

handler:
	EventHandler NO_DESIRE() {
		myself::AddDoNothingDesire(-1,9999);
	}

	EventHandler MENU_SELECTED(talker,ask,reply,i0,fhtml0) {
		if( ask == 222 ) {
			if( myself::IsMyLord(talker) == 0 ) {
				myself::ShowPage(talker,fnNoAuthority);
				return;
			}
			if( reply == 0 ) {
				i0 = myself::GetPledgeCastleSiegeDefenceCount(talker);
				myself::FHTML_SetFileName(fhtml0,fnMedalLevel);
				myself::FHTML_SetStr(fhtml0,"medal_level",gg::IntToStr(i0));
				myself::ShowFHTML(talker,fhtml0);
				return;
			} else if( reply == 1 ) {
				i0 = myself::GetPledgeCastleSiegeDefenceCount(talker);
				if( i0 == 0 ) {
					myself::ShowPage(talker,fnNoReward);
					return;
				} else if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) ) {
					myself::ShowSystemMessage(talker,1118);
					return;
				}
				myself::GiveItemByCastleSiegeDefence(talker,i0,item_medal,0,i0);
				return;
			} else if( reply == 2 ) {
				if( gg::OwnItemCount(talker,item_medal) >= num_oath ) {
					myself::DeleteItem1(talker,item_medal,num_oath);
					myself::GiveItem1(talker,item_proof,num_proof);
					myself::ShowPage(talker,fnChangeItem);
				} else {
					myself::ShowPage(talker,fnNotEnoughToChange);
					return;
				}
			}
		}
	}

	EventHandler PLEDGE_CASTLE_SIEGE_DEFENCE_COUNT_DECREASE_RETURNED(talker,reply) {
		if( reply == 0 ) {
			myself::ShowPage(talker,fnDecreaseCountFailed);
			return;
		} else if( reply == 1 ) {
			myself::ShowPage(talker,fnGetMedalSuccess);
			return;
		}
	}

}
