Skip to content
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

Implement "perpetually" mechanic #13016

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

karapuzz14
Copy link
Contributor

@karapuzz14 karapuzz14 commented Oct 20, 2024

I was brave enough to try implementing this digital mechanic and I hope that I didn't break anything else in process.

"Perpetually" is complex mechanic that isn't described in Comprehensive Rules, so my main source of information is MtGA experiments. And also this very useful third-party research.

According to that, there are core principles:

  1. Perpetual effect is a continuous effect. So it applies in its usual layers and follows same timestamp rules.
  2. Perpetual effect can't be removed after zone change. There are only 2 exceptions: melded card decomposition and Brawl-like assumption that perpetual effects on commander can be removed on the way to the commander zone.

Summary of my pull-request:

  • PerpetuallyEffect interface that helps any perpetual effect to keep its features (meld cards and commander workarounds) and to be recognised
  • 3 new common continuous effects (BoostTargetPerpetuallyEffect, GainAbilityTargetPerpetuallyEffect, SetBasePowerToughnessTargetPerpetuallyEffect)
  • 3 new common effects that exploit mentioned effects and which are often used in cards with "perpetually": BoostSourcePerpetuallyEffect, CardsInYourHandPerpetuallyGainEffect, ChooseACardInYourHandItPerpetuallyGainsEffect
  • changes in ContinuousEffects: new methods for handling perpetual effects and map for storing perpetual rules that need to be colored
  • changes in CardUtil: colorizing perpetual rules text and their summation
  • changes in PlayerImpl, CommanderReplacementEffect and GameImpl: optional removing perpetual effects from commander (arena update highlights)
  • changes in GameState: I've added one condition to addOtherAbility() because of ability didn't change its controller and perpetually gained activated abilities attached to "stolen" card were not active (I hope it's not gamebreaking), also there's adventure and split cards workaround
  • changes in CardImpl: workaround for adventure and split cards that allows their abilities to trigger on stack and their perpetual abilities to be returned
  • CardView and other client-focused changes: are made for colorizing perpetually affected P/T
  • small fix for Arden Angel (found it while testing)
  • small fix for SpellCostIncreaseSourceEffect (wrong Outcome)

Also I wrote PerpetuallyTest where I tried to describe and validate main and troublesome interactions with perpetual effects. Most of the described things are tested here except of rules generation.
Of course, there's bunch of example cards that helped me in general testing and writing unit-tests, but... I implemented more cards than had expected. I hope that perpetual effects structure review would have higher priority than 21 implemented cards which use its functionality. There're controversial cards, for example 'Davriel, Soul Broker' and lack of its emblem images.

The only thing where I've left TODO is "inactive check". There's no >3 players games in Arena so we don't know should perpetual effects be removed after their owner's leave or not. I hope to find answer in discussion.
Also fused cards aren't present in Arena, so perpetual effects don't apply on them in current version. This fact also needs discussion.

@karapuzz14 karapuzz14 marked this pull request as ready for review October 20, 2024 18:36
@xenohedron
Copy link
Contributor

This will be a lot to review, but thanks for writing out a clear description with references.

@JayDi85
Copy link
Member

JayDi85 commented Oct 22, 2024

Perpetually is a designed-for-digital, MTG Arena-specific mechanic introduced in Jumpstart: Historic Horizons.[1][2] It causes effects and modifications on a card to apply permanently to that card for the rest of the game, regardless of zone changes.

The permanence of perpetual effects has one exception; as a player's commander moves to the command zone, they may choose to remove all perpetual effects on their commander.[3] This was initially not the case, and many cards that applied perpetual effects were initially banned from Historic Brawl.

That's PR contains many game engine changes to support new type of effects. Maybe it can be implemented more easy by standard rules and global static effect like RadiationEmblem (see initGameDefaultHelperEmblems for example) -- some global effect for all zones that control lists of all perpetual effects per player and card, and apply it as continues effects or remove on commander request. Single source can help with many zone change and effects removing problems.

If it's a more complex logic than that PR can be accepted (after reviews).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants