Commit 40016cac authored by fallenstardust's avatar fallenstardust

sync ocgcore

parent 797f58de
......@@ -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;
......
......@@ -195,10 +195,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]);
......@@ -221,10 +224,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]);
......@@ -246,10 +252,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]);
......@@ -633,10 +642,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]);
......@@ -790,10 +802,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]);
......
......@@ -3402,6 +3402,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()) {
......@@ -3423,8 +3424,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;
}
......@@ -3432,7 +3433,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;
}
}
......@@ -3465,6 +3466,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;
......@@ -3497,6 +3504,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