PromptHeading = ID_TUTORIAL_9_OFFSET + 1
g_currentprompt = 0;
g_counter = 0;
Tweaks.numyearsin24hours = 0;

-------------------------------------------------------------------------------------------------
-- INITIALISE_Level. Standard level event
-------------------------------------------------------------------------------------------------
function EVENTINITIALISE_Level()
	--Game.Pause();
	-- load the building and business file
	C_RunScript("scripts\\maps\\tempmap.lua");
	C_RunScript("scripts\\tutorial9\\initialpref.lua");

end;

-------------------------------------------------------------------------------------------------
-- Level. Standard level event.
-------------------------------------------------------------------------------------------------
function EVENT_Level()
	-- create an initial prompt
	C_TriggerEvent("BlockCam", 1, PACIFIC_AVENUE);
	-- Game.Unpause();
	Interface.DisableAllControls();
	Interface.DisableAll3DPicking();
	Interface.DisableCameraControl();
	C_TriggerEvent("SetPlanView", 1);
	-- create the initial prompt
	CreatePrompt(1);
end;

function EVENT_AIBid(a)
		Interface.ForcePlayerToBid(a, 50*a); 	
end;

function EVENT_AIPass(a)
		Interface.ForcePlayerToPass(a);  	
end;

function EVENT_AIPullout(a)
		Interface.ForcePlayerToPullOut(a);  	
end;

function CATCHEVENT_InterfacePromptDismiss(a)

	if g_currentprompt == 21 then
		Game.Unpause();
		C_TriggerEvent("AIPullout", 25, 1);
		C_TriggerEvent("AIPullout", 125, 2);
		g_counter = g_counter + 1;
		return 0;
	end;

	if g_currentprompt == 18 then
		Game.Unpause();
		C_TriggerEvent("AIBid", 25, 1);
		C_TriggerEvent("AIBid", 125, 2);
		C_TriggerEvent("AIPullout", 225, 3);
		g_counter = g_counter + 1;
		return 0;
	end;
			
	if g_currentprompt == 15 then
		Game.Unpause();
		C_TriggerEvent("AIBid", 25, 1);
		C_TriggerEvent("AIBid", 125, 2);
		C_TriggerEvent("AIPass", 225, 3);
		g_counter = g_counter + 1;
		return 0;
	end;

   if g_currentprompt == 6 then
			Game.Unpause();
		else
			CreatePrompt(a);
	end;
end;

function CATCHEVENT_TutorialEvent(a)

	if a ~= TUT_MYGO and g_currentprompt == 21 then
		Interface.DismissPrompt();
	end;

	if a == TUT_MYGO and g_currentprompt == 21 then
		Interface.DisableAllControls();
		CreatePrompt(22);
		Interface.DisableControl(TUT_AUCTION_50);
		Interface.DisableControl(TUT_AUCTION_100);
		Interface.DisableControl(TUT_AUCTION_500);
		Interface.DisableControl(TUT_AUCTION_PASS);
		Interface.DisableControl(TUT_AUCTION_PULLOUT);
	end;

	if a ~= TUT_MYGO and g_currentprompt == 18 then
		Interface.DismissPrompt();
	end;

	if a == TUT_MYGO and g_currentprompt == 18 then
		Interface.DisableAllControls();
		CreatePrompt(19);
		Interface.DisableControl(TUT_AUCTION_50);
		Interface.DisableControl(TUT_AUCTION_100);
		Interface.DisableControl(TUT_AUCTION_500);
		Interface.DisableControl(TUT_AUCTION_PASS);
		Interface.DisableControl(TUT_AUCTION_PULLOUT);
	end;

	if g_currentprompt == 17 then
		Interface.DismissPrompt();
	end;

	if a == TUT_MYGO and g_currentprompt == 15 then
		Interface.DisableAllControls();
		CreatePrompt(16);
		Interface.DisableControl(TUT_AUCTION_50);
		Interface.DisableControl(TUT_AUCTION_100);
		Interface.DisableControl(TUT_AUCTION_500);
		Interface.DisableControl(TUT_AUCTION_PASS);
		Interface.DisableControl(TUT_AUCTION_PULLOUT);
	end;

	if a == TUT_BEGINAUCTION then
--		Interface.DismissPrompt();
		CreatePrompt(7);
	end;

	if g_currentprompt == 4 then
		Interface.DismissPrompt();
		Interface.DisableControl(TUT_MPP_BLOCK_BUYBLOCK);
	end;

	if g_currentprompt == 3 then
		Interface.DismissPrompt();
		Interface.DisableControl(TUT_MPP_GREENBUTTON_2);
	end;

end;


function CATCHEVENT_Picked3D(a)
	if a == 1 and g_currentprompt == 2 then
		Interface.DismissPrompt();
		Interface.DisableAll3DPicking();
	end;		
end;

