[AFC] Implemented Hellish Rebuke

This commit is contained in:
Evan Kranzler 2021-08-21 11:20:16 -04:00
parent 898f8ca287
commit d20b15c7b6
3 changed files with 140 additions and 0 deletions

View file

@ -1,6 +1,8 @@
package mage.watchers.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.cards.Card;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.filter.StaticFilters;
@ -68,4 +70,18 @@ public class SpellsCastWatcher extends Watcher {
public int getNumberOfNonCreatureSpells() {
return nonCreatureSpells;
}
public UUID getCasterId(Ability source, Game game) {
for (Map.Entry<UUID, List<Spell>> entry : spellsCast.entrySet()) {
if (entry.getValue()
.stream()
.map(Spell::getCard)
.map(Card::getMainCard)
.anyMatch(card -> card.getId().equals(source.getSourceId())
&& card.getZoneChangeCounter(game) == source.getSourceObjectZoneChangeCounter())) {
return entry.getKey();
}
}
return null;
}
}