Commit f20b6ddf authored by mercury233's avatar mercury233
parents 4232babf abf1e6b1
......@@ -633,12 +633,31 @@ int32 field::is_location_useable(uint32 playerid, uint32 location, uint32 sequen
}
return TRUE;
}
/**
* Return usable count in zone of playerid's MZONE or SZONE(0~4) when uplayer moves pcard to playerid's field (can be negative).
* for LOCATION_MZONE, "usable" means not used, not disabled, satisfying EFFECT_MUST_USE_MZONE, satisfying EFFECT_MAX_MZONE
* for LOCATION_SZONE, "usable" means not used, not disabled, satisfying EFFECT_MAX_SZONE
*
* @param pcard the card about to move
* @param playerid the target player
* @param location LOCATION_MZONE or LOCATION_SZONE
* @param uplayer the request player, PLAYER_NONE means ignoring EFFECT_MUST_USE_MZONE of uplayer, ignoring EFFECT_MAX_MZONE, EFFECT_MAX_SZONE of playerid
* @param reason location reason
* @param zone specified zones, 0xff by default
* @param list storing unavailable or unspecified zones
*
* @return usable count in zone of playerid's MZONE or SZONE(0~4) (can be negative)
*/
int32 field::get_useable_count(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone, uint32* list) {
if(location == LOCATION_MZONE && pcard && pcard->current.location == LOCATION_EXTRA)
return get_useable_count_fromex(pcard, playerid, uplayer, zone, list);
else
return get_useable_count_other(pcard, playerid, location, uplayer, reason, zone, list);
}
/**
* @param pcard the card about to move from Extra Deck (NULL means any card in Extra Deck)
* @return usable count in zone of playerid's MZONE for pcard
*/
int32 field::get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone, uint32* list) {
bool use_temp_card = false;
if(!pcard) {
......@@ -655,12 +674,20 @@ int32 field::get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer
pcard->current.location = 0;
return useable_count;
}
/**
* @return the number of available grids in zone of playerid's MZONE for pcard sp_summoned by playerid
* for LOCATION_MZONE, "available" means not used, not disabled, satisfying EFFECT_MUST_USE_MZONE
*/
int32 field::get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone, uint32* list) {
if(pcard->current.location == LOCATION_EXTRA)
return get_spsummonable_count_fromex(pcard, playerid, playerid, zone, list);
else
return get_tofield_count(pcard, playerid, LOCATION_MZONE, playerid, LOCATION_REASON_TOFIELD, zone, list);
}
/**
* @param pcard the card about to move from Extra Deck (NULL means any card in Extra Deck)
* @return the number of available grids in zone of playerid's MZONE for pcard
*/
int32 field::get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone, uint32* list) {
bool use_temp_card = false;
if(!pcard) {
......@@ -677,7 +704,9 @@ int32 field::get_spsummonable_count_fromex(card* pcard, uint8 playerid, uint8 up
pcard->current.location = 0;
return spsummonable_count;
}
// return: usable count of main mzone or szone(0~4) of playerid requested by uplayer (may be negative)
/**
* @return usable count in zone of Main MZONE or SZONE(0~4)
*/
int32 field::get_useable_count_other(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone, uint32* list) {
int32 count = get_tofield_count(pcard, playerid, location, uplayer, reason, zone, list);
int32 limit;
......@@ -689,10 +718,11 @@ int32 field::get_useable_count_other(card* pcard, uint8 playerid, uint8 location
count = limit;
return count;
}
// uplayer: request player, PLAYER_NONE means ignoring EFFECT_MUST_USE_MZONE, EFFECT_MAX_MZONE, EFFECT_MAX_SZONE
// list: store unavailable flag in list
// for LOCATION_MZONE, return the available count of zone in main mzone (not used, not disabled, satisfying EFFECT_MUST_USE_MZONE)
// for LOCATION_SZONE, return the available count of zone in szone(0~4) (not used, not disabled)
/**
* @return the number of available grids in zone of Main MZONE or SZONE(0~4)
* for LOCATION_MZONE, "available" means not used, not disabled, satisfying EFFECT_MUST_USE_MZONE
* for LOCATION_SZONE, "available" means not used, not disabled
*/
int32 field::get_tofield_count(card* pcard, uint8 playerid, uint8 location, uint32 uplayer, uint32 reason, uint32 zone, uint32* list) {
if (location != LOCATION_MZONE && location != LOCATION_SZONE)
return 0;
......@@ -744,6 +774,13 @@ int32 field::get_spsummonable_count_fromex_rule4(card* pcard, uint8 playerid, ui
count++;
return count;
}
/**
* @param playerid the target player
* @param uplayer the request player, PLAYER_NONE means ignoring EFFECT_MAX_MZONE
* @param reason location reason
*
* @return the remaining count in playerid's MZONE after applying EFFECT_MAX_MZONE (can be negative).
*/
int32 field::get_mzone_limit(uint8 playerid, uint8 uplayer, uint32 reason) {
uint32 used_flag = player[playerid].used_location;
used_flag = used_flag & 0x1f;
......@@ -770,6 +807,13 @@ int32 field::get_mzone_limit(uint8 playerid, uint8 uplayer, uint32 reason) {
int32 limit = max - used_count;
return limit;
}
/**
* @param playerid the target player
* @param uplayer the request player, PLAYER_NONE means ignoring EFFECT_MAX_SZONE
* @param reason location reason
*
* @return the remaining count in playerid's SZONE(0~4) after applying EFFECT_MAX_SZONE.
*/
int32 field::get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason) {
uint32 used_flag = player[playerid].used_location;
used_flag = (used_flag >> 8) & 0x1f;
......@@ -810,6 +854,13 @@ uint32 field::get_rule_zone_fromex(int32 playerid, card* pcard) {
return 0x1f;
}
}
/**
* @param playerid the target player
* @param uplayer the request player, PLAYER_NONE means ignoring EFFECT_MUST_USE_MZONE of uplayer
* @param reason location reason
* @param pcard the card about to move
* @param flag storing the zones in MZONE blocked by EFFECT_MUST_USE_MZONE
*/
void field::filter_must_use_mzone(uint8 playerid, uint8 uplayer, uint32 reason, card* pcard, uint32* flag) {
effect_set eset;
if(uplayer < 2)
......
......@@ -282,7 +282,7 @@ struct processor {
uint8 extra_summon[2];
int32 spe_effect[2];
int32 duel_options;
int32 duel_rule;
int32 duel_rule; //current rule: 5, Master Rule 2020
uint32 copy_reset;
uint8 copy_reset_count;
uint32 last_control_changed_id;
......
......@@ -13,15 +13,18 @@ group::group(duel* pd) {
ref_handle = 0;
pduel = pd;
is_readonly = FALSE;
it = container.begin();
}
group::group(duel* pd, card* pcard) {
container.insert(pcard);
ref_handle = 0;
pduel = pd;
is_readonly = FALSE;
it = container.begin();
}
group::group(duel* pd, const card_set& cset): container(cset) {
ref_handle = 0;
pduel = pd;
is_readonly = FALSE;
it = container.begin();
}
......@@ -1844,6 +1844,7 @@ int32 scriptlib::duel_check_summon_count(lua_State *L) {
lua_pushboolean(L, 0);
return 1;
}
// Return usable count in zone of playerid's Main MZONE or SZONE(0~4) when uplayer moves a card to playerid's field (can be negative).
int32 scriptlib::duel_get_location_count(lua_State *L) {
check_param_count(L, 2);
uint32 playerid = (uint32)lua_tointeger(L, 1);
......@@ -1865,6 +1866,7 @@ int32 scriptlib::duel_get_location_count(lua_State *L) {
lua_pushinteger(L, list);
return 2;
}
// Return usable count in zone of playerid's Main MZONE after mcard or mgroup leaves the field.
int32 scriptlib::duel_get_mzone_count(lua_State *L) {
check_param_count(L, 1);
uint32 playerid = (uint32)lua_tointeger(L, 1);
......@@ -1919,6 +1921,8 @@ int32 scriptlib::duel_get_mzone_count(lua_State *L) {
}
return 2;
}
// Condition: uplayer moves scard or any card with type from Extra Deck to playerid's field
// Return usable count in zone of playerid's MZONE after mcard or mgroup leaves the field
int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
check_param_count(L, 1);
uint32 playerid = (uint32)lua_tointeger(L, 1);
......@@ -1992,6 +1996,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
}
return 2;
}
// Return the number of available grids in playerid's Main MZONE and Extra MZONE
int32 scriptlib::duel_get_usable_mzone_count(lua_State *L) {
check_param_count(L, 1);
uint32 playerid = (uint32)lua_tointeger(L, 1);
......
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