
System.DoFile(Game.GetDataPath().."AchEndRound.lua");
	
-----------------------------------------------------------------------------
-- CHECK FOR ITEM UNLOCKS
-----------------------------------------------------------------------------

function CheckItemUnlocks()
	System.OutputDebugString("Checking Item Unlocks\n");
	
	if(EntGame.CheckWeaponUnlocks() == true) then
		return(true);
		end;
		
	if(EntGame.CheckItemUnlocks() == true) then
		return(true);
		end;

	end;


-----------------------------------------------------------------------------

function ShowAchievements()
	
	-- Award items here.
    while( CheckItemUnlocks() == true ) do
		EntGame.PushMenu("MenuUnlockNotice");
		EntGame.ClearFlag(GF_READYTOSTART);		
		
		-- wait until the we accepted the award
		while (EntGame.GetFlag(GF_READYTOSTART) == false) do
			Script.WaitFrame(1);
			end;
		end;
	
	-- award achievements here
	while( IsNewAchievement() == true ) do
		EntGame.PushMenu("MenuAchieveNotice");
		EntGame.ClearFlag(GF_READYTOSTART);		
		
		-- wait until the we accepted the award
		while (EntGame.GetFlag(GF_READYTOSTART) == false) do
			Script.WaitFrame(1);
			end;
		
    	end;
    	
	System.OutputDebugString("Done with Achievements!\n");
	-- Jump back to the main menu
	-- JJK: TODO: will need to go back to the tournament screen in single/multi mode
	menuRoot = Game.GetMenuEntity()
	
	if ( EntGame.IsTradeShow() ) then
		EntGame.PushMenu("MenuTradeShow");
	else
		EntGame.RunReturnToLodgeMenu();
        end;

	end; -- end function


-----------------------------------------------------------------------------

function IsNewAchievement()

    System.OutputDebugString("Checking End-of-Round achievements\n");

	if(DoAchEndRound()) then
		return(true);
		end;

    return(false);

	end;

-------------------------------------------------------------------------

ShowAchievements();

