Commit ee16ca74 authored by DailyShana's avatar DailyShana

add Duel.SwapSequence

parent 0f75b20e
...@@ -360,6 +360,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -360,6 +360,7 @@ static const struct luaL_Reg duellib[] = {
{ "MoveToField", scriptlib::duel_move_to_field }, { "MoveToField", scriptlib::duel_move_to_field },
{ "ReturnToField", scriptlib::duel_return_to_field }, { "ReturnToField", scriptlib::duel_return_to_field },
{ "MoveSequence", scriptlib::duel_move_sequence }, { "MoveSequence", scriptlib::duel_move_sequence },
{ "SwapSequence", scriptlib::duel_swap_sequence },
{ "SetChainLimit", scriptlib::duel_set_chain_limit }, { "SetChainLimit", scriptlib::duel_set_chain_limit },
{ "SetChainLimitTillChainEnd", scriptlib::duel_set_chain_limit_p }, { "SetChainLimitTillChainEnd", scriptlib::duel_set_chain_limit_p },
{ "GetChainMaterial", scriptlib::duel_get_chain_material }, { "GetChainMaterial", scriptlib::duel_get_chain_material },
......
...@@ -660,6 +660,32 @@ int32 scriptlib::duel_move_sequence(lua_State *L) { ...@@ -660,6 +660,32 @@ int32 scriptlib::duel_move_sequence(lua_State *L) {
pduel->game_field->move_card(pcard->current.controler, pcard, pcard->current.location, seq); pduel->game_field->move_card(pcard->current.controler, pcard, pcard->current.location, seq);
return 0; return 0;
} }
int32 scriptlib::duel_swap_sequence(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_CARD, 2);
card* pcard1 = *(card**) lua_touserdata(L, 1);
card* pcard2 = *(card**) lua_touserdata(L, 2);
uint8 player = pcard1->current.controler;
uint8 location = pcard1->current.location;
duel* pduel = pcard1->pduel;
if(pcard2->current.controler == player
&& location == LOCATION_MZONE && pcard2->current.location == location
&& pcard1->is_affect_by_effect(pduel->game_field->core.reason_effect)
&& pcard2->is_affect_by_effect(pduel->game_field->core.reason_effect)) {
uint8 s1 = pcard1->current.sequence, s2 = pcard2->current.sequence;
pduel->game_field->remove_card(pcard1);
pduel->game_field->remove_card(pcard2);
pduel->game_field->add_card(player, pcard1, location, s2);
pduel->game_field->add_card(player, pcard2, location, s1);
pduel->write_buffer8(MSG_SWAP);
pduel->write_buffer32(pcard1->data.code);
pduel->write_buffer32(pcard2->get_info_location());
pduel->write_buffer32(pcard2->data.code);
pduel->write_buffer32(pcard1->get_info_location());
}
return 0;
}
int32 scriptlib::duel_set_chain_limit(lua_State *L) { int32 scriptlib::duel_set_chain_limit(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_FUNCTION, 1); check_param(L, PARAM_TYPE_FUNCTION, 1);
......
...@@ -356,6 +356,7 @@ public: ...@@ -356,6 +356,7 @@ public:
static int32 duel_move_to_field(lua_State *L); static int32 duel_move_to_field(lua_State *L);
static int32 duel_return_to_field(lua_State *L); static int32 duel_return_to_field(lua_State *L);
static int32 duel_move_sequence(lua_State *L); static int32 duel_move_sequence(lua_State *L);
static int32 duel_swap_sequence(lua_State *L);
static int32 duel_set_chain_limit(lua_State *L); static int32 duel_set_chain_limit(lua_State *L);
static int32 duel_set_chain_limit_p(lua_State *L); static int32 duel_set_chain_limit_p(lua_State *L);
static int32 duel_get_chain_material(lua_State *L); static int32 duel_get_chain_material(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