[DSC] Implement Fear of Sleep Paralysis

Also fix UntapSourceCost to allow 'consuming a stun counter' to count as paying untap cost, per rule 118.11, but only if Fear of Sleep Paralysis isn't making stun permanent.
This commit is contained in:
Grath 2024-12-01 12:02:59 -05:00
parent c6bec887b9
commit 8f3cd5a106
3 changed files with 100 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.constants.AsThoughEffectType;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -27,7 +28,13 @@ public class UntapSourceCost extends CostImpl {
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
int stunCount = permanent.getCounters(game).getCount(CounterType.STUN);
paid = permanent.untap(game);
// 118.11 - if a stun counter replaces the untap, the cost has still been paid.
// Fear of Sleep Paralysis ruling - if the stun counter can't be removed, the untap cost hasn't been paid.
if (stunCount > 0) {
paid = permanent.getCounters(game).getCount(CounterType.STUN) < stunCount;
}
}
return paid;
}