Commit 5be1c7d0 authored by Momobako's avatar Momobako

updc

parent d3e8fa81
...@@ -358,6 +358,8 @@ static const struct luaL_Reg duellib[] = { ...@@ -358,6 +358,8 @@ static const struct luaL_Reg duellib[] = {
{ "RegisterFlagEffect", scriptlib::duel_register_flag_effect }, { "RegisterFlagEffect", scriptlib::duel_register_flag_effect },
{ "GetFlagEffect", scriptlib::duel_get_flag_effect }, { "GetFlagEffect", scriptlib::duel_get_flag_effect },
{ "ResetFlagEffect", scriptlib::duel_reset_flag_effect }, { "ResetFlagEffect", scriptlib::duel_reset_flag_effect },
{ "SetFlagEffectLabel", scriptlib::duel_set_flag_effect_label },
{ "GetFlagEffectLabel", scriptlib::duel_get_flag_effect_label },
{ "Destroy", scriptlib::duel_destroy }, { "Destroy", scriptlib::duel_destroy },
{ "Remove", scriptlib::duel_remove }, { "Remove", scriptlib::duel_remove },
{ "SendtoGrave", scriptlib::duel_sendto_grave }, { "SendtoGrave", scriptlib::duel_sendto_grave },
...@@ -442,6 +444,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -442,6 +444,7 @@ static const struct luaL_Reg duellib[] = {
{ "CheckLocation", scriptlib::duel_check_location }, { "CheckLocation", scriptlib::duel_check_location },
{ "GetCurrentChain", scriptlib::duel_get_current_chain }, { "GetCurrentChain", scriptlib::duel_get_current_chain },
{ "GetChainInfo", scriptlib::duel_get_chain_info }, { "GetChainInfo", scriptlib::duel_get_chain_info },
{ "GetChainEvent", scriptlib::duel_get_chain_event },
{ "GetFirstTarget", scriptlib::duel_get_first_target }, { "GetFirstTarget", scriptlib::duel_get_first_target },
{ "GetCurrentPhase", scriptlib::duel_get_current_phase }, { "GetCurrentPhase", scriptlib::duel_get_current_phase },
{ "SkipPhase", scriptlib::duel_skip_phase }, { "SkipPhase", scriptlib::duel_skip_phase },
......
...@@ -89,6 +89,9 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) { ...@@ -89,6 +89,9 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
int32 reset = lua_tointeger(L, 3); int32 reset = lua_tointeger(L, 3);
int32 flag = lua_tointeger(L, 4); int32 flag = lua_tointeger(L, 4);
int32 count = lua_tointeger(L, 5); int32 count = lua_tointeger(L, 5);
int32 lab = 0;
if(lua_gettop(L) >= 6)
lab = lua_tointeger(L, 6);
if(count == 0) if(count == 0)
count = 1; count = 1;
if(reset & (RESET_PHASE) && !(reset & (RESET_SELF_TURN | RESET_OPPO_TURN))) if(reset & (RESET_PHASE) && !(reset & (RESET_SELF_TURN | RESET_OPPO_TURN)))
...@@ -105,6 +108,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) { ...@@ -105,6 +108,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
peffect->s_range = 1; peffect->s_range = 1;
peffect->o_range = 0; peffect->o_range = 0;
peffect->reset_count = count; peffect->reset_count = count;
peffect->label = lab;
pduel->game_field->add_effect(peffect, playerid); pduel->game_field->add_effect(peffect, playerid);
interpreter::effect2value(L, peffect); interpreter::effect2value(L, peffect);
return 1; return 1;
...@@ -132,11 +136,46 @@ int32 scriptlib::duel_reset_flag_effect(lua_State *L) { ...@@ -132,11 +136,46 @@ int32 scriptlib::duel_reset_flag_effect(lua_State *L) {
for(; pr.first != pr.second; ) { for(; pr.first != pr.second; ) {
auto rm = pr.first++; auto rm = pr.first++;
effect* peffect = rm->second; effect* peffect = rm->second;
if(peffect->code == code) if(peffect->code == code && peffect->is_target_player(playerid))
pduel->game_field->remove_effect(peffect); pduel->game_field->remove_effect(peffect);
} }
return 0; return 0;
} }
int32 scriptlib::duel_set_flag_effect_label(lua_State *L) {
check_param_count(L, 3);
int32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
uint32 code = (lua_tounsigned(L, 2) & 0xfffffff) | 0x10000000;
int32 lab = lua_tointeger(L, 3);
duel* pduel = interpreter::get_duel_info(L);
effect_set eset;
pduel->game_field->filter_player_effect(playerid, code, &eset);
if(!eset.size())
lua_pushboolean(L, FALSE);
else {
eset[0]->label = lab;
lua_pushboolean(L, TRUE);
}
return 1;
}
int32 scriptlib::duel_get_flag_effect_label(lua_State *L) {
check_param_count(L, 2);
int32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
uint32 code = (lua_tounsigned(L, 2) & 0xfffffff) | 0x10000000;
duel* pduel = interpreter::get_duel_info(L);
effect_set eset;
pduel->game_field->filter_player_effect(playerid, code, &eset);
if(!eset.size()) {
lua_pushnil(L);
return 1;
}
for(int32 i = 0; i < eset.size(); ++i)
lua_pushinteger(L, eset[i]->label);
return eset.size();
}
int32 scriptlib::duel_destroy(lua_State *L) { int32 scriptlib::duel_destroy(lua_State *L) {
check_action_permission(L); check_action_permission(L);
check_param_count(L, 2); check_param_count(L, 2);
...@@ -1824,6 +1863,21 @@ int32 scriptlib::duel_get_chain_info(lua_State *L) { ...@@ -1824,6 +1863,21 @@ int32 scriptlib::duel_get_chain_info(lua_State *L) {
} }
return args; return args;
} }
int32 scriptlib::duel_get_chain_event(lua_State *L) {
check_param_count(L, 1);
uint32 count = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L);
chain* ch = pduel->game_field->get_chain(count);
if(!ch)
return 0;
interpreter::group2value(L, ch->evt.event_cards);
lua_pushinteger(L, ch->evt.event_player);
lua_pushinteger(L, ch->evt.event_value);
interpreter::effect2value(L, ch->evt.reason_effect);
lua_pushinteger(L, ch->evt.reason);
lua_pushinteger(L, ch->evt.reason_player);
return 6;
}
int32 scriptlib::duel_get_first_target(lua_State *L) { int32 scriptlib::duel_get_first_target(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
chain* ch = pduel->game_field->get_chain(0); chain* ch = pduel->game_field->get_chain(0);
......
...@@ -352,8 +352,10 @@ public: ...@@ -352,8 +352,10 @@ public:
static int32 duel_get_draw_count(lua_State *L); static int32 duel_get_draw_count(lua_State *L);
static int32 duel_register_effect(lua_State *L); static int32 duel_register_effect(lua_State *L);
static int32 duel_register_flag_effect(lua_State *L); static int32 duel_register_flag_effect(lua_State *L);
static int32 duel_reset_flag_effect(lua_State *L);
static int32 duel_get_flag_effect(lua_State *L); static int32 duel_get_flag_effect(lua_State *L);
static int32 duel_reset_flag_effect(lua_State *L);
static int32 duel_set_flag_effect_label(lua_State *L);
static int32 duel_get_flag_effect_label(lua_State *L);
static int32 duel_destroy(lua_State *L); static int32 duel_destroy(lua_State *L);
static int32 duel_remove(lua_State *L); static int32 duel_remove(lua_State *L);
static int32 duel_sendto_grave(lua_State *L); static int32 duel_sendto_grave(lua_State *L);
...@@ -439,6 +441,7 @@ public: ...@@ -439,6 +441,7 @@ public:
static int32 duel_check_location(lua_State *L); static int32 duel_check_location(lua_State *L);
static int32 duel_get_current_chain(lua_State *L); static int32 duel_get_current_chain(lua_State *L);
static int32 duel_get_chain_info(lua_State *L); static int32 duel_get_chain_info(lua_State *L);
static int32 duel_get_chain_event(lua_State *L);
static int32 duel_get_first_target(lua_State *L); static int32 duel_get_first_target(lua_State *L);
static int32 duel_get_current_phase(lua_State *L); static int32 duel_get_current_phase(lua_State *L);
static int32 duel_skip_phase(lua_State *L); static int32 duel_skip_phase(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