#include "NetCli_Party.h"

//-------------------------------------------------------------------
NetCli_Party*    NetCli_Party::This         = NULL;
//-------------------------------------------------------------------
bool NetCli_Party::_Init()
{
	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_Invite		, _PG_Party_ChattoC_Invite			);
	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_PartyBaseInfo	, _PG_Party_ChattoC_PartyBaseInfo	);
	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_AddMember		, _PG_Party_ChattoC_AddMember		);
	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_DelMember		, _PG_Party_ChattoC_DelMember		);
	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_FixMember		, _PG_Party_ChattoC_FixMember		);

	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_PartyTreasure		, _PG_Party_ChattoC_PartyTreasure		);
	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_PartyTreasureLoot	, _PG_Party_ChattoC_PartyTreasureLoot	);
	_Net.RegOnSrvPacketFunction	( EM_PG_Party_ChattoC_GiveItemInfo		, _PG_Party_ChattoC_GiveItemInfo		);
    return true;
}
//-------------------------------------------------------------------
bool NetCli_Party::_Release()
{
    return true;
}
//-------------------------------------------------------------------
void NetCli_Party::_PG_Party_ChattoC_GiveItemInfo		( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_GiveItemInfo* PG = (PG_Party_ChattoC_GiveItemInfo*) Data;
	This->R_GiveItemInfo( PG->DBID , PG->Item , PG->Version );
}

void NetCli_Party::_PG_Party_ChattoC_Invite			( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_Invite* PG = (PG_Party_ChattoC_Invite*) Data;
	This->R_Invite( (char*)PG->LeaderName.Begin() );
}
void NetCli_Party::_PG_Party_ChattoC_PartyBaseInfo	( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_PartyBaseInfo* PG = (PG_Party_ChattoC_PartyBaseInfo*) Data;
	This->R_PartyBaseInfo( PG->Info );
}
void NetCli_Party::_PG_Party_ChattoC_AddMember		( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_AddMember* PG = (PG_Party_ChattoC_AddMember*) Data;
	This->R_AddMember( PG->NewMember );
}
void NetCli_Party::_PG_Party_ChattoC_DelMember		( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_DelMember* PG = (PG_Party_ChattoC_DelMember*) Data;
	This->R_DelMember( PG->Member );
}
void NetCli_Party::_PG_Party_ChattoC_FixMember		( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_FixMember* PG = (PG_Party_ChattoC_FixMember*) Data;
	This->R_FixMember( PG->Member );
}
void NetCli_Party::_PG_Party_ChattoC_PartyTreasure		( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_PartyTreasure* PG = (PG_Party_ChattoC_PartyTreasure*) Data;
	This->R_PartyTreasure	( PG->ItemVersion , PG->LootType , PG->Item , PG->LootDBID );
}
void NetCli_Party::_PG_Party_ChattoC_PartyTreasureLoot	( int NetID , int Size , void* Data )
{
	PG_Party_ChattoC_PartyTreasureLoot* PG = (PG_Party_ChattoC_PartyTreasureLoot*) Data;
	This->R_PartyTreasureLoot( PG->ItemVersion , PG->DBID , PG->LootValue );

}
//-------------------------------------------------------------------
void NetCli_Party::S_Invite		( char* Name )
{
	PG_Party_CtoChat_Invite Send;
	Send.InviteName = Name;
	SendToChat( sizeof( Send ) , &Send );
}
void NetCli_Party::S_Join		( char* LeaderName )
{
	PG_Party_CtoChat_Join Send;
	Send.LeaderName = LeaderName;
	SendToChat( sizeof( Send ) , &Send );
}
void NetCli_Party::S_KickMember	( char* MemberName )
{
	PG_Party_CtoChat_KickMember Send;
	Send.MemberName = MemberName;
	SendToChat( sizeof( Send ) , &Send );
}
void NetCli_Party::S_PartyRule	( PartyBaseInfoStruct& PartyInfo )
{
	PG_Party_CtoChat_PartyRule Send;
	Send.PartyInfo = PartyInfo;
	SendToChat( sizeof( Send ) , &Send );
}

void NetCli_Party::S_LootItem( int ItemVersion )
{
	PG_Party_CtoChat_PartyTreasureLoot Send;
	Send.DBID = -1;
	Send.Type = EM_PartyTreasureLootType_Loot;
	Send.ItemVersion = ItemVersion;
	SendToChat( sizeof( Send ) , &Send );
}
void NetCli_Party::S_PassItem( int ItemVersion )
{
	PG_Party_CtoChat_PartyTreasureLoot Send;
	Send.DBID = -1;
	Send.Type = EM_PartyTreasureLootType_Pass;
	Send.ItemVersion = ItemVersion;
	SendToChat( sizeof( Send ) , &Send );
}
void NetCli_Party::S_AssistItem( int ItemVersion , int DBID )
{
	PG_Party_CtoChat_PartyTreasureLoot Send;
	Send.DBID = DBID;
	Send.Type = EM_PartyTreasureLootType_Assist;
	Send.ItemVersion = ItemVersion;
	SendToChat( sizeof( Send ) , &Send );
}
void NetCli_Party::S_LootItem_NotNeed( int ItemVersion )
{
	PG_Party_CtoChat_PartyTreasureLoot Send;
	Send.Type = EM_PartyTreasureLootType_Loot_NotNeed;
	Send.ItemVersion = ItemVersion;
	SendToChat( sizeof( Send ) , &Send );
}