-
Notifications
You must be signed in to change notification settings - Fork 785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[STX] Implement Ecological Appreciation #7732
[STX] Implement Ecological Appreciation #7732
Conversation
} | ||
int xValue = source.getManaCostsToPay().getX(); | ||
TargetCard targetCardsInLibrary = new EcologicalAppreciationTarget(Zone.LIBRARY, 4, xValue); | ||
boolean searched = player.choose(Outcome.PutCreatureInPlay, new CardsImpl(player.getLibrary().getCards(game)), targetCardsInLibrary, game); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use player.searchLibrary(...)
instead if desired -- went with this approach to avoid having to make two kinds of targets for EcologicalAppreciationTarget
: one for TargetCardInLibrary
and one for TargetCardInGraveyard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple xmage hint:
- If you can use existed classes and methods then use it;
- If you need to create a new one then make research and ensure that you really need it;
- Custom classes (card's specific classes) are tech debt and must be skipped as much as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
understood 👍
It looks fine to me, it'll need to be refactored as a part of #7685 anyway. |
} | ||
} | ||
|
||
class EcologicalAppreciationTarget extends TargetCard { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not extends TargetCard
-- there are limited number of default target classes, so extends it instead (if you really needs it, but I can't see needs in your use case -- just use TargetCardInYourGraveyard
and TargetCardInLibrary
with name and cmc predicates).
It's important cause AI uses only known target type and will raise error on the new one (it's not critical in your use case cause it uses existing cards list but in can be critical in another custom targets).
I recommends to use name and cmc predicates to generate dynamic filter and use it in choose dialogs. If you can't then keep that code (it's ok in your use case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the EcologicalAppreciationTarget
class and just used TargetCardInLibrary
and TargetCardInYourGraveyard
. I was able to use the cmc predicate to add a filter. However, I wasn't sure how to do the different names predicate, so I extracted that logic to a method and made both targets anon classes overriding canTarget
, which seemed to be a good compromise to avoid dupe code. Also, in the GY case, I needed to also block selecting cards that were chosen from library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create new filter on apply (filter.copy
) and add dynamic cmc and names predicates to it.
Name predicate usage example:
filter.add(Predicates.not(new NamePredicate("ignore name")));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. But I can see the problem with predicates now -- you still allows to select same names in one step, so canTarget
is good approach.
} | ||
int xValue = source.getManaCostsToPay().getX(); | ||
TargetCard targetCardsInLibrary = new EcologicalAppreciationTarget(Zone.LIBRARY, 4, xValue); | ||
targetCardsInLibrary.setNotTarget(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use target.withChooseHint
to inform user in choose dialog about current step or additional info. Example: "step 1 of 2, from library".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
} | ||
int xValue = source.getManaCostsToPay().getX(); | ||
TargetCard targetCardsInLibrary = new EcologicalAppreciationTarget(Zone.LIBRARY, 4, xValue); | ||
boolean searched = player.choose(Outcome.PutCreatureInPlay, new CardsImpl(player.getLibrary().getCards(game)), targetCardsInLibrary, game); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple xmage hint:
- If you can use existed classes and methods then use it;
- If you need to create a new one then make research and ensure that you really need it;
- Custom classes (card's specific classes) are tech debt and must be skipped as much as possible.
Cards cards = new CardsImpl(targetCardsInLibrary.getTargets()); | ||
|
||
if (cards.isEmpty()) { | ||
if (searched) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a smell code to call shuffle three times. You can store it the status var and use it at the end. Also don't use searched
at all -- always shuffle it. Cause cheating possible: user can open choose dialog and disconnect (see #4263) -- so you will get a false here, but he already saw the cards order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
chosenCards.setNotTarget(true); | ||
opponent.choose(outcome, cards, chosenCards, game); | ||
Cards toShuffle = new CardsImpl(chosenCards.getTargets().stream() | ||
.map(game::getCard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing filter by Objects::nonNull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
this.getTargets().stream() | ||
.map(game::getCard) | ||
.map(MageObject::getName) | ||
.noneMatch(card.getName()::equals); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need names compare then use CardUtil.haveSameNames
all the time. It's important to use it in all code cause face down cards don't have names and can't be equal to another empty name (but java's compare does).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
* [STX] Implemented Promising Duskmage * fixed Blatant Thievery test failure * [STX] fixed a verify error * [STX] Pest Summoning - Fixed using wrong token * [STX] Implemented Beledros Witherbloom * [KHM] fixed Roots of Wisdom being able to target any card * [STX] Implemented Honor Troll * [STX] Implemented Teachings of the Archaics * [STX] Implemented Tend the Pests * [STX] Implemented Tome Shredder * [STX] updated spoiler * [STX] updated spoiler * [STX] Implemented Killian, Ink Duelist * [STX] Implemented Biblioplex Assistant * [C21] updated spoiler * [C21] Implemented Excavation Technique * [C21] Implemented Angel of the Ruins * [C21] Implemented Monologue Tax * [STX] Implemented Zimone, Quandrix Prodigy * [STX] Implemented Zephyr Boots * [STX] Implemented Spell Satchel * [STX] Implemented Brackish Trudge * [STX] Implemented Spiteful Squad * [C21] updated spoiler and reprints * [STX] Implemented Galazeth Prismari * [STX] Implemented Hall of Oracles * [STX] Implemented Pillardrop Warden * [STX] Implemented Ardent Dustspeaker (magefree#7717) * [STX] Implemented Ardent Dustspeaker * Declare filter as static * fix: attack ability trigger for opponent creatures (magefree#7697) The checkTrigger of ZurzothChaosRiderAttackAbility wasn't filtering creatures controlled by Zurzoth's controller * Fixed compile warning * [STX] Implemented Blex, Vexing Pest (magefree#7719) * [STX] Implemented Daemogoth Woe-Eater * [STX] Implemented Culling Ritual * [STX] Implemented Mortality Spear * [STX] Implemented Oriq Loremage * [STX] Implemented Rushed Rebirth * [STX] Implemented Silverquill Silencer * [STX] Implemented Harness Infinity * [C21] Implemented Bronze Guardian * [C21] Implemented Adrix and Nev, Twincasters * [STX] Implemented Willowdusk, Essence Seer * [C21] updated spoiler and reprints * [C21] Implemented Veyran, Voice of Duality * [C21] Implemented Inferno Project * [C21] Implemented Digsite Engineer * [C21] Implemented Audacious Reshapers * [STX] Implemented Mage Hunters' Onslaught * [STX] Implemented Mercurial Transformation * [STX] Implemented Deadly Brew * [STX] Implemented Maelstrom Muse * [STX] Implemented Infuse with Vitality * [STX] Implemented Bookwurm * [STX] Implemented Explosive Welcome * [STX] Implemented Reject * [STX] Implemented Test of Talents * [STX] Implemented Make Your Mark * fixed an error * [STX] Implemented Retriever Phoenix * [STX] Implemented Emergent Sequence * [C21] updated spoiler * [STX] Implemented Dina, Soul Steeper * [C21] Implemented Deekah, Fractal Theorist * [C21] Implemented Fiery Encore * [C21] Implemented Guardian Augmenter * [C21] Implemented Paradox Zone * [C21] Implemented Oversimplify * [C21] Implemented Replication Technique * [C21] Implemented Archaeomancer's Map * [C21] Implemented Sequence Engine * [C21] Implemented Perplexing Test * [C21] Implemented Reinterpret * [C21] Implemented Octavia, Living Thesis * [C21] Implemented Spawning Kraken * [C21] Implemented Curiosity Crafter * [STX] Implemented Inspiring Refrain * [C21] Implemented Rousing Refrain * fixed a test failure * [STX] Implemented Dramatic Finale * [C21] updated spoiler and reprints * [C21] Implemented Incarnation Technique * additional test fix * [STX] Implemented Dragon's Approach * [STX] Implemented Draconic Intervention * [STX] Implemented Flamescroll Celebrant // Revel in Silence * [STX] Implemented The Biblioplex * [STX] Implemented Detention Vortex * [STX] add more cards (magefree#7720) * implement AcademicProbation * implement AugmenterPugilist // EchoingEquation * Implement BalefulMastery * implement BasicConjuration * implement ClosingStatement * Test framework: added custom effect to return card from any zone to hand; Co-authored-by: Oleg Agafonov <[email protected]> * [STX] Implemented Devastating Mastery * [STX] Implemented Fervent Mastery * [C21] updated spoiler and reprints * [C21] updated spoiler and reprints * [C21] Implemented Pest Infestation * [C21] Implemented Revival Experiment * [C21] Implemented Witch's Clinic * [C21] Implemented Trudge Garden * [C21] Implemented Veinwitch Coven * [C21] Implemented Healing Technique * [C21] Implemented Tivash, Gloom Summoner * added life gain hints to various cards * [STX] Implemented Reflective Golem * [STX] Implemented Velomachus Lorehold * [STX] Implemented Elemental Expression * [STX] Implemented Mage Duel * [STX] Implemented Pestilent Cauldron / Restorative Burst * fixed a test failure * [STX] Implement Conspiracy Theorist (magefree#7728) * [STX] Implement Conspiracy Theorist * removed temporary test skips * [STX] Implemented Plumb the Forbidden * [STX] Implemented Ingenious Mastery * [STX] Implemented Show of Confidence * [STX] Implement Devouring Tendrils (magefree#7731) * [STX] Implement Devouring Tendrils * [ODY] fixed Aven Windreader effect magefree#7733 * [STX] Implemented Wandering Archaic / Explore the Vastlands * [STX] Implemented Extus, Oriq Overlord / Awaken the Blood Avatar * [STX] Implemented Jadzi, Oracle of Arcavios / Journey to the Oracle * [ODY] fixed Skyshooter not sacrificing itself to activate (fixes magefree#7738) * [STX] Implemented Expressive Iteration * [C21] Implemented Alibou, Ancient Witness * [C21] Implemented Ruin Grinder * [KHM] fixed Spectral Deluge counting Islands controlled by other players (fixes magefree#7739) * [C21] Implemented Blight Mound * added new EachTargetPointer object * [C21] Implemented Ezzaroot Channeler * [C21] Implemented Essence Pulse * [C21] Implemented Triplicate Titan * [C21] Implemented Felisa, Fang of Silverquill * [C21] Implemented Ruxa, Patient Professor * [STX] Implemented Codie, Vociferous Codex * [C21] Implemented Blossoming Bogbeast * [C21] Implemented Creative Technique * [C21] Implemented Fain, the Broker * [C21] Implemented Gyome, Master Chef * [C21] Implemented Keen Duelist * [C21] updated spoiler and reprints * [STX] Implemented Verdant Mastery * [STX] Implemented Mila, Crafty Companion / Lukka, Wayward Bonder * [STX] Implemented Rowan, Scholar of Sparks / Will, Scholar of Frost * [STX] Implemented Strixhaven Stadium * [STX] Implemented Radiant Scrollwielder * [STX] Implemented Hofri Ghostforge * [C21] Implemented Wake the Past * [STX] Implement Ecological Appreciation (magefree#7732) * [STX] Implement Ecological Appreciation * Add possibility to play less rounds of swiss than xmage suggests (magefree#7729) * Make it possible to adjust the number of rounds in a swiss tournament to be less than the number of rounds suggested by xmage. Co-authored-by: sprangg <[email protected]> Co-authored-by: Oleg Agafonov <[email protected]> * [C21] Implemented Esix, Fractal Bloom * [C21] Implemented Inkshield * [C21] Implemented Nils, Discipline Enforcer * [C21] Implemented Cursed Mirror * [C21] Implemented Rionya, Fire Dancer * [C21] Implemented Zaffai, Thunder Conductor * [C21] Implemented Scholarship Sponsor * [C21] Implemented Dazzling Sphinx * [C21] Implemented Commander's Insight * [STX] Implemented Mavinda, Students' Advocate * [STX] fixed Silverquill Command mode not targeting (fixes magefree#7743) * [STX] fixed Star Pupil not adding counters (fixes magefree#7744) * [STX] Implemented Elite Spellbinder * [STX] Semester's End * [C21] Implemented Tempting Contract * [C21] Implemented Stinging Study * [STX] Implemented Strict Proctor * [STX] Implemented Shadrix Silverquill * [STX] [C21] updated spoiler * [STX] Implement Efreet Flamepainter (magefree#7747) * [STX] Implement Efreet Flamepainter * Add null check * Target needs to be chosen before ability resolution * [READY FOR REVIEW] Implement a "multi-amount" dialog (magefree#7528) * Implemented chooseTargetAmount and new GUI dialog (distribute damage, distribute mana) * Added tests and AI support; * Test framework: added aliases support in TargetAmount dialogs; Co-authored-by: Oleg Agafonov <[email protected]> * [STX] Implemented Uvilda, Dean of Perfect / Nassari, Dean of Expression * [STX] fixed Rushed Rebirth delayed ability not triggering (fixes magefree#7765) * removed deprecated method for adding delayed triggered abilities * [STX] fixed Plumb the Forbidden ability not triggering (fixes magefree#7755) * [STX] Implement Selfless Glyphweaver (magefree#7754) * [STX] Implement Selfless Glyphweaver * static filter, choose on resolution * [STX] added null check to Selfless Glyphweaver * [STX] updated spoiler and add all printings * fixed a test failure * [STA] text fixes * replaced all instances of converted mana cost with mana value * [STX] various text fixes * fixed Ward ability text (fixes magefree#7715) * changed ExileSpellEffect from being singleton * added MTGJSON metadata to verify test * [STX] more text fixes * revert change to fix test, will investigate later * fixed a test failure * a few more cmc->mana value changes * un-reverted change, fixed test failure * [C21] Implemented Bold Plagiarist * [C21] Implemented Geometric Nexus * [C21] Implemented Sly Instigator * [STX] some final text fixes * some more text fixes * many find/replace "shuffle" fixes * if you're having text problems I feel bad for you son, I've got 99 problems and they're all text-related and I've only dealt with a small amount of them * fix failing test * more text fixes * [C21] Implemented Author of Shadows * [C21] Implemented Cunning Rhetoric * [C21] Implemented Theoretical Duplication * moved a misplaced test * [C21] Implemented Battlemage's Braces * [C21] Implemented Sproutback Trudge * fixed some text * [C21] Implemented Elementalist's Palette * [C21] Implemented Guardian Archon * small text update * C21 cards (magefree#7765) * initial commit of OsgirTheReconstructor incomplete * changed target * fixed target with adjustment * made requested changes changed exiled card to be a cost instead of effect * [C21] Implemented Surge to Victory * [C21] added missing card * more text fixes * [C21] Implemented Promise of Loyalty * [C21] Implemented Losheel, Clockwork Scholar * fixed a test failure * fixed another test failure * [STX] fixed Perplexing Test not bouncing nontoken permanents (fixes magefree#7766) * text fixes * text fix for ReturnFromGraveyardToBattlefieldTargetEffect * text fix for fetch lands * more text fixes * fixed test failures * reworked alara heralds * fix a Layer comparison in Liege of the Tangle * rewrite loop to stream * text fixes * fixed some cards with random effects (fixes magefree#7693) * [MRD] fixed Hum of the Radix applying to non-artifact spells (fixes magefree#7775) * [ONS] fixed Thrashing Mudspawn null pointer exception (fixes magefree#7775) * add RiteOfPassageTest for magefree#7740 * update .gitignore * Add Deicide Test * [STX] added booster collation * rewrite some dies events cards * test for issue magefree#7772 * [C21] Implemented Muse Vortex * updated copy implementation to work with stack objects * [C21] Implemented Radiant Performer * [C21] Implemented Marshland Bloodcaster * [STX] fixed a null pointer exemption with Radiant Scrollwielder (fixes magefree#7777, fixes magefree#7778, fixes magefree#7779) * Fleeting Aven return to Hand no longer optional, fixes magefree#7780 * [C21] Implemented Fractal Harness * [C21] Implemented Combat Calligrapher * [C21] Implemented Breena, the Demagogue * [C21] Implemented Study Hall * fixed effects counting opponents no longer in the game * [C21] Implemented Yedora, Grave Gardener * fixed a change left out from previous commit failure * use staticfilter for 'a spell' * remove explicit null checks, match(..) checks on null itself by instanceof calls * Resizing GUI elements live from the preference menu * [STX] fixed Reflective Golem triggering off of spells that don't target it (fixes magefree#7782) * [C21] various text fixes * Fixing issue with GUI events being triggered prematurely when loading prefs (magefree#7785) Co-authored-by: Evan Kranzler <[email protected]> Co-authored-by: Daniel Bomar <[email protected]> Co-authored-by: Damiano Carradori <[email protected]> Co-authored-by: htrajan <[email protected]> Co-authored-by: Oleg Agafonov <[email protected]> Co-authored-by: sprangg <[email protected]> Co-authored-by: sprangg <[email protected]> Co-authored-by: arketec <[email protected]> Co-authored-by: Ingmar Goudt <[email protected]> Co-authored-by: Michael Lee <[email protected]> Co-authored-by: Michael Lee <[email protected]>
No description provided.