Card-Forge / forge

An unofficial rules engine for the world's greatest card game.
https://card-forge.github.io/forge/
GNU General Public License v3.0
1.03k stars 571 forks source link

Protection from spells checks can fail #5262

Open tool4ever opened 6 months ago

tool4ever commented 6 months ago

Devoted Caretaker can give protection from instant + sorcery spells[^1]

Case A: ➡️ the cast trigger of The Beast, Deathless Prince will be from a spell source, so it shouldn't be able to target it now

Case B: ➡️ but the trigger from Kozilek's Return should be allowed to damage it, since the ability triggers in the GY

Ideas:

  1. I think ideally Card.isSpell() could be changed from

    • isInstant() || isSorcery() || (isAura() && !isInZone(ZoneType.Battlefield)) to just
    • isInZone(ZoneType.Stack) But I'm not sure if some that would fail some logic checks?
  2. Maybe just scripting it as Protection:Instant.inZoneStack,Sorcery.inZoneStack is the safer alternative

  3. Otherwise getProtectionValid will need a bigger rework as it also needs to provide SA valids:

    • but not for all parts
    • Damage replacement would somehow need to check the Cause instead (but only if DamageSource is its host?) 🤔

[^1]: So it's different from e. g. Petrified Wood-Kin which has "Protection from instants", here only the type should matter

Hanmac commented 6 months ago

i think we should try isInZone(ZoneType.Stack) and then fix the places where it breaks later

tool4ever commented 6 months ago

My initial tests with that aren't good: the AI never places a spell on the stack before checking for targets, so it'd cheat too quickly this way :/ but I will try combining it with 3.

Hanmac commented 6 months ago

My initial tests with that aren't good: the AI never places a spell on the stack before checking for targets, so it'd cheat too quickly this way :/ but I will try combining it with 3.

Yeah, the AI part needs to be fixed for this

tool4ever commented 6 months ago

Another problem with 1 is you could counter The Beast and then the ability can be retargeted because the zone gets updated 💩

Hanmac commented 6 months ago

Another problem with 1 is you could counter The Beast and then the ability can be retargeted because the zone gets updated 💩

Sounds like a problem where lki should be used?