Commit graph

498 commits

Author SHA1 Message Date
Oleg Agafonov
e320bf241c GUI, game: added source info in "choose number/amount" dialogs, added auto-choose for single possible value (part of #13638); 2025-05-17 21:18:45 +04:00
Oleg Agafonov
66db821437 refactor: combined announceX methods in one, improved X message and selection for AI (part of #10330) 2025-05-16 19:34:57 +04:00
Oleg Agafonov
133e4fe425
other: reworked target selection: (#13638)
- WIP: AI and multi targets, human and X=0 use cases, human and impossible targets use cases;
- improved stability and shared logic (related to #13606, #11134, #11666, continue from a53eb66b58, close #13617, close #13613);
- improved test logs and debug info to show more target info on errors;
- improved test framework to support multiple addTarget calls;
- improved test framework to find bad commands order for targets (related to #11666);
- fixed game freezes on auto-choice usages with disconnected or under control players (related to #11285);
- gui, game: fixed that player doesn't mark avatar as selected/green in "up to" targeting;
- gui, game: fixed small font in some popup messages on big screens (related to #969);
- gui, game: added min targets info for target selection dialog;
- for devs: added new cheat option to call and test any game dialog (define own dialogs, targets, etc in HumanDialogsTester);
- for devs: now tests require complete an any or up to target selection by addTarget + TestPlayer.TARGET_SKIP or setChoice + TestPlayer.CHOICE_SKIP (if not all max/possible targets used);
- for devs: added detail targets info for activate/trigger/cast, can be useful to debug unit tests, auto-choose or AI (see DebugUtil.GAME_SHOW_CHOOSE_TARGET_LOGS)
2025-05-16 13:55:54 +04:00
Oleg Agafonov
a53eb66b58 other: reworked target selection (now it use same logic and methods in all places), fixed AI and selection freezes in some use cases (related to #13606, #11285) 2025-05-07 17:34:36 +04:00
Oleg Agafonov
00dc6f4742 refactor: removed useless getNumberOfTargets from Target (replaced with getMinNumberOfTargets) 2025-05-07 02:55:02 +04:00
Oleg Agafonov
f83c2bea4b merge fix 2025-04-19 17:48:27 +04:00
Oleg Agafonov
3dc606501d AI: improved stability and bug fixes (related to #13290):
- bug's reason: wrong usage of canTarget, add/addTarget, getOpponents, etc;
- fixed that it can target dead players in some use cases (close #13507);
- fixed that it wrongly choose targets in bad/good effects in some use cases;
- fixed that it can't find valid targets in some use cases;
- fixed game freezes and errors with some cards;
2025-04-19 07:04:55 +04:00
Oleg Agafonov
b819545744 bump version 2025-04-11 17:50:12 +04:00
Oleg Agafonov
bae3089abb Reworked cost adjuster logic for better support of X and cost modification effects:
Improves:
* refactor: split CostAdjuster logic in multiple parts - prepare X, prepare cost, increase cost, reduce cost;
* refactor: improved VariableManaCost to support min/max values, playable and AI calculations, test framework;
* refactor: improved EarlyTargetCost to support mana costs too (related to #13023);
* refactor: migrated some cards with CostAdjuster and X to EarlyTargetCost (Knollspine Invocation, etc - related to #13023);
* refactor: added shared code for "As an additional cost to cast this spell, discard X creature cards";
* refactor: added shared code for "X is the converted mana cost of the exiled card";
* tests: added dozens tests with cost adjusters;

Bug fixes:
* game: fixed that some cards with CostAdjuster ignore min/max limits for X (allow to choose any X, example: Scorched Earth, Open The Way);
* game: fixed that some cards ask to announce already defined X values (example: Bargaining Table);
* game: fixed that some cards with CostAdjuster do not support combo with other cost modification effects;
* game, gui: fixed missing game logs about predefined X values;
* game, gui: fixed wrong X icon for predefined X values;

Test framework:
* test framework: added X min/max check for wrong values;
* test framework: added X min/max info in miss X value announce;
* test framework: added check to find duplicated effect bugs (see assertNoDuplicatedEffects);

Cards:
* Open The Way - fixed that it allow to choose any X without limits (close #12810);
* Unbound Flourishing - improved combo support for activated abilities with predefined X mana costs like Bargaining Table;
2025-04-08 22:39:10 +04:00
ssk97
969ffa1c98
FDN New Combat Rules (#13279)
* Remove all combat ordering code

* Use MultiAmount division for damage

* Remove damage selection division skipping in tests

* Fix Banding, Multi-block, add tests

* Fix test

* Fix random iteration order, fix new tests

* Add more info to choose dialog, make MultiAmountType class instead of enum

* Don't prompt for trample damage assignment if none possible

* Mark "Assign default damage" on tests, minor other test improvements
2025-03-30 14:42:05 -07:00
Oleg Agafonov
07f68fbf38 server: fixed error on server startup from a launcher (temporary fix, #13315); 2025-02-08 21:41:43 +04:00
Oleg Agafonov
f17cbbe72b AI: improved performance and fixed crashes on use cases with too much target options like "deals 5 damage divided as you choose" (related to #11285):
* added DebugUtil.AI_ENABLE_DEBUG_MODE for better IDE's debugging AI code;
 * it's a target amount optimizations;
 * it's use a grouping of possible targets due same static and dynamic stats (name, abilities, rules, damage, etc);
 * instead of going through all possible combinations, AI uses only meaningful targets from particular groups;
2025-02-06 17:40:22 +04:00
Oleg Agafonov
7d229e511c tests: added AI performance tests to reproduce bad use cases with too much possible targets 2025-02-05 13:12:22 +04:00
Oleg Agafonov
b62ac065c1 AI: improved performance in tournament games (now computer will play AI vs AI games at the same time); 2025-02-04 14:26:17 +04:00
Oleg Agafonov
fc159728c7 version bump 2025-02-01 20:16:27 +04:00
Oleg Agafonov
39872e2625 AI: fixed that computer can cheat with target selection and choose 1 creature instead multiple required (example: sacrifice, close #13219) 2025-01-12 14:46:16 +04:00
xenohedron
9c5c394c75
refactor: TargetCreatureOrPlayer inheritance (#13199)
* update TargetCreatureOrPlayer to be a subclass of TargetPermanentOrPlayer

closes #11161

* fix usages
2025-01-08 22:47:36 -05:00
Oleg Agafonov
b1f914bbf4 version bump 2024-11-30 22:42:47 +04:00
Oleg Agafonov
2d9ac4e732 refactor: removed outdated Player::assignDamage by multi amount dialog, fixed getMultiAmount to work with min values, added additional checks 2024-10-24 15:31:04 +04:00
Oleg Agafonov
278bda4c36 version bump 2024-09-08 22:13:45 +04:00
ssk97
b70638acc9
Unbound Flourishing's X doubling should be a triggered ability (and related refactors) (#12597)
Complete rework of Unbound Flourishing, removing the multiplier code for casting X spells.
Adds ActivateAbilityTriggeredAbility, NotManaAbilityPredicate, AbilitySourceAttachedPredicate
CopyStackObjectEffect now uses a MOR.
OrTriggeredAbility now works with target pointer setting abilities.
2024-08-22 13:33:39 -07:00
Oleg Agafonov
de5de0e103 version bump 2024-08-16 19:35:42 +04:00
Oleg Agafonov
7b2e9b390c GUI: added card hints in choose replacement effect dialog 2024-07-19 00:06:18 +04:00
Evan Kranzler
27bea843a3
[M3C] Implement Ulalek, Fused Atrocity and new colorless hybrid mana (#12273)
* improved by (#12415)
* Added symbol downloads for new colorless hybrid
---------

Co-authored-by: Alexander Novotny <alexander_novo@mail.tmcc.edu>
Co-authored-by: Oleg Agafonov <jaydi85@gmail.com>
2024-06-06 23:43:45 +04:00
Oleg Agafonov
add2d0473e dev, AI: improved AI logs:
* added object and targets info for possible actions;
* added detailed score for each action in possible action chains;
* added stack info;
* improved output for easy read and analyse;
2024-05-28 17:17:16 +04:00
Oleg Agafonov
2298ebc5f5 Playable mana calculation improved:
* server: fixed server crashes on usage of multiple permanents with {Any} mana abilities (example: Energy Refractor, related to #11285);
* AI: fixed game freezes and errors on computer's {Any} mana usage (closes #9467, closes #6419);
2024-05-27 22:24:58 +04:00
Susucre
754b382e78
implement [MH3] Nethergoyf, refactor targets usages by game param (#12267) 2024-05-21 13:34:38 +02:00
Oleg Agafonov
ebe04dc3a6 tests: added tests for Chandra Ablaze card and some AI logic; 2024-05-12 14:37:10 +04:00
Susucre
85cad4ff1e
cleanup AbilityType for easier check that an ability is an activated ability (#12153)
* cleanup AbilityType

* further cleanup

* cleanup instanceof

* tweak formatting

* rework Rex

* fix mistake in PlayerImpl

* cleanup 'instanceof' for 'ActivatedManaAbilityImpl'
2024-05-03 22:13:34 -04:00
Oleg Agafonov
ad8e7daf97 refactor: improved card info 2024-02-18 22:40:30 +04:00
Oleg Agafonov
229e8d3075 game engine, tests and other fixes:
tests: fixed wrong permanent structure for battlefield cards (addCard command);
tests: added docs and additional runtime checks;
game: Modal double-faced cards - improved support, no more other side effects on battlefield;
game: Copy abilities - improved stability and cards support;
game: Player under control - improved stability and related cards support (possible NPE errors, additional runtime checks);
server: fixed bloated logs with game timer;
AI: fixed wrong timer in computer games;
2024-02-17 19:35:44 +04:00
Oleg Agafonov
08b99fcbf7 AI: removed outdated AIMinimax project (#7075), removed some useless player classes, code and config files, improved docs; 2024-01-15 05:03:21 +04:00
xenohedron
9b3ff32a33
Rework sacrifice effects to support "can't be sacrificed" (#11587)
* add TargetSacrifice and canBeSacrificed

* SacrificeTargetCost refactor, now uses TargetSacrifice, constructors simplified, subclasses aligned

* fix text errors introduced by refactor

* refactor SacrificeEffect, SacrificeAllEffect, SacrificeOpponentsEffect

* cleanup keyword abilities involving sacrifice

* fix a bunch of custom effect classes involving sacrifice

* fix test choices

* update Assault Suit implementation

* fix filter check arguments

* add documentation to refactored common classes

* [CLB] Implement Jon Irenicus, Shattered One

* implement "{this} can't be sacrificed"

* add tests for Assault Suit and Jon Irenicus

* refactor out PlayerToRightGainsControlOfSourceEffect

* implement [LTC] Hithlain Rope

* add choose hint to all TargetSacrifice

---------

Co-authored-by: Evan Kranzler <theelk801@gmail.com>
Co-authored-by: PurpleCrowbar <26198472+PurpleCrowbar@users.noreply.github.com>
2023-12-31 14:10:37 -05:00
xenohedron
35f4a898f9
Small rework for autochoosing color of mana to add (#11495)
fix #11494
2023-12-01 00:49:42 -05:00
Oleg Agafonov
58ce3296b6 AI: little refactor 2023-11-26 21:37:47 +04:00
Jeff Wadsworth
c7007a3de3 Fixed #11426 2023-11-22 10:22:34 -06:00
Jeff Wadsworth
0820761c3a Fixed #8771 2023-11-01 21:26:28 -05:00
Oleg Agafonov
3abdb72910
dev: improved code coverage (jacoco) and static analyser (sonar) support (#11367):
* fixed code coverage data lost on failed tests;
* fixed code coverage report duplication and improved performance;
* fixed that sonar analyser can't see code coverage for some modules;
* added new aggregation module: Mage.Reports (used for code coverage report generation);
* reorganized pom and added additional instructions for jacoco and sonar usage;
2023-10-30 09:19:12 +04:00
Susucre
7c454fb24c
Rework AsThough handling to allow choosing/affecting a specific alternate cast (#11114)
* Rework AsThoughEffect

* some cleanup of MageIdentifer

* refactor ActivationStatus

* fix bolas's citadel

* fix a couple of the Alternative Cost being applied too broadly.

* fix Risen Executioneer

* allow cancellation of AsThough choice.

* fix One with the Multiverse

* cleanup cards needing their own MageIdentifier

* last couple of fixes

* apply reviews for cleaner code.

* some more cleanup
2023-10-02 18:42:54 -04:00
Oleg Agafonov
4e77ccb381 refactor: removed unused data from special action, improved code (related to #11137) 2023-09-17 14:37:49 +04:00
Oleg Agafonov
8a65b0f149 refactor: removed netbeans's auto-generated comments 2023-09-02 16:05:29 +04:00
Susucre
5062c84098
Refactor: removed server side objects from a client side game's data (#10788)
* Clean original values transmitted with CardView.originalObject
* Move RateCard to mage.Common, support cardView as argument.
* Clean PermanentView constructor for TestCardRenderDialog
2023-08-24 12:04:07 +04:00
Artemis Kearney
9ba0da00ff
Basic groundwork for extra decks (contraptions, attractions) (#10378)
* extra deck cards not counted in deck size

* extra deck handling in deckbuilder

* move responsibility for extraDeckCard boolean to CardImpl

* remove redundant field copy
2023-08-06 21:06:32 -04:00
Alexander Novotny
a36a7d9b7f
[LTR] Add Goldberry, River-Daughter (#10524)
* Added Goldberry

* Slight optimizaztion

* Happy Path Test

* More unhappy tests

* Sanity check for Goldberry's counter choices

* Updated player.getMultiAmount to support individual constraints

* Some cleanup

Also modified ResourcefulDefense to use new multi amount api

* Updated logging

* Added hint for number of counters

* Fixed issue with Resourceful Defense

* Improvements to defaults

Default list will properly make sure to stay within individual maximums
If a player is asked for a choice that isn't actually a choice because each choice's min and max are equal, instead the default response is immediately returned. This helps with situations like moving a counter off of Goldberry when she only has one counter on her.

* -1/-1 Counter test

* Fixed issue with -1/-1 counters

* Adjusted dialog to properly enforce constraints
2023-07-28 21:29:40 -04:00
Evan Kranzler
a850e3660b
Change supertype method in constructors (#10361)
* replace addSuperType with supertype.add in card constructors

* more supertype replacements

* update MDFC supertype implementation

* remove unnecessary class

* update test
2023-05-12 20:45:07 -04:00
Oleg Agafonov
1dea98cf1f Game: fixed that search by card name was able to return a wrong card (example: cheat command) 2023-05-08 22:58:30 +04:00
Oleg Agafonov
5474787641 Refactor: added miss Ability source in some choose methods 2023-04-21 10:08:33 +04:00
Evan Kranzler
947351932b
Ready for Review: Implementing Battles (#10156)
* add types and subtypes

* add startingDefense attribute

* [MOM] Implement Invasion of Ravnica / Guildpact Paragon

* fix two small errors

* refactor various instances of "any target"

* fully implement defense counters

* battles can now be attacked

* [MOM] Implement Invasion of Dominaria / Serra Faithkeeper

* [MOM] Implement Invasion of Innistrad / Deluge of the Dead

* [MOM] Implement Invasion of Kaladesh / Aetherwing, Golden-Scale Flagship

* [MOM] Implement Invasion of Kamigawa / Rooftop Saboteurs

* [MOM] Implement Invasion of Karsus / Refraction Elemental

* [MOM] Implement Invasion of Tolvada / The Broken Sky

* simplify battle info ability

* fix verify failure

* some more fixes for attacking battles

* [MOM] Implement Invasion of Kaldheim / Pyre of the World Tree

* [MOM] Implement Invasion of Lorwyn / Winnowing Forces

* [MOM] Implement Invasion of Moag / Bloomwielder Dryads

* [MOM] Implement Invasion of Shandalar / Leyline Surge

* [MOM] Implement Invasion of Belenon / Belenon War Anthem

* [MOM] Implement Invasion of Pyrulea / Gargantuan Slabhorn

* [MOM] Implement Invasion of Vryn / Overloaded Mage-Ring

* [MOM] Implement Marshal of Zhalfir

* [MOM] Implement Sunfall

* implement protectors for sieges

* partially implement siege defeated trigger

* fix verify failure

* some updates to blocking

* [MOM] Implement Invasion of Mercadia / Kyren Flamewright

* [MOM] Implement Invasion of Theros / Ephara, Ever-Sheltering

* [MOM] Implement Invasion of Ulgrotha / Grandmother Ravi Sengir

* [MOM] Implement Invasion of Xerex / Vertex Paladin

* add initial battle test

* fix verify failure

* [MOM] Implement Invasion of Amonkhet / Lazotep Convert

* [MOM] update spoiler

* update how protectors are chosen

* update text

* battles can't block

* add control change test

* rename battle test for duel

* add multiplayer test

* [MOM] Implement Invasion of Alara / Awaken the Maelstrom

* [MOM] Implement Invasion of Eldraine

* [MOM] Implement Invasion of Ergamon / Truga Cliffhanger

* [MOM] Implement Invasion of Ixalan / Belligerent Regisaur

* battles now cast transformed (this is super hacky but we need to refactor TDFCs anyway)

* add TODO

* add ignore for randomly failing test

* a few small fixes

* add defense to MtgJsonCard (unused like loyalty)

* implement ProtectorIdPredicate

* small fixes
2023-04-13 20:03:16 -04:00
Oleg Agafonov
a15a0daa04 Fixed potential NPE errors in getPhase usage (fixed Berserker's Frenzy, etc) 2023-03-25 16:01:27 +04:00
Alex Vasile
f68db93683 Fix minor bug in ComputerPlayer mana handling 2022-10-04 02:01:34 -04:00