mage icon indicating copy to clipboard operation
mage copied to clipboard

"If {A} attacks, {B} attack if able" effects are impossible to implement correctly

Open awjackson opened this issue 3 years ago • 2 comments

Attack requirement effects are currently only checked once per combat, before the active player has declared any attackers. This is good enough for most requirements, but it doesn't work for effects that depend on which other creatures are attacking.

Affected cards:

[[Ekundu Cyclops]] (not implemented in xmage, see https://github.com/magefree/mage/pull/8594) [[Magnetic Web]] (not implemented in xmage) [[Viashino Bey]] (currently implemented, incorrectly, as a triggered ability) [[War's Toll]] (currently implemented, incorrectly, as a restriction effect)

awjackson avatar Jan 25 '22 18:01 awjackson

Ekundu Cyclops - (Gatherer) (Scryfall) (EDHREC)

{3}{R} Creature — Cyclops 3/4 If a creature you control attacks, Ekundu Cyclops also attacks if able.

Magnetic Web - (Gatherer) (Scryfall) (EDHREC)

{2} Artifact If a creature with a magnet counter on it attacks, all creatures with magnet counters on them attack if able. Whenever a creature with a magnet counter on it attacks, all creatures with magnet counters on them block that creature this turn if able. {1}, {T}: Put a magnet counter on target creature.

Viashino Bey - (Gatherer) (Scryfall) (EDHREC)

{2}{R}{R} Creature — Viashino 4/3 If Viashino Bey attacks, all creatures you control attack if able.

War's Toll - (Gatherer) (Scryfall) (EDHREC)

{3}{R} Enchantment Whenever an opponent taps a land for mana, tap all lands that player controls. If a creature an opponent controls attacks, all creatures that opponent controls attack if able.

github-actions[bot] avatar Jan 25 '22 18:01 github-actions[bot]

I present a simple algorithm that can correctly handle those 4 cards here: Step By Step: Declaring Attackers

Unfortunately I believe it's O((2^n)!) in the worst case, but in practice it's not a problem; you can try out the calculator on the page and it's able to return results in <100ms for almost any realistic set of creatures.

KingSupernova31 avatar Aug 23 '24 20:08 KingSupernova31

Proposed workaround for [MIR] Ekmundu Cyclops

At the beginning of combat on your turn, you may have Ekmundu Cyclops gain "This creature must attack this turn if able" until end of combat. If you decline, then you gain "creatures you control can't attack this turn" until end of combat.

There also needs to be a check that removes the option to decline if any of your other creature currently "must attack".

Also, because it would likely be only able to be implemented as a Triggered Ability - would also need to prevent that ability being copied or countered.


This is beyond my current scope for coding for xamge, so I will need to leave it to someone else to submit a PR if that is seen as an acceptable workaround.

tiera3 avatar Jan 30 '25 11:01 tiera3