Commit a4242e52 authored by salix5's avatar salix5

Duel.SendtoExtra()

Duel.SendtoExtra(Card|Group targets, int player|nil, int reason)
parent 37eabe3e
...@@ -322,6 +322,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -322,6 +322,7 @@ static const struct luaL_Reg duellib[] = {
{ "SendtoGrave", scriptlib::duel_sendto_grave }, { "SendtoGrave", scriptlib::duel_sendto_grave },
{ "SendtoHand", scriptlib::duel_sendto_hand }, { "SendtoHand", scriptlib::duel_sendto_hand },
{ "SendtoDeck", scriptlib::duel_sendto_deck }, { "SendtoDeck", scriptlib::duel_sendto_deck },
{ "SendtoExtra", scriptlib::duel_sendto_extra },
{ "GetOperatedGroup", scriptlib::duel_get_operated_group }, { "GetOperatedGroup", scriptlib::duel_get_operated_group },
{ "Summon", scriptlib::duel_summon }, { "Summon", scriptlib::duel_summon },
{ "SpecialSummonRule", scriptlib::duel_special_summon_rule }, { "SpecialSummonRule", scriptlib::duel_special_summon_rule },
......
...@@ -453,6 +453,31 @@ int32 scriptlib::duel_sendto_deck(lua_State *L) { ...@@ -453,6 +453,31 @@ int32 scriptlib::duel_sendto_deck(lua_State *L) {
pduel->game_field->core.subunits.begin()->type = PROCESSOR_SENDTO_S; pduel->game_field->core.subunits.begin()->type = PROCESSOR_SENDTO_S;
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_sendto_extra(lua_State *L) {
check_action_permission(L);
check_param_count(L, 3);
card* pcard = 0;
group* pgroup = 0;
duel* pduel = 0;
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
pcard = *(card**) lua_touserdata(L, 1);
pduel = pcard->pduel;
} else if(check_param(L, PARAM_TYPE_GROUP, 1, TRUE)) {
pgroup = *(group**) lua_touserdata(L, 1);
pduel = pgroup->pduel;
} else
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 playerid = lua_tointeger(L, 2);
if(lua_isnil(L, 2) || (playerid != 0 && playerid != 1))
playerid = PLAYER_NONE;
uint32 reason = lua_tointeger(L, 3);
if(pcard)
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, playerid, LOCATION_EXTRA, 0, POS_FACEUP);
else
pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, playerid, LOCATION_EXTRA, 0, POS_FACEUP);
pduel->game_field->core.subunits.begin()->type = PROCESSOR_SENDTO_S;
return lua_yield(L, 0);
}
int32 scriptlib::duel_get_operated_group(lua_State *L) { int32 scriptlib::duel_get_operated_group(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(pduel->game_field->core.operated_set); group* pgroup = pduel->new_group(pduel->game_field->core.operated_set);
......
...@@ -230,8 +230,9 @@ void field::release(card* target, effect* reason_effect, uint32 reason, uint32 r ...@@ -230,8 +230,9 @@ void field::release(card* target, effect* reason_effect, uint32 reason, uint32 r
tset.insert(target); tset.insert(target);
release(&tset, reason_effect, reason, reason_player); release(&tset, reason_effect, reason, reason_player);
} }
// send to locations other than LOCATION_ONFIELD
void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position) { void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position) {
if(!(destination & (LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE + LOCATION_REMOVED))) if(destination & LOCATION_ONFIELD)
return; return;
uint32 p, pos; uint32 p, pos;
for(auto cit = targets->begin(); cit != targets->end(); ++cit) { for(auto cit = targets->begin(); cit != targets->end(); ++cit) {
...@@ -3022,7 +3023,8 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3022,7 +3023,8 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
|| (dest == LOCATION_HAND && !pcard->is_capable_send_to_hand(core.reason_player)) || (dest == LOCATION_HAND && !pcard->is_capable_send_to_hand(core.reason_player))
|| (dest == LOCATION_DECK && !pcard->is_capable_send_to_deck(core.reason_player)) || (dest == LOCATION_DECK && !pcard->is_capable_send_to_deck(core.reason_player))
|| (dest == LOCATION_REMOVED && !pcard->is_removeable(core.reason_player)) || (dest == LOCATION_REMOVED && !pcard->is_removeable(core.reason_player))
|| (dest == LOCATION_GRAVE && !pcard->is_capable_send_to_grave(core.reason_player)))) { || (dest == LOCATION_GRAVE && !pcard->is_capable_send_to_grave(core.reason_player))
|| (dest == LOCATION_EXTRA && !pcard->is_capable_send_to_extra(core.reason_player)))) {
pcard->current.reason = pcard->temp.reason; pcard->current.reason = pcard->temp.reason;
pcard->current.reason_player = pcard->temp.reason_player; pcard->current.reason_player = pcard->temp.reason_player;
pcard->current.reason_effect = pcard->temp.reason_effect; pcard->current.reason_effect = pcard->temp.reason_effect;
......
...@@ -328,6 +328,7 @@ public: ...@@ -328,6 +328,7 @@ public:
static int32 duel_special_summon_complete(lua_State *L); static int32 duel_special_summon_complete(lua_State *L);
static int32 duel_sendto_hand(lua_State *L); static int32 duel_sendto_hand(lua_State *L);
static int32 duel_sendto_deck(lua_State *L); static int32 duel_sendto_deck(lua_State *L);
static int32 duel_sendto_extra(lua_State *L);
static int32 duel_get_operated_group(lua_State *L); static int32 duel_get_operated_group(lua_State *L);
static int32 duel_remove_counter(lua_State *L); static int32 duel_remove_counter(lua_State *L);
static int32 duel_is_can_remove_counter(lua_State *L); static int32 duel_is_can_remove_counter(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