//////////////////////////////////////////////////////////////////////////////
//
// Asura_Project_Platform_Rewards_System.cpp
//
// Copyright (c) 2009 Rebellion. All rights reserved.
//
// Description:
//
//     Platform specific project reward functions
//
//////////////////////////////////////////////////////////////////////////////

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

#include "Core/Asura.h"

#ifdef ASURA_USE_REWARDS

#include "Rewards/Asura_Rewards_System.h"
#include "Rewards/Asura_PS3_Trophies_System.h"

#include "Rewards/AVP_Rewards_System.h"


// NY - 18 March 2009 - temp - from sample
// projects will need to replace this with the ones from the sony website
static const SceNpCommunicationId s_xCommunication_ID =
{
	{'N','P','X','S','0','0','0','2','2'},
	0,
	0,
	0
};

// NY - 18 March 2009 - temp - from sample
// projects will need to replace this with the ones from the sony website
static const SceNpCommunicationSignature s_xCommunication_Sig =
{
	{
		0xb9,0xdd,0xe1,0x3b,0x01,0x00,0x00,0x00,
		0x00,0x00,0x00,0x00,0x1d,0x3c,0x55,0x0f,
		0x35,0xb5,0x54,0xfe,0x4e,0x97,0x1a,0x01,
		0x23,0x38,0xaa,0xd6,0x3d,0xda,0x6a,0xac,
		0x3e,0x95,0xff,0x09,0x49,0xd7,0xb3,0xda,
		0x11,0xae,0xf0,0xde,0xd6,0x2b,0x70,0x96,
		0x40,0x09,0x0e,0xed,0x8c,0x38,0x1d,0xa4,
		0xc3,0x0e,0xc9,0x30,0xc1,0xcc,0x66,0x92,
		0xd1,0xb0,0x6e,0x01,0xc0,0x44,0xb2,0xa2,
		0xd0,0x62,0x88,0xa8,0x26,0x7f,0x91,0xb5,
		0x7b,0x40,0x0c,0x6a,0xc9,0x3b,0x5c,0x89,
		0x43,0x22,0x16,0x4e,0x27,0x56,0x46,0x4a,
		0x63,0xc4,0x55,0xce,0xb3,0xce,0xf7,0x92,
		0x07,0x71,0x13,0x60,0x6e,0xcb,0xad,0xd5,
		0xf0,0x60,0xd6,0x71,0x3a,0x45,0xaa,0x25,
		0x38,0x60,0x11,0x1a,0xa5,0x0e,0xcf,0xa4,
		0x21,0xc8,0x94,0x6d,0xf2,0x0d,0xac,0xcf,
		0x67,0x8d,0x4a,0x14,0x14,0x4e,0xed,0x45,
		0x67,0x40,0x60,0x93,0x2b,0x00,0xeb,0xb7,
		0xf3,0x2f,0x09,0x36,0xb6,0x59,0x84,0x0e
	}
};

// NY - 31 March 2009 - array to store mappings of independent rewards to trophies
// -1 means reward not mapped on ps3
int aiAVP_PS3_Rewards[AVP_NUM_REWARDS] =
{
	0, // AVP_REWARD_COMPLETE_LEVEL
};

// NY - 31 March 2009 - platform specific event handler, for anything that needs platform specific code, or that only relates to one platform
void Asura_Rewards_System::Project_Platform_HandleEvent(Asura_Hash_ID uEventHash, int iEventData)
{
//	switch (uEventHash)
//	{
//		default:
//		{
//			// do nothing
//			break;
//		}
//	}
}

// NY - 31 March 2009 - reward mapping - just do a bounds checked lookup on the array
int Asura_PS3_Trophies_System::Project_ConvertReward(u_int uRewardIndex)
{
	if (uRewardIndex < AVP_NUM_REWARDS)
	{
		return aiAVP_PS3_Rewards[uRewardIndex];
	}
	Asura_Assert(false, "Reward index out of range");
	return -1;
}

// NY - 31 March 2009 - return project specific comms id
const SceNpCommunicationId* Asura_PS3_Trophies_System::Project_GetCommunicationID()
{
	return &s_xCommunication_ID;
}

// NY - 31 March 2009 - return project specific comms sig
const SceNpCommunicationSignature* Asura_PS3_Trophies_System::Project_GetCommunicationSig()
{
	return &s_xCommunication_Sig;
}

// NY - 01 May 2009 - return how much space to check for on boot over and above whatever is needed by trophies
// This ideally should include save games, if so we need to check if we actually have a save yet
// Similar applies for game data, however, if the gamedata is mandatory that effectively must be included here when not already installed
// Called from a thread (producer consumer quere), so if save/load code hasn't determined how much space is needed yet
//  then wait (yielding as needed) before returning.
u_int Asura_PS3_Trophies_System::Project_GetRequiredSpaceInK()
{
	return 0;
}


#endif // #ifdef ASURA_USE_REWARDS
