@LabelIndex 108745
@StringIndex 12828
class 0 fortress_steward : steward {
parameter:
	int	fortress_id = 0;
	int	InContract = 0;
	int	ContractCastle = 0;
	string	fnHi1 = "";
	string	fnHi2 = "";
	string	fileSetName = "FortressDeco";
	int	fstr_own_time = 1300135;
	string	fnFortressInfo = "fortress_steward022.htm";
	string	fnFortressInfoIndep = "fortress_steward023.htm";
	int	fstr_parent_castle = 1001000;
	int	fstr_no_parent = 1300136;
	int	fstr_contract_status = 1300123;
	int	dominion_id = 81;

handler:
	EventHandler CREATED() {
		myself::RegisterTeleporterType(1,0);
		super;
	}

	EventHandler TALKED(talker,i0,i1,i2,fhtml0) {
		if( myself::IsMyLord(talker) || ( myself::Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0 ) ) {
			if( myself::Castle_IsUnderSiege() || gg::GetDominionWarState(dominion_id) == 5 ) {
				myself::ShowPage(talker,fnIsUnderSiege);
			} else {
				myself::ShowPage(talker,fnHi);
			}
		} else {
			myself::ShowPage(talker,fnHi2);
		}
	}

	EventHandler MENU_SELECTED(talker,ask,reply,fhtml0,i0,i1,i2,i4,i5,i6,i7,s1) {
		super;
		if( ask == -272 ) {
			if( reply == 0 ) {
				i0 = gg::Fortress_GetAvailableOwnMinutes(fortress_id);
				i1 = ( i0 / 60 );
				i2 = ( i0 % 60 );
				i4 = gg::Fortress_GetParentCastleId(fortress_id);
				if( i4 > 0 && i4 < 10 ) {
					i5 = gg::Fortress_GetContractStatus(fortress_id);
					i6 = gg::Fortress_GetRentCost(fortress_id);
					i7 = gg::Fortress_GetNextRewardRemainTime(fortress_id);
					myself::FHTML_SetFileName(fhtml0,fnFortressInfo);
					myself::FHTML_SetStr(fhtml0,"ParentCastle",gg::MakeFString(( fstr_parent_castle + i4 ),"","","","",""));
					myself::FHTML_SetStr(fhtml0,"ContractStatus",gg::MakeFString(( fstr_contract_status + i5 ),"","","","",""));
					myself::FHTML_SetInt(fhtml0,"RentCost",( i6 * 2 ));
					myself::FHTML_SetInt(fhtml0,"NextDueHour",( i7 / 60 ));
					myself::FHTML_SetInt(fhtml0,"NextDueMin",( i7 % 60 ));
				} else {
					myself::FHTML_SetFileName(fhtml0,fnFortressInfoIndep);
					myself::FHTML_SetStr(fhtml0,"ParentCastle",gg::MakeFString(fstr_no_parent,"","","","",""));
				}
				myself::FHTML_SetStr(fhtml0,"time_remained",gg::MakeFString(fstr_own_time,gg::IntToStr(i1),gg::IntToStr(i2),"","",""));
				myself::ShowFHTML(talker,fhtml0);
			}
		}
	}

}
