Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro-core
Commits
83936a3f
Commit
83936a3f
authored
Dec 23, 2024
by
wind2009
Committed by
GitHub
Dec 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Duel.GetSZoneCount() (#700)
* Add Duel.GetSZoneCount() * Add header * update used_location
parent
313962f7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
libduel.cpp
libduel.cpp
+56
-0
scriptlib.h
scriptlib.h
+1
-0
No files found.
libduel.cpp
View file @
83936a3f
...
...
@@ -2017,6 +2017,61 @@ int32_t scriptlib::duel_get_mzone_count(lua_State *L) {
}
return 2;
}
// Return usable count in zone of playerid's SZONE after card or group leaves the field.
int32_t scriptlib::duel_get_szone_count(lua_State *L) {
check_param_count(L, 1);
int32_t playerid = (int32_t)lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
duel* pduel = interpreter::get_duel_info(L);
bool swapped = false;
card* mcard = nullptr;
group* mgroup = nullptr;
uint32_t used_location[2] = { 0, 0 };
card_vector list_szone[2];
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) {
if(check_param(L, PARAM_TYPE_CARD, 2, TRUE)) {
mcard = *(card**)lua_touserdata(L, 2);
} else if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE)) {
mgroup = *(group**)lua_touserdata(L, 2);
} else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
for(int32_t p = 0; p < 2; p++) {
uint32_t digit = 0x100U;
for(auto& pcard : pduel->game_field->player[p].list_szone) {
if(pcard && pcard != mcard && !(mgroup && mgroup->container.find(pcard) != mgroup->container.end())) {
used_location[p] |= digit;
list_szone[p].push_back(pcard);
} else
list_szone[p].push_back(nullptr);
digit <<= 1;
}
used_location[p] |= pduel->game_field->player[p].used_location & 0xff;
std::swap(used_location[p], pduel->game_field->player[p].used_location);
pduel->game_field->player[p].list_szone.swap(list_szone[p]);
}
swapped = true;
}
uint32_t uplayer = pduel->game_field->core.reason_player;
uint32_t reason = LOCATION_REASON_TOFIELD;
uint32_t zone = 0xff;
if(lua_gettop(L) >= 3)
uplayer = (uint32_t)lua_tointeger(L, 3);
if(lua_gettop(L) >= 4)
reason = (uint32_t)lua_tointeger(L, 4);
if(lua_gettop(L) >= 5)
zone = (uint32_t)lua_tointeger(L, 5);
uint32_t list = 0;
lua_pushinteger(L, pduel->game_field->get_useable_count(nullptr, playerid, LOCATION_SZONE, uplayer, reason, zone, &list));
lua_pushinteger(L, list);
if(swapped) {
pduel->game_field->player[0].used_location = used_location[0];
pduel->game_field->player[1].used_location = used_location[1];
pduel->game_field->player[0].list_szone.swap(list_szone[0]);
pduel->game_field->player[1].list_szone.swap(list_szone[1]);
}
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_t scriptlib::duel_get_location_count_fromex(lua_State *L) {
...
...
@@ -4876,6 +4931,7 @@ static const struct luaL_Reg duellib[] = {
{ "CheckSummonedCount", scriptlib::duel_check_summon_count },
{ "GetLocationCount", scriptlib::duel_get_location_count },
{ "GetMZoneCount", scriptlib::duel_get_mzone_count },
{ "GetSZoneCount", scriptlib::duel_get_szone_count },
{ "GetLocationCountFromEx", scriptlib::duel_get_location_count_fromex },
{ "GetUsableMZoneCount", scriptlib::duel_get_usable_mzone_count },
{ "GetLinkedGroup", scriptlib::duel_get_linked_group },
...
...
scriptlib.h
View file @
83936a3f
...
...
@@ -499,6 +499,7 @@ public:
static
int32_t
duel_check_summon_count
(
lua_State
*
L
);
static
int32_t
duel_get_location_count
(
lua_State
*
L
);
static
int32_t
duel_get_mzone_count
(
lua_State
*
L
);
static
int32_t
duel_get_szone_count
(
lua_State
*
L
);
static
int32_t
duel_get_location_count_fromex
(
lua_State
*
L
);
static
int32_t
duel_get_usable_mzone_count
(
lua_State
*
L
);
static
int32_t
duel_get_linked_group
(
lua_State
*
L
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment