Commit 22f62064 authored by mercury233's avatar mercury233
parents 81aa6e14 55c542ec
...@@ -2166,11 +2166,11 @@ int32 card::leave_field_redirect(uint32 reason) { ...@@ -2166,11 +2166,11 @@ int32 card::leave_field_redirect(uint32 reason) {
filter_effect(EFFECT_LEAVE_FIELD_REDIRECT, &es); filter_effect(EFFECT_LEAVE_FIELD_REDIRECT, &es);
for(int32 i = 0; i < es.size(); ++i) { for(int32 i = 0; i < es.size(); ++i) {
redirect = es[i]->get_value(this, 0); redirect = es[i]->get_value(this, 0);
if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(current.controler, this)) if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(es[i]->get_handler_player(), this))
return redirect; return redirect;
else if((redirect & LOCATION_DECK) && !is_affected_by_effect(EFFECT_CANNOT_TO_DECK) && pduel->game_field->is_player_can_send_to_deck(current.controler, this)) else if((redirect & LOCATION_DECK) && !is_affected_by_effect(EFFECT_CANNOT_TO_DECK) && pduel->game_field->is_player_can_send_to_deck(es[i]->get_handler_player(), this))
return redirect; return redirect;
else if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(current.controler, this)) else if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(es[i]->get_handler_player(), this))
return redirect; return redirect;
} }
return 0; return 0;
...@@ -2192,13 +2192,13 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) { ...@@ -2192,13 +2192,13 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
return 0; return 0;
for(int32 i = 0; i < es.size(); ++i) { for(int32 i = 0; i < es.size(); ++i) {
redirect = es[i]->get_value(this, 0); redirect = es[i]->get_value(this, 0);
if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(current.controler, this)) if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(es[i]->get_handler_player(), this))
return redirect; return redirect;
if((redirect & LOCATION_DECK) && !is_affected_by_effect(EFFECT_CANNOT_TO_DECK) && pduel->game_field->is_player_can_send_to_deck(current.controler, this)) if((redirect & LOCATION_DECK) && !is_affected_by_effect(EFFECT_CANNOT_TO_DECK) && pduel->game_field->is_player_can_send_to_deck(es[i]->get_handler_player(), this))
return redirect; return redirect;
if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(current.controler, this)) if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(es[i]->get_handler_player(), this))
return redirect; return redirect;
if((redirect & LOCATION_GRAVE) && !is_affected_by_effect(EFFECT_CANNOT_TO_GRAVE) && pduel->game_field->is_player_can_send_to_grave(current.controler, this)) if((redirect & LOCATION_GRAVE) && !is_affected_by_effect(EFFECT_CANNOT_TO_GRAVE) && pduel->game_field->is_player_can_send_to_grave(es[i]->get_handler_player(), this))
return redirect; return redirect;
} }
return 0; return 0;
...@@ -3406,10 +3406,12 @@ int32 card::is_capable_send_to_grave(uint8 playerid) { ...@@ -3406,10 +3406,12 @@ int32 card::is_capable_send_to_grave(uint8 playerid) {
int32 card::is_capable_send_to_hand(uint8 playerid) { int32 card::is_capable_send_to_hand(uint8 playerid) {
if(is_status(STATUS_LEAVE_CONFIRMED)) if(is_status(STATUS_LEAVE_CONFIRMED))
return FALSE; return FALSE;
if((current.location == LOCATION_EXTRA) && (data.type & (TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ + TYPE_LINK))) if((current.location == LOCATION_EXTRA) && is_extra_deck_monster())
return FALSE; return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_TO_HAND)) if(is_affected_by_effect(EFFECT_CANNOT_TO_HAND))
return FALSE; return FALSE;
if(is_extra_deck_monster() && !is_capable_send_to_deck(playerid))
return FALSE;
if(!pduel->game_field->is_player_can_send_to_hand(playerid, this)) if(!pduel->game_field->is_player_can_send_to_hand(playerid, this))
return FALSE; return FALSE;
return TRUE; return TRUE;
...@@ -3417,7 +3419,7 @@ int32 card::is_capable_send_to_hand(uint8 playerid) { ...@@ -3417,7 +3419,7 @@ int32 card::is_capable_send_to_hand(uint8 playerid) {
int32 card::is_capable_send_to_deck(uint8 playerid) { int32 card::is_capable_send_to_deck(uint8 playerid) {
if(is_status(STATUS_LEAVE_CONFIRMED)) if(is_status(STATUS_LEAVE_CONFIRMED))
return FALSE; return FALSE;
if((current.location == LOCATION_EXTRA) && (data.type & (TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ + TYPE_LINK))) if((current.location == LOCATION_EXTRA) && is_extra_deck_monster())
return FALSE; return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK)) if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK))
return FALSE; return FALSE;
...@@ -3426,7 +3428,7 @@ int32 card::is_capable_send_to_deck(uint8 playerid) { ...@@ -3426,7 +3428,7 @@ int32 card::is_capable_send_to_deck(uint8 playerid) {
return TRUE; return TRUE;
} }
int32 card::is_capable_send_to_extra(uint8 playerid) { int32 card::is_capable_send_to_extra(uint8 playerid) {
if(!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_PENDULUM | TYPE_LINK))) if(!is_extra_deck_monster() && !(data.type & TYPE_PENDULUM))
return FALSE; return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK)) if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK))
return FALSE; return FALSE;
...@@ -3464,7 +3466,7 @@ int32 card::is_capable_cost_to_grave(uint8 playerid) { ...@@ -3464,7 +3466,7 @@ int32 card::is_capable_cost_to_grave(uint8 playerid) {
int32 card::is_capable_cost_to_hand(uint8 playerid) { int32 card::is_capable_cost_to_hand(uint8 playerid) {
uint32 redirect = 0; uint32 redirect = 0;
uint32 dest = LOCATION_HAND; uint32 dest = LOCATION_HAND;
if(data.type & (TYPE_TOKEN | TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) if(data.type & (TYPE_TOKEN) || is_extra_deck_monster())
return FALSE; return FALSE;
if(current.location == LOCATION_HAND) if(current.location == LOCATION_HAND)
return FALSE; return FALSE;
...@@ -3487,7 +3489,7 @@ int32 card::is_capable_cost_to_hand(uint8 playerid) { ...@@ -3487,7 +3489,7 @@ int32 card::is_capable_cost_to_hand(uint8 playerid) {
int32 card::is_capable_cost_to_deck(uint8 playerid) { int32 card::is_capable_cost_to_deck(uint8 playerid) {
uint32 redirect = 0; uint32 redirect = 0;
uint32 dest = LOCATION_DECK; uint32 dest = LOCATION_DECK;
if(data.type & (TYPE_TOKEN | TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) if(data.type & (TYPE_TOKEN) || is_extra_deck_monster())
return FALSE; return FALSE;
if(current.location == LOCATION_DECK) if(current.location == LOCATION_DECK)
return FALSE; return FALSE;
...@@ -3510,7 +3512,7 @@ int32 card::is_capable_cost_to_deck(uint8 playerid) { ...@@ -3510,7 +3512,7 @@ int32 card::is_capable_cost_to_deck(uint8 playerid) {
int32 card::is_capable_cost_to_extra(uint8 playerid) { int32 card::is_capable_cost_to_extra(uint8 playerid) {
uint32 redirect = 0; uint32 redirect = 0;
uint32 dest = LOCATION_DECK; uint32 dest = LOCATION_DECK;
if(!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))) if(!is_extra_deck_monster())
return FALSE; return FALSE;
if(current.location == LOCATION_EXTRA) if(current.location == LOCATION_EXTRA)
return FALSE; return FALSE;
......
...@@ -188,6 +188,7 @@ public: ...@@ -188,6 +188,7 @@ public:
explicit card(duel* pd); explicit card(duel* pd);
~card(); ~card();
static bool card_operation_sort(card* c1, card* c2); static bool card_operation_sort(card* c1, card* c2);
const bool is_extra_deck_monster() { return !!(data.type & 0x4802040); }
uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE); uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE);
uint32 get_info_location(); uint32 get_info_location();
......
...@@ -162,7 +162,7 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence ...@@ -162,7 +162,7 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence
return; return;
if (!is_location_useable(playerid, location, sequence)) if (!is_location_useable(playerid, location, sequence))
return; return;
if((pcard->data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) && (location & (LOCATION_HAND | LOCATION_DECK))) { if(pcard->is_extra_deck_monster() && (location & (LOCATION_HAND | LOCATION_DECK))) {
location = LOCATION_EXTRA; location = LOCATION_EXTRA;
pcard->sendto_param.position = POS_FACEDOWN_DEFENSE; pcard->sendto_param.position = POS_FACEDOWN_DEFENSE;
} }
...@@ -300,7 +300,7 @@ void field::move_card(uint8 playerid, card* pcard, uint8 location, uint8 sequenc ...@@ -300,7 +300,7 @@ void field::move_card(uint8 playerid, card* pcard, uint8 location, uint8 sequenc
return; return;
uint8 preplayer = pcard->current.controler; uint8 preplayer = pcard->current.controler;
uint8 presequence = pcard->current.sequence; uint8 presequence = pcard->current.sequence;
if((pcard->data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) && (location & (LOCATION_HAND | LOCATION_DECK))) { if(pcard->is_extra_deck_monster() && (location & (LOCATION_HAND | LOCATION_DECK))) {
location = LOCATION_EXTRA; location = LOCATION_EXTRA;
pcard->sendto_param.position = POS_FACEDOWN_DEFENSE; pcard->sendto_param.position = POS_FACEDOWN_DEFENSE;
} }
...@@ -991,7 +991,7 @@ void field::swap_deck_and_grave(uint8 playerid) { ...@@ -991,7 +991,7 @@ void field::swap_deck_and_grave(uint8 playerid) {
player[playerid].list_grave.swap(player[playerid].list_main); player[playerid].list_grave.swap(player[playerid].list_main);
card_vector ex; card_vector ex;
for(auto clit = player[playerid].list_main.begin(); clit != player[playerid].list_main.end(); ) { for(auto clit = player[playerid].list_main.begin(); clit != player[playerid].list_main.end(); ) {
if((*clit)->data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) { if((*clit)->is_extra_deck_monster()) {
ex.push_back(*clit); ex.push_back(*clit);
clit = player[playerid].list_main.erase(clit); clit = player[playerid].list_main.erase(clit);
} else } else
...@@ -3272,6 +3272,8 @@ int32 field::is_player_can_send_to_hand(uint8 playerid, card * pcard) { ...@@ -3272,6 +3272,8 @@ int32 field::is_player_can_send_to_hand(uint8 playerid, card * pcard) {
if (pduel->lua->check_condition(eset[i]->target, 3)) if (pduel->lua->check_condition(eset[i]->target, 3))
return FALSE; return FALSE;
} }
if(pcard->is_extra_deck_monster() && !is_player_can_send_to_deck(playerid, pcard))
return FALSE;
return TRUE; return TRUE;
} }
int32 field::is_player_can_send_to_deck(uint8 playerid, card * pcard) { int32 field::is_player_can_send_to_deck(uint8 playerid, card * pcard) {
......
...@@ -564,6 +564,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -564,6 +564,7 @@ static const struct luaL_Reg duellib[] = {
{ "IsPlayerCanSendtoHand", scriptlib::duel_is_player_can_send_to_hand }, { "IsPlayerCanSendtoHand", scriptlib::duel_is_player_can_send_to_hand },
{ "IsPlayerCanSendtoGrave", scriptlib::duel_is_player_can_send_to_grave }, { "IsPlayerCanSendtoGrave", scriptlib::duel_is_player_can_send_to_grave },
{ "IsPlayerCanSendtoDeck", scriptlib::duel_is_player_can_send_to_deck }, { "IsPlayerCanSendtoDeck", scriptlib::duel_is_player_can_send_to_deck },
{ "IsPlayerCanAdditionalSummon", scriptlib::duel_is_player_can_additional_summon },
{ "IsChainNegatable", scriptlib::duel_is_chain_negatable }, { "IsChainNegatable", scriptlib::duel_is_chain_negatable },
{ "IsChainDisablable", scriptlib::duel_is_chain_disablable }, { "IsChainDisablable", scriptlib::duel_is_chain_disablable },
{ "CheckChainTarget", scriptlib::duel_check_chain_target }, { "CheckChainTarget", scriptlib::duel_check_chain_target },
......
...@@ -2112,7 +2112,7 @@ int32 scriptlib::card_is_able_to_deck_or_extra_as_cost(lua_State *L) { ...@@ -2112,7 +2112,7 @@ int32 scriptlib::card_is_able_to_deck_or_extra_as_cost(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 p = pcard->pduel->game_field->core.reason_player; uint32 p = pcard->pduel->game_field->core.reason_player;
int32 val = (pcard->data.type & 0x4802040) ? pcard->is_capable_cost_to_extra(p) : pcard->is_capable_cost_to_deck(p); int32 val = pcard->is_extra_deck_monster() ? pcard->is_capable_cost_to_extra(p) : pcard->is_capable_cost_to_deck(p);
if(val) if(val)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
......
...@@ -3601,6 +3601,20 @@ int32 scriptlib::duel_is_player_can_send_to_deck(lua_State * L) { ...@@ -3601,6 +3601,20 @@ int32 scriptlib::duel_is_player_can_send_to_deck(lua_State * L) {
lua_pushboolean(L, pduel->game_field->is_player_can_send_to_deck(playerid, pcard)); lua_pushboolean(L, pduel->game_field->is_player_can_send_to_deck(playerid, pcard));
return 1; return 1;
} }
int32 scriptlib::duel_is_player_can_additional_summon(lua_State * L) {
check_param_count(L, 1);
int32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1) {
lua_pushboolean(L, 0);
return 1;
}
duel* pduel = interpreter::get_duel_info(L);
if(pduel->game_field->core.extra_summon[playerid] == 0)
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::duel_is_chain_negatable(lua_State * L) { int32 scriptlib::duel_is_chain_negatable(lua_State * L) {
check_param_count(L, 1); check_param_count(L, 1);
int32 chaincount = lua_tointeger(L, 1); int32 chaincount = lua_tointeger(L, 1);
......
...@@ -30,9 +30,9 @@ int32 scriptlib::group_from_cards(lua_State *L) { ...@@ -30,9 +30,9 @@ int32 scriptlib::group_from_cards(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
for(int32 i = 0; i < lua_gettop(L); ++i) { for(int32 i = 0; i < lua_gettop(L); ++i) {
void* p = lua_touserdata(L, i + 1); if(!lua_isnil(L, i + 1)) {
if(p) { check_param(L, PARAM_TYPE_CARD, i + 1);
card* pcard = *(card**)p; card* pcard = *(card**) lua_touserdata(L, i + 1);
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
} }
......
...@@ -558,6 +558,7 @@ public: ...@@ -558,6 +558,7 @@ public:
static int32 duel_is_player_can_send_to_hand(lua_State *L); static int32 duel_is_player_can_send_to_hand(lua_State *L);
static int32 duel_is_player_can_send_to_grave(lua_State *L); static int32 duel_is_player_can_send_to_grave(lua_State *L);
static int32 duel_is_player_can_send_to_deck(lua_State *L); static int32 duel_is_player_can_send_to_deck(lua_State *L);
static int32 duel_is_player_can_additional_summon(lua_State *L);
static int32 duel_is_chain_negatable(lua_State *L); static int32 duel_is_chain_negatable(lua_State *L);
static int32 duel_is_chain_disablable(lua_State *L); static int32 duel_is_chain_disablable(lua_State *L);
static int32 duel_check_chain_target(lua_State *L); static int32 duel_check_chain_target(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