mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Fix Heat Stroke
This commit is contained in:
parent
9eeebcd3d3
commit
c78cbc40eb
3 changed files with 119 additions and 11 deletions
|
@ -1,35 +1,46 @@
|
|||
|
||||
package mage.cards.h;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EndOfCombatTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DestroyAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.BlockedPredicate;
|
||||
import mage.filter.predicate.permanent.BlockingPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.BlockedThisTurnWatcher;
|
||||
import mage.watchers.common.WasBlockedThisTurnWatcher;
|
||||
|
||||
/**
|
||||
* @author dustinroepsch
|
||||
*/
|
||||
public final class HeatStroke extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(new BlockedPredicate(), new BlockingPredicate()));
|
||||
}
|
||||
|
||||
public HeatStroke(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}");
|
||||
|
||||
// At end of combat, destroy each creature that blocked or was blocked this turn.
|
||||
this.addAbility(new EndOfCombatTriggeredAbility(new DestroyAllEffect(filter)
|
||||
.setText("destroy each creature that blocked or was blocked this turn"), false));
|
||||
Ability ability = new EndOfCombatTriggeredAbility(new HeatStrokeEffect(), false);
|
||||
ability.addWatcher(new BlockedThisTurnWatcher());
|
||||
ability.addWatcher(new WasBlockedThisTurnWatcher());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public HeatStroke(final HeatStroke card) {
|
||||
|
@ -41,3 +52,44 @@ public final class HeatStroke extends CardImpl {
|
|||
return new HeatStroke(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HeatStrokeEffect extends OneShotEffect {
|
||||
|
||||
public HeatStrokeEffect() {
|
||||
super(Outcome.DestroyPermanent);
|
||||
this.staticText = "destroy each creature that blocked or was blocked this turn";
|
||||
}
|
||||
|
||||
public HeatStrokeEffect(HeatStrokeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
BlockedThisTurnWatcher blockedWatcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName());
|
||||
WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName());
|
||||
boolean toRet = false;
|
||||
Set<MageObjectReference> toDestroy = new HashSet<>();
|
||||
|
||||
if (blockedWatcher != null){
|
||||
toDestroy.addAll(blockedWatcher.getBlockedThisTurnCreatures());
|
||||
}
|
||||
if (wasBlockedThisTurnWatcher != null){
|
||||
toDestroy.addAll(wasBlockedThisTurnWatcher.getWasBlockedThisTurnCreatures());
|
||||
}
|
||||
|
||||
for (MageObjectReference mor : toDestroy) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null && permanent.isCreature()){
|
||||
permanent.destroy(source.getSourceId(), game, false);
|
||||
toRet = true;
|
||||
}
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeatStrokeEffect copy() {
|
||||
return new HeatStrokeEffect(this);
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.watchers.common.BlockedAttackerWatcher;
|
||||
|
||||
/**
|
||||
|
@ -61,10 +62,10 @@ public final class JovensFerrets extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class JovensFerretsEffect extends DontUntapInControllersNextUntapStepTargetEffect {
|
||||
class JovensFerretsEffect extends OneShotEffect {
|
||||
|
||||
public JovensFerretsEffect() {
|
||||
super();
|
||||
super(Outcome.Benefit);
|
||||
}
|
||||
|
||||
public JovensFerretsEffect(final JovensFerretsEffect effect) {
|
||||
|
@ -93,7 +94,9 @@ class JovensFerretsEffect extends DontUntapInControllersNextUntapStepTargetEffec
|
|||
}
|
||||
for (Permanent creature : toTap) {
|
||||
creature.tap(game);
|
||||
getTargetPointer().getTargets(game, source).add(creature.getId());
|
||||
DontUntapInControllersNextUntapStepTargetEffect effect = new DontUntapInControllersNextUntapStepTargetEffect();
|
||||
effect.setTargetPointer(new FixedTarget(creature.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
package mage.watchers.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public class WasBlockedThisTurnWatcher extends Watcher {
|
||||
|
||||
private final Set<MageObjectReference> wasBlockedThisTurnCreatures;
|
||||
|
||||
public WasBlockedThisTurnWatcher() {
|
||||
super(WasBlockedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
|
||||
wasBlockedThisTurnCreatures = new HashSet<>();
|
||||
}
|
||||
|
||||
public WasBlockedThisTurnWatcher(final WasBlockedThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
wasBlockedThisTurnCreatures = new HashSet<>(watcher.wasBlockedThisTurnCreatures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Watcher copy() {
|
||||
return new WasBlockedThisTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
|
||||
this.wasBlockedThisTurnCreatures.add(new MageObjectReference(event.getTargetId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<MageObjectReference> getWasBlockedThisTurnCreatures() {
|
||||
return this.wasBlockedThisTurnCreatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
wasBlockedThisTurnCreatures.clear();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue