#include "../../netwaker_member/NetWakerClientInc.h"
#include "CharacterCreate.h"

CCharacterCreate*		g_pCharacterCreate = NULL;

int LuaFunc_CreateCharacter(lua_State *L);

// --------------------------------------------------------------------------------------
CCharacterCreate::CCharacterCreate(CInterface* object)
	: CInterfaceBase(object)
{

	g_pCharacterCreate = this;
}

// --------------------------------------------------------------------------------------
CCharacterCreate::~CCharacterCreate()
{
	g_pCharacterCreate = NULL;
}

// --------------------------------------------------------------------------------------
void CCharacterCreate::RegisterFunc()
{
	lua_State* L = GetLuaStateLogin();
	if (L)
	{
		lua_register(L, "CreateCharacter",		LuaFunc_CreateCharacter);
	}
}

// --------------------------------------------------------------------------------------
int LuaFunc_CreateCharacter(lua_State *L)
{
	CreateRoleData role;
	role.SampleRole.init();
	role.SampleRole.RoleName = luaL_checkstring(L, 1);

	switch (luaL_checkint(L, 2))
	{
	case 1:
		role.SampleRole.Sex = EM_Sex_Boy;
		role.iRoleBaseID = 1000;
		break;

	case 2:
		role.SampleRole.Sex = EM_Sex_Girl;
		role.iRoleBaseID = 1001;
		break;
	}

	switch (luaL_checkint(L, 3))
	{
	case 1:
		role.SampleRole.Voc = EM_Vocation_Warrior;
		break;
	case 2:
		role.SampleRole.Voc = EM_Vocation_Wizard;
		break;
	case 3:
		role.SampleRole.Voc = EM_Vocation_Rogue;
		break;
	}	
	
	role.iBodyColor = 2;
	role.iHairColor = 4;
	role.iFaceID = 2000;
	role.iHairID = 2001;
	CNetCli_Login::CreateRole(&role);
	return 0;
}