//////////////////////////////////////////////////////////////////////////////
//
// Asura_Platform_Rewards_System.cpp
//
// Copyright (c) 2009 Rebellion. All rights reserved.
//
// Description:
//
//     Engine class to unify platform Reward (achievement) systems
//
//////////////////////////////////////////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

#include "Core/Asura.h"

#ifdef ASURA_USE_REWARDS

// This file's header.
#include "Rewards/Asura_Rewards_System.h"

#include "Rewards/Asura_PS3_Trophies_System.h"

void Asura_Rewards_System::Platform_Initialise()
{
	Asura_PS3_Trophies_System::Initialise();
}

void Asura_Rewards_System::Platform_Shutdown()
{
	Asura_PS3_Trophies_System::Shutdown();
}

void Asura_Rewards_System::Platform_Reset()
{
	Asura_PS3_Trophies_System::Reset();
}

void Asura_Rewards_System::Platform_UnlockReward(u_int uRewardIndex)
{
	// NY - 30 March 2009 - silently ignore if rewards not valid for ps3
	int iTrophy = Asura_PS3_Trophies_System::Project_ConvertReward(uRewardIndex);
	if (iTrophy >= 0)
	{
		Asura_PS3_Trophies_System::UnlockTrophy(iTrophy);
	}
}

void Asura_Rewards_System::Platform_RewardProgress(u_int uRewardIndex, u_int uProgress, u_int uTarget)
{
	// NY - 25 March 2009 - stubbed out for now as nothing in SDK to handle this
}

bool Asura_Rewards_System::Platform_IsRewardUnlocked(u_int uRewardIndex)
{
	int iTrophy = Asura_PS3_Trophies_System::Project_ConvertReward(uRewardIndex);
	if (iTrophy < 0)
	{
		// NY - 30 March 2009 - silently return false if not valid for PS3
		return false;
	}
	return Asura_PS3_Trophies_System::IsTrophyUnlocked(iTrophy);
}

bool Asura_Rewards_System::Platform_IsRewardAvailable(u_int uRewardIndex)
{
	return Asura_PS3_Trophies_System::Project_ConvertReward(uRewardIndex) >= 0;
}

bool Asura_Rewards_System::Platform_IsInitComplete()
{
	return Asura_PS3_Trophies_System::IsInitComplete();
}

bool Asura_Rewards_System::Platform_IsReadyToUnlock()
{
	// NY - 30 March 2009 - basically always true once init started, due to threading code - failiure of init should be handled on PS3 by the game stopping on a message
	return Asura_PS3_Trophies_System::IsInitialised();
}

#endif // #ifdef ASURA_USE_REWARDS
