Commit graph

344 commits

Author SHA1 Message Date
Edoardo Lolletti
c20d9a4b38 Update copyright years in changed files 2025-05-30 23:09:29 +02:00
Edoardo Lolletti
50a2b9ba22 Add initial draft of lua managed group lifetime 2025-05-30 23:09:22 +02:00
Edoardo Lolletti
7d31fdaade Make return values of Duel.GetChainInfo and Card.GetFlagEffectLabel actually int 2025-02-24 20:51:49 +01:00
Naim
e9475ef157
Allow passing player parameter directly (#160)
update the following functions to allow passing the player parameter directly, if needed:
Card.IsReleasable, Card.IsReleasableByEffect and Card.IsDiscardable.
Card.IsReleasableByEffect can also take an effect as 2nd optional parameter
2024-12-21 22:01:20 +01:00
Naim
86013b6e97
Update card::IsSSetable (#159)
Now it allows checking for a zone available in a certain player's field instead of only the player calling the function
2024-12-15 12:15:21 +01:00
Edoardo Lolletti
4e56e5b677 Automatically register GLOBALFLAG_DECK_REVERSE_CHECK 2024-11-04 22:36:54 +01:00
Edoardo Lolletti
e9e5c6cec9 Card.AssumeProperty: error out when invalid assume is passed
No longer make the function do nothing
2024-10-06 16:23:04 +02:00
Edoardo Lolletti
d841514796 Use std::max when makes more sense in libcard 2024-10-06 14:46:28 +02:00
Edoardo Lolletti
ba026c3fd6 Card.CheckRemoveOverlayCard and Card.RemoveOverlayCard: Create new groups only after the checks 2024-09-21 11:06:39 +02:00
Naim
11e59fd84b
Update Card.IsCanBeLinkMaterial (#157)
Default the summon player to the reason player
2024-07-17 18:56:39 +02:00
Edoardo Lolletti
7d79b281d8 Add Card.GetOwnEffects
Returns all the effects that are registered on a given card (including effects gained via EFFECT_TYPE_GRANT)
2024-07-09 20:54:03 +02:00
Edoardo Lolletti
b91dd7f752 Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +02:00
Edoardo Lolletti
a388095e1f Wrap luaL calls so that the lua stack has always at least 5 elements
Functions from the auxiliary library, assume the stack has always at least 5 empty slots, add macro ensure_luaL_stack to wrap every such call so that the stack is checked for enough free space beforehand. This will make mandatory to use the latest version of visual studio 2017 as minimum for windows (it was already being required for c++17 support regardless), as it needs the conformant c++ preprocessor option to be used.
2024-04-13 10:36:47 +02:00
Edoardo Lolletti
787bd2d7e1 Minor cleanups in interpreter.cpp 2024-04-13 10:36:17 +02:00
Edoardo Lolletti
e4fc37a4ca Minor updates 2024-04-02 14:02:23 +02:00
Edoardo Lolletti
16add063f6 Remove check_param_count where redoundant
LUA_FUNCTIONs don't really need to check the amount of parameters to be at least 1, as that's implicitly checked by the mandatory first parameter being the lua_object itself
2024-02-25 15:55:53 +01:00
Edoardo Lolletti
acaa99beb9 Use clang-tidy to update instances where 0 was used instead of nullptr 2024-01-13 16:30:50 +01:00
Edoardo Lolletti
6d83314fcf Use lua_iterate_table_or_stack instead of manually checking for table where needed 2024-01-06 21:52:34 +01:00
Edoardo Lolletti
ff41aec90a Update header inclusion 2024-01-05 13:03:46 +01:00
Edoardo Lolletti
8b4bd4ac53 Update field functions to properly take bool and not uint8_t 2024-01-03 14:29:48 +01:00
Edoardo Lolletti
da45f91460 Update copyright for 2024 2024-01-03 01:21:08 +01:00
Edoardo Lolletti
6dc321de75 Make LuaParamType an enum class 2023-12-08 19:55:50 +01:00
Edoardo Lolletti
cdb14fd115 Use lua_createtable instead of lua_newtable
Allows preallocating the needed size for its elements since they're known in advance
2023-12-08 12:30:10 +01:00
Edoardo Lolletti
cb5516a931 Rename get_card_or_group and lua_tostring_or_empty
Use the lua_get prefix for consistency with the other higher level lua getters
2023-12-03 11:34:38 +01:00
Edoardo Lolletti
f89c5da422 Update get_card_or_group to return a pair group/card
To then be unpacked with c++ 17's structured binding
2023-11-26 17:47:46 +01:00
Edoardo Lolletti
434b775193 C++17 constructs 2023-11-26 17:47:46 +01:00
Edoardo Lolletti
57c0e37104 Minor cleanup Duel.AddMonsterAttribute 2023-11-25 11:16:36 +01:00
Edoardo Lolletti
20fbf2d87e LUA_FUNCTION: directly pass pduel in the function scope
Update lua functions to already have the pduel parameter passed inside them, thus not needing to manually retrieve them in the functions.
Add also a yieldk macro that does the same thing but for the yield continuation function, removing the redoundancies
2023-11-25 11:15:21 +01:00
Edoardo Lolletti
420d5b6107 LUA_FUNCTION: directly pass "self" parameter referring to the object
Most of the library functions are used as "class member functions" where the first parameter is always the corresponding lua object, update the LUA_FUNCTION macro so that the functions already have a "self" parameter corresponding to the already parsed lua object.
Added a new LUA_STATIC_FUNCTION macro for functions that are to be called without an associated object
2023-11-21 11:56:23 +01:00
Naim
7ac33a959f
Update tribute related functions to support "Ritual Beast Ulti-Reirautari" (#150)
* Update Card.IsReleasable to accept a second, optional parameter for the reason. Update GetReleaseGroup, GetReleaseGroupCount the same way as well, with the new parameter being the 4th. Defaulting it to REASON_COST will prevent massive script changes (cards that tribute by effect already use Card.IsReleasableByEffect).

* Update EFFECT_CANNOT_RELEASE to pass the reason and the reason effect a 4th and 5th parameters to its target function

* Pass the reason down the line until get_release_list, check_release_list,is_player_can_release and card::is_releasable_by_nonsummon, updating internal function calls accordingly

---------

Co-authored-by: Edoardo Lolletti <edoardo762@gmail.com>
2023-11-12 17:04:20 +01:00
Edoardo Lolletti
b349040157 Fix wrong forced parameter count in Card.IsSummonable and Card.IsMSetable 2023-09-19 18:17:58 +02:00
Edoardo Lolletti
70f419426c Don't push directly the result of bitwise operations with lua_pushboolean
Explicitly check for !=0 to avoid possible future oversights caused by the integers being changed becoming 64 bit
2023-08-12 10:19:31 +02:00
Naim
1c1c684d5f
Fix Card.IsCanBeDisabledByEffect (#140)
Importing the changes from: https://github.com/Fluorohydride/ygopro-core/pull/490
2023-05-31 17:45:00 +02:00
Edoardo Lolletti
7ff52adcd6 Fix Card.IsRace, Card.IsOriginalRace to properly work with 64 bit races
lua_pushboolean was expecting an int, but if checking for a race whose bit was higher than an uint32, that value was truncated to 0, thus passing "false", now make sure to actually pass a boolean by explicitly checking for != 0
2023-05-07 19:49:50 +02:00
Edoardo Lolletti
00e8ddd44f Minor update to setcode checking functions 2023-03-15 22:07:31 +01:00
Edoardo Lolletti
e73fb449a8 Silence downcast warnings 2023-02-07 16:43:27 +01:00
Edoardo Lolletti
93f77ab64e Import Card.IsCanBeDisabledByEffect
https://github.com/Fluorohydride/ygopro-core/pull/469
2023-02-05 11:19:45 +01:00
Edoardo Lolletti
29a7a057f1 Minor update to the way the summon info are stored
Decouple the summon location from the summon type, also keep track of the sequence and if the card was in a pzone, this allows to use symbolic locations in Card.IsSummonLocation as wel
2022-10-30 11:08:18 +01:00
Edoardo Lolletti
55b9588556 Update Card.IsLocation
Make it work with symbolic locations
2022-10-28 13:46:07 +02:00
Edoardo Lolletti
151a5b7f71
Add support for table arguments in function already accepting a variable number of parameters (#131)
Also update the IsSetCard function family to work with a table as parameter as well
2022-10-26 18:13:11 +02:00
Edoardo Lolletti
da59b442fa Typo in function name 2022-10-25 12:24:31 +02:00
Edoardo Lolletti
b525c9ee14 Fix regression introduced in Card.IsOriginalCodeRule 2022-10-19 16:49:35 +02:00
Edoardo Lolletti
2ce69cbf50 Update some instances where the usage of lua_gettop was unoptimal or redoundant
In loops don't reevaluate it each iteration, in some functions already checking the value before entering a specific codepath don't repeat the same check
2022-10-19 15:04:27 +02:00
Edoardo Lolletti
f7c41b30f6 Add Card.IsOriginalCode, IsExactType, IsOriginalType, IsOriginalRace, IsOriginalAttribute, IsSummonLocation, IsSummonPlayer, IsPreviousControler 2022-10-19 14:37:41 +02:00
Edoardo Lolletti
457bc55b5c Use luaL_checkstack on all the library function that return an arbitrary number of values
The given lua stack to a c function has enough room to push few return values without issues, so all the functions that return a fixed amount of values (usually 1 or 2) weren't touched, all the others that return an unknown amount are now properly calling checkstack to make the lua api allocate the space needed for all the return values.
2022-10-06 13:11:11 +02:00
Edoardo Lolletti
65f99b748f GetCardEffect and GetPlayerEffect: Fix lua assertion becuse the return stack size was not checked 2022-10-06 12:24:16 +02:00
Edoardo Lolletti
eb82fa3c57 Minor syntax/readibility updates 2022-09-17 12:46:51 +02:00
Edoardo Lolletti
0de9a3e1e4
Update internal race value to 64 bit (#127)
Bump the race value size from 32 to 64 bit, giving us 32 new race values.
This is needed to futureproof the new upcoming rush card types, that could end up making the card types become more than 32.
This change breaks both the core abi and the messages.
For the abi now the race field in the OCG_CardData struct changed from uint32_t to uint64_t.
For the messages, QUERY_RACE will now be an uint64_t instead of uint32_t, MSG_ANNOUNCE_RACE will send an uint64_t for the races that can be declared, and also will now expect an uint64_t as answer, also, the HINT_RACE property associated with MSG_HINT will be using the full uint64_t data field as well.
2022-09-03 22:45:49 +02:00
Edoardo Lolletti
f2960234ac Make Card.SetHint read the value as 64 bit 2022-08-31 17:04:39 +02:00
Edoardo Lolletti
dfe05a5ab1 Fix typo in Card.IsCanBeFusionMaterial
Was reading the playerid as 3rd parameter rather than 4th
2022-07-19 19:29:30 +02:00