Commit bbbe1411 authored by nanahira's avatar nanahira

add Duel.MoveTurnCount

parent 23af4bb2
......@@ -1032,7 +1032,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
break;
}
case MSG_NEW_TURN: {
pbuf++;
int r_player = BufferIO::ReadInt8(pbuf);
time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
......@@ -1044,18 +1044,21 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
#ifdef YGOPRO_SERVER_MODE
NetServer::ReSendToPlayers(cache_recorder, replay_recorder);
#endif
if(turn_count > 0) {
if(turn_count % 2 == 0) {
if(cur_player[0] == players[0])
cur_player[0] = players[1];
else
cur_player[0] = players[0];
} else {
if(cur_player[1] == players[2])
cur_player[1] = players[3];
else
cur_player[1] = players[2];
if(!(r_player & 0x2)) {
if(turn_count > 0) {
if(turn_count % 2 == 0) {
if(cur_player[0] == players[0])
cur_player[0] = players[1];
else
cur_player[0] = players[0];
} else {
if(cur_player[1] == players[2])
cur_player[1] = players[3];
else
cur_player[1] = players[2];
}
}
turn_count++;
}
turn_count++;
break;
......
......@@ -377,6 +377,7 @@ static const struct luaL_Reg duellib[] = {
{ "Exile", scriptlib::duel_exile },
{ "DisableActionCheck", scriptlib::duel_disable_action_check },
{ "SetMetatable", scriptlib::duel_setmetatable },
{ "MoveTurnCount", scriptlib::duel_move_turn_count },
{ "EnableGlobalFlag", scriptlib::duel_enable_global_flag },
{ "GetLP", scriptlib::duel_get_lp },
......
......@@ -144,6 +144,15 @@ int32 scriptlib::duel_setmetatable(lua_State *L) {
lua_setmetatable(L, 1);
return 0;
}
int32 scriptlib::duel_move_turn_count(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
int32 turn_player = pduel->game_field->infos.turn_player;
pduel->game_field->infos.turn_id++;
pduel->game_field->infos.turn_id_by_player[turn_player]++;
pduel->write_buffer8(MSG_NEW_TURN);
pduel->write_buffer8(turn_player | 0x2);
return 0;
}
int32 scriptlib::duel_enable_global_flag(lua_State *L) {
check_param_count(L, 1);
......
......@@ -32,6 +32,7 @@ public:
static int32 duel_exile(lua_State *L);
static int32 duel_disable_action_check(lua_State *L);
static int32 duel_setmetatable(lua_State *L);
static int32 duel_move_turn_count(lua_State *L);
//card lib
static int32 card_get_code(lua_State *L);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment