Commit graph

493 commits

Author SHA1 Message Date
Edoardo Lolletti
c4fb83b3d9 Use std tie for tevent operator 2025-05-30 23:09:27 +02:00
Edoardo Lolletti
20d2e5a5ab Properly implement tevent::operator< instead of using memcmp
Properly handle the fact that event_cards  is now no longer a pointer
2025-05-30 23:09:26 +02:00
Edoardo Lolletti
f747c21c3a Explicitly allow fusion spell cards to start in the extra deck 2025-04-24 22:24:50 +02:00
Edoardo Lolletti
158aebe758 Add duel flag DUEL_NORMAL_SUMMON_FACEUP_DEF 2025-04-17 21:57:02 +02:00
Edoardo Lolletti
4505fa604a
Add DUEL_EXTRA_DECK_RITUAL flag (#164)
Allows ritual monsters to be treated as extra deck monsters, to account for the change in RUSH duels. For this implementation, if the flag is used with the extra monster zones enabled, the monster will be summonable to both EMZone and MMZone like other non link cards
2025-03-29 13:02:46 +01:00
Edoardo Lolletti
4bd56c2289 Prevent adding non extra deck monsters to the extra deck
Only extra deck monsters or faceup pendulum monsters should be allowed to go in the extra deck
2025-03-22 20:13:24 +01:00
Edoardo Lolletti
4e56e5b677 Automatically register GLOBALFLAG_DECK_REVERSE_CHECK 2024-11-04 22:36:54 +01:00
Edoardo Lolletti
0266090f98 Automatically enable GLOBALFLAG_DETACH_EVENT and GLOBALFLAG_BRAINWASHING_CHECK 2024-11-04 22:36:54 +01:00
Edoardo Lolletti
f05dc470bd Automatically enable GLOBALFLAG_SELF_TOGRAVE
Check if an effect of type EFFECT_SELF_TOGRAVE is registered, in which case enable the flag
2024-11-04 22:36:53 +01:00
Edoardo Lolletti
ee5d6cd574 Remove GLOBALFLAG_SPSUMMON_COUNT
Its whole purpose was actually a pessimization, as it was guarding a 3 instructions compare with another 3 instructions compare
2024-11-04 22:36:53 +01:00
Edoardo Lolletti
1fc4a58255 Address warning 2024-09-21 18:42:06 +02:00
Edoardo Lolletti
49dda1b9c6 Check for underflow in dec_effect_code 2024-09-21 11:03:50 +02:00
Edoardo Lolletti
607a5fcb59 Fix checking for tributes if multiple decrease tribute effects were applying at the same time
Regression introduced in 90e2c650dd
2024-08-30 18:38:48 +02:00
Edoardo Lolletti
7a81311598 Fix EFFECT_FORCE_NORMAL_SUMMON_POSITION
It got erroneously added in the variant rework, and was in an incomplete state, fixup what is possible for the moment
2024-05-30 17:29:07 +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
b769f3a1f9 Update the way grant effects are sorted
Sort them by "initial id", since lua references could diverge across different runs, thus leading to possibly non reproducible behaviour
2024-04-01 20:04:32 +02:00
Edoardo Lolletti
ffe3ba695b Make field::raise_event take card_set by value 2024-03-08 11:03:06 +01:00
Edoardo Lolletti
a50505ea81 Update handling for EFFECT_MUST_ATTACK_MONSTER
Properly implement 58c488de9e:
 * If only one effect is providing EFFECT_MUST_ATTACK_MONSTER the attack selection proceeds as normal, with the turn player choosing the attack targets
 * If multiple effects are providing EFFECT_MUST_ATTACK_MONSTER, the opponent choose the attack target like it did prior to the other change, if then the EFFECT_MUST_ATTACK_MONSTER effect applied on the selected monster was also applying to other monsters, the turn player will then choose among those monsters a valid attack target
2024-02-10 11:34:42 +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
e97a1c2f94
Restructure the processor handling to use a variant object (#149)
Rewrite the whole ``process`` function of the processor to use instead tag dispatching on variant objects.
Each single processor message got rewritten as a struct, inheriting from a base templated Process struct, containing only the required data for that process, rather than using the generic structure that ended up needing to spam bitwise operations to pack as many arguments in a byte as possible. This makes things easier to follow and streamlines the addition of new processes:
 - Define its struct with the parameters it expects by also providing a constructor
   - If the process requires an answer, inherit it from ``Process<true>``, if it requires no answer, inherit it from ``Process<false>``
 - Add such struct to the ``processors`` variant type
 - Declare and implement its corresponding ``bool process(Processors::NewProcess& arg);`` function
2024-01-08 20:46:41 +01:00
Edoardo Lolletti
44b0f30214 More minor c++17 updates 2024-01-05 16:53:38 +01:00
Edoardo Lolletti
9790b552a0 Address various warnings raised by clang's -Weverything
They were mostly extra breaks/extra semicolons
2024-01-05 15:50:25 +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
48a4ecf0b4 Fix possible crash in IsPlayerCanDiscardDeckAsCost with count of 0
If 0 was passed as count, and the checked player had no cards in his deck, and a EFFECT_TO_GRAVE_REDIRECT was applied, the core would've crashed
2023-12-21 21:58:07 +01:00
Naim
a2a979a00e
Added more chain info options (#153)
Added new flags for Duel.GetChainInfo:
TRIGGERING_STATUS: the status of the card
TRIGGERING_SUMMON_LOCATION: the summon location of the card
TRIGGERING_SUMMON_TYPE: its summon type
TRIGGERING_SUMMON_PROC_COMPLETE: if the card was properly summoned or not when it triggered the effect
TRIGGERING_SETCODES: the archetypes the card had when it activated the effect
2023-12-09 15:04:56 +01:00
Edoardo Lolletti
6dc321de75 Make LuaParamType an enum class 2023-12-08 19:55:50 +01:00
Edoardo Lolletti
f079c3bdb4 Add CHAININFO_TRIGGERING_TYPE 2023-12-08 10:04:31 +01:00
Edoardo Lolletti
816fe64199 Update emplace_back/back construct usage
Use c++17's return value on emplace_back
2023-11-26 17:47:47 +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
dd9f84e592 Spsummon procedure: pass the proc effect to player's EFFECT_CANNOT_SPECIAL_SUMMON 2023-10-14 14:49:49 +02:00
Edoardo Lolletti
d9b959a75f Fix chain attacking by monsters with EFFECT_EXTRA_ATTACK_COUNT_MONSTER applied 2023-09-24 16:48:50 +02:00
Edoardo Lolletti
0ff1ecfff5 Handle cards in the main and extra deck in Duel.ReleaseRitualMaterial 2023-06-02 17:12:48 +02:00
Edoardo Lolletti
6b91ccd8e7 Fix crash when getting ritual materials 2023-06-02 17:12:06 +02:00
Edoardo Lolletti
25d30add8a Check for EFFECT_EXTRA_RITUAL_MATERIAL in main and extra deck 2023-06-01 11:25:31 +02:00
Edoardo Lolletti
3f6bd811d9 GetRtitualMaterial: Return only faceup oppo's monsters 2023-06-01 11:24:59 +02:00
Naim
586bf87965
Fix Duel.IsPlayerCanDiscardDeckAsCost (#141)
Importing the changes from: https://github.com/Fluorohydride/ygopro-core/pull/480
2023-05-31 17:38:40 +02:00
Edoardo Lolletti
04ad396c05 Prevent crash in get_chain if there's a continuous chain but no reason effect 2023-05-16 10:24:24 +02:00
Edoardo Lolletti
85bec80d87 Add EFFECT_COUNT_CODE_CHAIN (import https://github.com/Fluorohydride/ygopro-core/pull/485) 2023-04-02 16:52:13 +02:00
Edoardo Lolletti
c8354bcf17 Add some helper functions to use for handling of count limits 2023-04-02 16:39:35 +02:00
Edoardo Lolletti
cb350ca38e Remove some redoundancies and put them in field::reset_chain 2023-04-02 16:37:46 +02:00
Edoardo Lolletti
0491984317 Remove costly pass by value of chain struct 2023-03-15 22:03:39 +01:00
Edoardo Lolletti
e73fb449a8 Silence downcast warnings 2023-02-07 16:43:27 +01:00
Edoardo Lolletti
7bc4f3bab7 make field::get_pzone_index return uint8 2022-10-30 11:01:00 +01:00
Edoardo Lolletti
99361da960 Fix some places where the offseted sequences weren't being handled 2022-10-28 20:23:23 +02:00
Edoardo Lolletti
c9a3a0a903 Add CHAININFO_TRIGGERING_LOCATION_SYMBOLIC and CHAININFO_TRIGGERING_SEQUENCE_SYMBOLIC
Explicitely return the symbolic locations and relative sequences
2022-10-28 20:03:45 +02:00
Edoardo Lolletti
1ec18571c8 Make sequences for location_mmzone and location_stzone be 0-2 on 3 columns field 2022-10-28 20:03:45 +02:00
Edoardo Lolletti
7b5a52c6cc Add new symbolic locations
LOCATION_STZONE (the Spell & Trap zone, so excluding mr3 pzones and field zone), LOCATION_MMZONE and LOCATION_EMZONE. Usable in GetMatchingCard, GetFieldGroup, etc
2022-10-28 13:00:48 +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