class 1 olympiad_operator_basic : citizen
{
handler:
	EventHandler TALKED(talker)
	{
		if( talker.karma > 0 )
		{
			myself::ShowPage(talker,  "wyac.htm");
			return;
		}
		if( talker.nobless_type == 1 )
		{
			myself::ShowPage(talker,"olympiad_operator001.htm");
		}
		else
		{
			myself::ShowPage(talker,"olympiad_operator002.htm");
		}
	}

	EventHandler MENU_SELECTED(talker,ask,reply,fhtml0,i0,s0,s1)
	{
		if( ask == -50 )
		{
			if( talker.nobless_type == 1 )
			{
				myself::ShowPage(talker,"olympiad_operator001.htm");
			}
			else
			{
				myself::ShowPage(talker,"olympiad_operator002.htm");
			}
		}
		else if( ask == -51 )
		{
			myself::ShowPage(talker,"olympiad_operator010.htm");
		}
		else if( ask == -52 )
		{
			switch(reply)
			{
				case 0:
				{
					myself::ShowPage(talker,"olympiad_operator001.htm");
					break;
				}
				case 1:
				{
					if( gg::GetDateTime(0,3) >= 23 && gg::GetDateTime(0,4) >= 50 )
					{
						myself::ShowPage(talker,"olympiad_operator010k.htm");
					}
					else
					{
						myself::ShowPage(talker,"olympiad_operator010a.htm");
					}
					break;
				}
				case 2:
				{
					if( gg::GetDateTime(0,3) >= 23 && gg::GetDateTime(0,4) >= 50 )
					{
						myself::ShowPage(talker,"olympiad_operator010k.htm");
					}
					else
					{
						myself::ShowPage(talker,"olympiad_operator010b.htm");
					}
					break;
				}
				case 3:
				{
					myself::FHTML_SetFileName(fhtml0,"olympiad_operator010f.htm");
					i0 = myself::GetOlympiadWaitingCount();
					if( i0 < 100 )
					{
						myself::FHTML_SetStr(fhtml0,"WaitingCount",myself::MakeFString(1000504,"100","","","",""));
					}
					else
					{
						myself::FHTML_SetStr(fhtml0,"WaitingCount",myself::MakeFString(1000505,"100","","","",""));
					}
					i0 = myself::GetClassFreeOlympiadWaitingCount();
					if( i0 < 100 )
					{
						myself::FHTML_SetStr(fhtml0,"WaitingCount",myself::MakeFString(1000504,"100","","","",""));
					}
					else
					{
						myself::FHTML_SetStr(fhtml0,"WaitingCount",myself::MakeFString(1000505,"100","","","",""));
					}
					myself::ShowFHTML(talker,fhtml0);
					break;
				}
				case 4:
				{
					myself::ShowPage(talker,"olympiad_operator010g.htm");
					break;
				}
				case 5:
				{
					myself::FHTML_SetFileName(fhtml0,"olympiad_operator010h.htm");
					myself::FHTML_SetInt(fhtml0,"WaitingCount",myself::GetOlympiadPoint(talker));
					myself::ShowFHTML(talker,fhtml0);
				}
			}
		}
		else if( ask == -53 )
		{
			if( reply == 0 )
			{
				myself::ShowPage(talker,"olympiad_operator001.htm");
			}
			else if( reply == 1 )
			{
				if( myself::IsMainClass(talker) == 1 )
				{
					if( myself::IsInCategory(8,talker.occupation) )
					{
						if( myself::GetOlympiadPoint(talker) > 0 )
						{
							myself::AddClassFreeOlympiad(talker);
						}
						else
						{
							myself::ShowPage(talker,"olympiad_operator010i.htm");
						}
					}
					else
					{
						myself::ShowPage(talker,"olympiad_operator010j.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"olympiad_operator010c.htm");
				}
			}
		}
		else if( ask == -54 )
		{
			if( reply == 0 )
			{
				myself::ShowPage(talker,"olympiad_operator001.htm");
			}
			else if( reply == 1 )
			{
				if( myself::IsMainClass(talker) == 1 )
				{
					if( myself::IsInCategory(8,talker.occupation) )
					{
						if( myself::GetOlympiadPoint(talker) > 0 )
						{
							myself::AddOlympiad(talker);
						}
						else
						{
							myself::ShowPage(talker,"olympiad_operator010i.htm");
						}
					}
					else
					{
						myself::ShowPage(talker,"olympiad_operator010j.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"olympiad_operator010c.htm");
				}
			}
		}
		else if( ask == -55 )
		{
			myself::ShowPage(talker,"olympiad_operator030.htm");
		}
		else if( ask == -56 )
		{
		}
		else if( ask == -57 )
		{
		}
		else if( ask == -58 )
		{
			myself::RemoveOlympiad(talker);
		}
		else if( ask == -59 )
		{
			myself::FHTML_SetFileName(fhtml0,"olympiad_operator020.htm");
			for(i0 = 1; i0 <= 22; i0 = ( i0 + 1 ))
			{
				s0 = "";
				s1 = "";
				myself::FHTML_SetInt(fhtml0,"FI" + i0,i0);
				if( myself::GetStatusForOlympiadField(i0) == 0 )
				{
					myself::FHTML_SetStr(fhtml0,"Status" + i0,"&$906;");
				}
				else
				{
					s0 = "&$829;" + "&nbsp;&nbsp;&nbsp;" + myself::GetPlayer1ForOlympiadField(i0) + "&nbsp; : &nbsp;" + myself::GetPlayer2ForOlympiadField(i0);
					myself::FHTML_SetStr(fhtml0,"Status" + i0,s0);
				}
			}
			myself::ShowFHTML(talker,fhtml0);
		}
		else if( ask == -60 )
		{
			if( reply == 0 )
			{
				if( talker.nobless_type == 1 )
				{
					myself::ShowPage(talker,"olympiad_operator001.htm");
				}
				else
				{
					myself::ShowPage(talker,"olympiad_operator002.htm");
				}
			}
		}
		else if( ask == -61 )
		{
			myself::ShowPage(talker,"olympiad_operator020.htm");
		}
		else if( ask == -70 )
		{
			if( reply == 0 )
			{
				myself::ShowPage(talker,"olympiad_operator001.htm");
			}
			else if( reply == 1 )
			{
				if( myself::GetPreviousOlympiadPoint(talker) == 0 )
				{
					myself::ShowPage(talker,"olympiad_operator031a.htm");
				}
				else if( myself::GetPreviousOlympiadPoint(talker) < 50 )
				{
					if( talker.hero_type == 1 || talker.hero_type == 2 )
					{
						myself::ShowPage(talker,"olympiad_operator031.htm");
					}
					else
					{
						myself::ShowPage(talker,"olympiad_operator031a.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"olympiad_operator031.htm");
				}
			}
			else if( reply == 513 )
			{
				myself::ShowMultisell(reply,talker);
			}
		}
		else if( ask == -71 )
		{
			if( reply == 0 )
			{
				myself::ShowPage(talker,"olympiad_operator030.htm");
			}
			else if( reply == 1 )
			{
				myself::DeletePreviousOlympiadPoint(talker,myself::GetPreviousOlympiadPoint(talker));
			}
		}
		else if( ask == -80 )
		{
		}
		else if( ask == -110 )
		{
			myself::FHTML_SetFileName(fhtml0,"olympiad_operator_rank_class.htm");
			for(i0 = 1; i0 <= 15; i0 = ( i0 + 1 ))
			{
				if( myself::GetRankByOlympiadRankOrder(reply,i0) == 0 )
				{
				}
				else
				{
					myself::FHTML_SetInt(fhtml0,"Rank" + i0,myself::GetRankByOlympiadRankOrder(reply,i0));
					myself::FHTML_SetStr(fhtml0,"Name" + i0,myself::GetNameByOlympiadRankOrder(reply,i0));
				}
				myself::ShowFHTML(talker,fhtml0);
			}
			if( ask == -130 )
			{
				myself::ObserveOlympiad(talker,reply);
			}
		}

	EventHandler DELETE_PREVIOUS_OLYMPIAD_POINT_RETURNED(talker,ask,reply,i0,i1)
	{
		i1 = 0;
		if( reply != 0 )
		{
			if( talker.hero_type == 1 || talker.hero_type == 2 )
			{
				i1 = 300;
			}
			if( ask > 1000 )
			{
				i0 = ( ( 1000 + i1 ) * 1000 );
			}
			else if( ask < 50 )
			{
				i0 = ( i1 * 1000 );
			}
			else
			{
				i0 = ( ( ask + i1 ) * 1000 );
			}
			myself::AddLogEx(1,talker,ask,i0);
			myself::GiveItem1(talker,6651,i0);
		}
	}

}
