Commit 29f43b23 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro-core

parents 9caab1f4 493ad7a0
......@@ -1894,6 +1894,7 @@ void field::get_ritual_material(uint8 playerid, effect* peffect, card_set* mater
for(auto& pcard : player[1 - playerid].list_mzone) {
if(pcard && pcard->is_affect_by_effect(peffect)
&& (pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE) || is_player_affected_by_effect(playerid, EFFECT_SEA_PULSE))
&& pcard->is_position(POS_FACEUP)
&& pcard->is_releasable_by_nonsummon(playerid) && pcard->is_releasable_by_effect(playerid, peffect)
&& (no_level || pcard->get_level() > 0 || pcard->is_affected_by_effect(EFFECT_MINIATURE_GARDEN_GIRL)))
material->insert(pcard);
......
......@@ -252,6 +252,7 @@ struct processor {
card_set operated_set;
card_set discarded_set;
card_set destroy_canceled;
card_set indestructable_count_set;
card_set delayed_enable_set;
card_set set_group_pre_set;
card_set set_group_set;
......
......@@ -403,10 +403,13 @@ int32 scriptlib::duel_destroy(lua_State *L) {
uint32 dest = LOCATION_GRAVE;
if(lua_gettop(L) >= 3)
dest = (uint32)lua_tointeger(L, 3);
uint32 reason_player = pduel->game_field->core.reason_player;
if (lua_gettop(L) >= 4)
reason_player = (uint32)lua_tointeger(L, 4);
if(pcard)
pduel->game_field->destroy(pcard, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, PLAYER_NONE, dest, 0);
pduel->game_field->destroy(pcard, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, dest, 0);
else
pduel->game_field->destroy(&(pgroup->container), pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, PLAYER_NONE, dest, 0);
pduel->game_field->destroy(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, dest, 0);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
......@@ -429,10 +432,13 @@ int32 scriptlib::duel_remove(lua_State *L) {
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 pos = (uint32)lua_tointeger(L, 2);
uint32 reason = (uint32)lua_tointeger(L, 3);
uint32 reason_player = pduel->game_field->core.reason_player;
if (lua_gettop(L) >= 4)
reason_player = (uint32)lua_tointeger(L, 4);
if(pcard)
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, pos);
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, pos);
else
pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, pos);
pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, pos);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
......@@ -454,10 +460,13 @@ int32 scriptlib::duel_sendto_grave(lua_State *L) {
} else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 reason = (uint32)lua_tointeger(L, 2);
uint32 reason_player = pduel->game_field->core.reason_player;
if (lua_gettop(L) >= 3)
reason_player = (uint32)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, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
else
pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
......@@ -844,10 +853,13 @@ int32 scriptlib::duel_sendto_deck(lua_State *L) {
playerid = PLAYER_NONE;
uint32 sequence = (uint32)lua_tointeger(L, 3);
uint32 reason = (uint32)lua_tointeger(L, 4);
uint32 reason_player = pduel->game_field->core.reason_player;
if (lua_gettop(L) >= 5)
reason_player = (uint32)lua_tointeger(L, 5);
if(pcard)
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP);
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, 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_DECK, sequence, POS_FACEUP);
pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
......@@ -1001,10 +1013,13 @@ int32 scriptlib::duel_release(lua_State *L) {
} else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 reason = (uint32)lua_tointeger(L, 2);
uint32 reason_player = pduel->game_field->core.reason_player;
if (lua_gettop(L) >= 3)
reason_player = (uint32)lua_tointeger(L, 3);
if(pcard)
pduel->game_field->release(pcard, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player);
pduel->game_field->release(pcard, pduel->game_field->core.reason_effect, reason, reason_player);
else
pduel->game_field->release(&(pgroup->container), pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player);
pduel->game_field->release(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
......
......@@ -3434,6 +3434,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
continue;
}
}
// monsters with EFFECT_INDESTRUCTABLE_COUNT cannot apply EFFECT_DESTROY_REPLACE
eset.clear();
pcard->filter_effect(EFFECT_INDESTRUCTABLE_COUNT, &eset);
if (eset.size()) {
......@@ -3455,8 +3456,8 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
pduel->lua->add_param(pcard->current.reason_player, PARAM_TYPE_INT);
int32 ct;
if(ct = eset[i]->get_value(3)) {
auto it = pcard->indestructable_effects.emplace(eset[i]->id, 0);
if(++it.first->second <= ct) {
auto ret = pcard->indestructable_effects.emplace(eset[i]->id, 0);
if(++ret.first->second <= ct) {
indestructable_effect_set.insert(eset[i]);
is_destructable = false;
}
......@@ -3464,7 +3465,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
}
}
if(!is_destructable) {
indestructable_set.insert(pcard);
core.indestructable_count_set.insert(pcard);
continue;
}
}
......@@ -3497,6 +3498,12 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
pcard->set_status(STATUS_DESTROY_CONFIRMED, FALSE);
targets->container.erase(pcard);
}
for (auto& pcard : core.indestructable_count_set) {
pcard->current.reason = pcard->temp.reason;
pcard->current.reason_effect = pcard->temp.reason_effect;
pcard->current.reason_player = pcard->temp.reason_player;
targets->container.erase(pcard);
}
for (auto& rep : extra) {
if(targets->container.count(rep) == 0) {
rep->temp.reason = rep->current.reason;
......@@ -3535,6 +3542,9 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
for (auto& pcard : core.destroy_canceled)
pcard->set_status(STATUS_DESTROY_CONFIRMED, FALSE);
core.destroy_canceled.clear();
for (auto& pcard : core.indestructable_count_set)
pcard->set_status(STATUS_DESTROY_CONFIRMED, FALSE);
core.indestructable_count_set.clear();
return FALSE;
}
case 3: {
......
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