Commit a2ce02ca authored by fallenstardust's avatar fallenstardust

sync ocgcore

parent c10d687d
......@@ -2079,9 +2079,9 @@ int32 card::leave_field_redirect(uint32 reason) {
return LOCATION_REMOVED;
// the ruling for the priority of the following redirects can't be confirmed for now
if(redirects & LOCATION_DECK) {
if(redirects & LOCATION_DECKBOT)
if((redirects & LOCATION_DECKBOT) == LOCATION_DECKBOT)
return LOCATION_DECKBOT;
if(redirects & LOCATION_DECKSHF)
if((redirects & LOCATION_DECKSHF) == LOCATION_DECKSHF)
return LOCATION_DECKSHF;
return LOCATION_DECK;
}
......
......@@ -1487,6 +1487,14 @@ int32 scriptlib::duel_disable_shuffle_check(lua_State *L) {
pduel->game_field->core.shuffle_check_disabled = disable;
return 0;
}
int32 scriptlib::duel_disable_self_destroy_check(lua_State* L) {
duel* pduel = interpreter::get_duel_info(L);
uint8 disable = TRUE;
if(lua_gettop(L) > 0)
disable = lua_toboolean(L, 1);
pduel->game_field->core.selfdes_disabled = disable;
return 0;
}
int32 scriptlib::duel_shuffle_deck(lua_State *L) {
check_param_count(L, 1);
uint32 playerid = (uint32)lua_tointeger(L, 1);
......@@ -3598,6 +3606,56 @@ int32 scriptlib::duel_select_disable_field(lua_State * L) {
return 1;
});
}
int32 scriptlib::duel_select_field(lua_State* L) {
check_action_permission(L);
check_param_count(L, 5);
int32 playerid = (int32)lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
uint32 count = (uint32)lua_tointeger(L, 2);
uint32 location1 = (uint32)lua_tointeger(L, 3);
uint32 location2 = (uint32)lua_tointeger(L, 4);
uint32 filter = (uint32)lua_tointeger(L, 5);
duel* pduel = interpreter::get_duel_info(L);
uint32 flag = 0xffffffff;
if(location1 & LOCATION_MZONE) {
flag &= 0xffffffe0;
}
if(location1 & LOCATION_SZONE) {
flag &= pduel->game_field->core.duel_rule == 3 ? 0xffff00ff : 0xffffc0ff;
}
if(location2 & LOCATION_MZONE) {
flag &= 0xffe0ffff;
}
if(location2 & LOCATION_SZONE) {
flag &= pduel->game_field->core.duel_rule == 3 ? 0x00ffffff : 0xc0ffffff;
}
if((location1 & LOCATION_MZONE) && (location2 & LOCATION_MZONE) && pduel->game_field->core.duel_rule >= 4) {
flag &= 0xffffff9f;
}
flag |= filter | 0x00800080;
pduel->game_field->add_process(PROCESSOR_SELECT_DISFIELD, 0, 0, 0, playerid, flag, count);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State* L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
int32 playerid = (int32)lua_tointeger(L, 1);
uint32 count = (uint32)lua_tointeger(L, 2);
int32 dfflag = 0;
uint8 pa = 0;
for(uint32 i = 0; i < count; ++i) {
uint8 p = pduel->game_field->returns.bvalue[pa];
uint8 l = pduel->game_field->returns.bvalue[pa + 1];
uint8 s = pduel->game_field->returns.bvalue[pa + 2];
dfflag |= 0x1u << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8));
pa += 3;
}
if(dfflag & (0x1 << 5))
dfflag |= 0x1 << (16 + 6);
if(dfflag & (0x1 << 6))
dfflag |= 0x1 << (16 + 5);
lua_pushinteger(L, dfflag);
return 1;
});
}
int32 scriptlib::duel_announce_race(lua_State * L) {
check_action_permission(L);
check_param_count(L, 3);
......@@ -4505,6 +4563,7 @@ static const struct luaL_Reg duellib[] = {
{ "DiscardDeck", scriptlib::duel_discard_deck },
{ "DiscardHand", scriptlib::duel_discard_hand },
{ "DisableShuffleCheck", scriptlib::duel_disable_shuffle_check },
{ "DisableSelfDestroyCheck", scriptlib::duel_disable_self_destroy_check },
{ "ShuffleDeck", scriptlib::duel_shuffle_deck },
{ "ShuffleExtra", scriptlib::duel_shuffle_extra },
{ "ShuffleHand", scriptlib::duel_shuffle_hand },
......@@ -4605,6 +4664,7 @@ static const struct luaL_Reg duellib[] = {
{ "SelectOption", scriptlib::duel_select_option },
{ "SelectSequence", scriptlib::duel_select_sequence },
{ "SelectPosition", scriptlib::duel_select_position },
{ "SelectField", scriptlib::duel_select_field },
{ "SelectDisableField", scriptlib::duel_select_disable_field },
{ "AnnounceRace", scriptlib::duel_announce_race },
{ "AnnounceAttribute", scriptlib::duel_announce_attribute },
......
......@@ -861,12 +861,12 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player
change = false;
if(!pcard->is_affect_by_effect(reason_effect))
change = false;
if(core.duel_rule <= 4 && (pcard->get_type() & TYPE_TRAPMONSTER) && get_useable_count(pcard, playerid, LOCATION_SZONE, playerid, LOCATION_REASON_CONTROL) <= 0)
if(core.duel_rule <= 4 && (pcard->get_type() & TYPE_TRAPMONSTER) && get_useable_count(pcard, playerid, LOCATION_SZONE, reason_player, LOCATION_REASON_CONTROL) <= 0)
change = false;
if(!change)
targets->container.erase(pcard);
}
int32 fcount = get_useable_count(NULL, playerid, LOCATION_MZONE, playerid, LOCATION_REASON_CONTROL, zone);
int32 fcount = get_useable_count(NULL, playerid, LOCATION_MZONE, reason_player, LOCATION_REASON_CONTROL, zone);
if(fcount <= 0) {
destroy_set->swap(targets->container);
core.units.begin()->step = 5;
......@@ -910,7 +910,7 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player
return FALSE;
}
card* pcard = *targets->it;
move_to_field(pcard, playerid, playerid, LOCATION_MZONE, pcard->current.position, FALSE, 0, FALSE, zone);
move_to_field(pcard, (reason_player != PLAYER_NONE) ? reason_player : playerid, playerid, LOCATION_MZONE, pcard->current.position, FALSE, 0, FALSE, zone);
return FALSE;
}
case 4: {
......
......@@ -433,6 +433,7 @@ public:
static int32 duel_discard_deck(lua_State *L);
static int32 duel_discard_hand(lua_State *L);
static int32 duel_disable_shuffle_check(lua_State *L);
static int32 duel_disable_self_destroy_check(lua_State *L);
static int32 duel_shuffle_deck(lua_State *L);
static int32 duel_shuffle_extra(lua_State *L);
static int32 duel_shuffle_hand(lua_State *L);
......@@ -536,6 +537,7 @@ public:
static int32 duel_select_sequence(lua_State *L);
static int32 duel_select_position(lua_State *L);
static int32 duel_select_disable_field(lua_State *L);
static int32 duel_select_field(lua_State *L);
static int32 duel_announce_race(lua_State *L);
static int32 duel_announce_attribute(lua_State *L);
static int32 duel_announce_level(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