-- prompt manager
function CreatePrompt(a)
	g_currentprompt = a;
	body = a+PromptHeading;
	if a == 1 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"We've already touched on auctions, but now we'll look at one in more detail...",a+1);
	elseif a == 2 then
		Interface.CreateMessage(PromptHeading,body, a+1); --"Our auction will revolve around Pacific Avenue. Double click on it.", a+1);
		Interface.EnableBlockPicking(PACIFIC_AVENUE);
		Interface.PositionPrompt(0,100);
		Interface.AddArrow(452,177);
	elseif a == 3 then
		Interface.CreateMessage(PromptHeading,body, a+1); --"Click on the Lease Block button. ", a+1);
		Interface.EnableControl(TUT_MPP_GREENBUTTON_2);
		Interface.AddArrow(29,92);
	elseif a == 4 then
		Interface.CreateMessage(PromptHeading,body, a+1); --"There is a minimum offer price, but if you want you can increase this value. When you click the Lease Block button an auction will be triggered. The offer price that you set will be the opening bid. Click Lease Block now.", a+1);
		Interface.EnableControl(TUT_MPP_BLOCK_BUYBLOCK);
		Interface.PositionPrompt(0,-100);
		Interface.AddArrow(158,128);
	elseif a == 5 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"The auction has now been registered and will take place when the timer reaches zero. If the auction timer is running no one else is able to put in an offer for a block until after the auction. Also, you cannot build on the block that is going to auction.", a+1);
		Interface.PositionPrompt(0,100);
		Interface.AddArrow(616,114);
		Game.Pause();
	elseif a == 6 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"You can get more information by clicking here. Click Continue to un-pause the game and go to auction.", a+1);
		Interface.EnableControlAndChildren(TUT_AUCTION_TIMER_PANEL);
		Interface.AddArrow(613,88);
	elseif a == 7 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"This is the Auction Room. It is here that you will bid for the lease of the City Block. We've frozen time to give you a chance to look around.", a+1);
	elseif a == 8 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"This panel tells you the Block Lease that you are bidding for, and who holds the current bid.", a+1);
		Interface.AddArrow(321, 32);
	elseif a == 9 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"This is you. As you put in the initial offer on the block, you hold the current bid. That's why your bid value is drawn so big.", a+1);
		Interface.AddArrow( 180, 160);
	elseif a == 10 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"You can also see how much cash you are holding.", a+1);
		Interface.PositionPrompt(0,-140);
		Interface.AddArrow( 180, 257);
	elseif a == 11 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"You can see other players' cash as well. This is useful when trying to decide how far to push the bidding.", a+1);
		Interface.AddArrow( 377, 262);
	elseif a == 12 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"This player is thinking. When the game is un-paused they will either bid, pass or pull out. We'll cover this in detail a little later. The pulsing spotlight helps you identify the player who's turn it is.", a+1);
		Interface.AddArrow(252, 277);
	elseif a == 13 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"Here you can see who owns the buildings on this block. If you hover the cursor over one of the buildings the tool-tip will tell you what business is running there.", a+1);
		Interface.AddArrow(118,393);
	elseif a == 14 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"This panel is very important. It tells you who already owns blocks in the city. Be sure to try to stop anyone else getting a Monopoly - all the blocks in a colour group.", a+1);
		Interface.AddArrow(523, 372);
	elseif a == 15 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"Okay, let's get on with the auction. When you click continue the game will un-pause and the other players will make their bids.", a+1);
	elseif a == 16 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"It looks like the other players' have an interest in this block too.", a+1);
	elseif a == 17 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"You have a limited time to put in your bid. If the timer runs out you will automatically pull out of the auction. For this tutorial, you will remain in the auction when the counter hits 0.", a+1);
		Interface.AddArrow(137, 75);
	elseif a == 18 then
		Interface.CreateMessage(PromptHeading,body, a+1); --"Now it is your turn to bid. All you need to do is select how much you want to raise it. Choose $50, $100 or $500, depending on how rich you feel, and how much you want the block.", a+1);
		Interface.AddArrow(310, 346);
		Interface.EnableControl(TUT_AUCTION_50);
		Interface.EnableControl(TUT_AUCTION_100);
		Interface.EnableControl(TUT_AUCTION_500);
		Interface.DisableControl(TUT_AUCTION_PASS);
		Interface.DisableControl(TUT_AUCTION_PULLOUT);
	elseif a == 19 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"If you click this button you would withdraw from the auction. The two remaining players would bid until one pulled out. The winner would take the block lease.", a+1);
		Interface.AddArrow( 281, 431);
	elseif a == 20 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"If you clicked here you would pass. As long as someone else bids you will stay in the auction. If no one else bids, the current bid holder will take the property lease.", a+1);
		Interface.AddArrow( 348, 432);
	elseif a == 21 then
		Interface.CreateMessage(PromptHeading,body, a+1); --"Bid again and try to win the block.", a+1);
		Interface.AddArrow( 326, 393);
		Interface.EnableControl(TUT_AUCTION_50);
		Interface.EnableControl(TUT_AUCTION_100);
		Interface.EnableControl(TUT_AUCTION_500);
		Interface.DisableControl(TUT_AUCTION_PASS);
		Interface.DisableControl(TUT_AUCTION_PULLOUT);
	elseif a == 22 then
		Interface.CreatePrompt(PromptHeading,body, a+1); --"Well done - you've won your first auction. You now have the lease for twenty-five years. Once this time expires the city will reclaim the lease. Make the most of your rent-free time, and if possible, build up and collect the leases for all the properties in this group.", a+1);
		Game.Pause();
	elseif a == 23 then
		Game.End(true);
	end;
end;


