mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
[AER] Fixed Daredevil Dragster.
This commit is contained in:
parent
9353c5aa9c
commit
491ab5fbb0
6 changed files with 147 additions and 145 deletions
|
@ -30,30 +30,29 @@ package mage.cards.c;
|
|||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
|
||||
import mage.abilities.common.EndOfCombatTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
||||
import mage.abilities.condition.common.AttackedOrBlockedThisCombatSourceCondition;
|
||||
import mage.abilities.condition.common.IsStepCondition;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.decorator.ConditionalActivatedAbility;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,7 +61,7 @@ import mage.game.permanent.Permanent;
|
|||
public class ClockworkAvian extends CardImpl {
|
||||
|
||||
public ClockworkAvian(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{5}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}");
|
||||
this.subtype.add("Bird");
|
||||
this.power = new MageInt(0);
|
||||
this.toughness = new MageInt(4);
|
||||
|
@ -71,10 +70,16 @@ public class ClockworkAvian extends CardImpl {
|
|||
this.addAbility(FlyingAbility.getInstance());
|
||||
// Clockwork Avian enters the battlefield with four +1/+0 counters on it.
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P0.createInstance(4)), "{this} enters the battlefield with four +1/+0 counters on it"));
|
||||
|
||||
// At end of combat, if Clockwork Avian attacked or blocked this combat, remove a +1/+0 counter from it.
|
||||
this.addAbility(new AttacksOrBlocksTriggeredAbility(new ClockworkAvianEffect(), false));
|
||||
this.addAbility(new ConditionalTriggeredAbility(
|
||||
new EndOfCombatTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P0.createInstance()), false),
|
||||
new AttackedOrBlockedThisCombatSourceCondition(),
|
||||
"At end of combat, if {this} attacked or blocked this combat, remove a +1/+0 counter from it."),
|
||||
new AttackedOrBlockedThisCombatWatcher());
|
||||
|
||||
// {X}, {tap}: Put up to X +1/+0 counters on Clockwork Avian. This ability can't cause the total number of +1/+0 counters on Clockwork Avian to be greater than four. Activate this ability only during your upkeep.
|
||||
Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD,
|
||||
Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD,
|
||||
new AvianAddCountersSourceEffect(CounterType.P1P0.createInstance(), new ManacostVariableValue(), true, true), new ManaCostsImpl("{X}"), new IsStepCondition(PhaseStep.UPKEEP), null);
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
@ -92,48 +97,21 @@ public class ClockworkAvian extends CardImpl {
|
|||
|
||||
class AvianAddCountersSourceEffect extends AddCountersSourceEffect {
|
||||
|
||||
public AvianAddCountersSourceEffect (Counter counter, DynamicValue amount, boolean informPlayers, boolean putOnCard){
|
||||
super(counter, amount, informPlayers, putOnCard);
|
||||
public AvianAddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers, boolean putOnCard) {
|
||||
super(counter, amount, informPlayers, putOnCard);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
//record how many counters
|
||||
Counters permCounters = game.getPermanent(source.getSourceId()).getCounters(game);
|
||||
int countersWas = permCounters.getCount(CounterType.P1P0);
|
||||
if (countersWas < 4){
|
||||
super.apply(game, source);
|
||||
if (permCounters.getCount(CounterType.P1P0)>4){
|
||||
permCounters.removeCounter(CounterType.P1P0, permCounters.getCount(CounterType.P1P0)-4);
|
||||
}//if countersWas < 4 then counter is min(current,4); there is no setCounters function tho
|
||||
}//else this is a rare case of an Avian getting boosted by outside sources :) Which is the sole purpose of this if, for the benefit of this rare but not impossible case :p
|
||||
if (countersWas < 4) {
|
||||
super.apply(game, source);
|
||||
if (permCounters.getCount(CounterType.P1P0) > 4) {
|
||||
permCounters.removeCounter(CounterType.P1P0, permCounters.getCount(CounterType.P1P0) - 4);
|
||||
}//if countersWas < 4 then counter is min(current,4); there is no setCounters function tho
|
||||
}//else this is a rare case of an Avian getting boosted by outside sources :) Which is the sole purpose of this if, for the benefit of this rare but not impossible case :p
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class ClockworkAvianEffect extends OneShotEffect {
|
||||
|
||||
ClockworkAvianEffect() {
|
||||
super(Outcome.UnboostCreature);
|
||||
staticText = "remove a +1/+0 counter from {this} at end of combat";
|
||||
}
|
||||
|
||||
ClockworkAvianEffect(final ClockworkAvianEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P0.createInstance()));
|
||||
game.addDelayedTriggeredAbility(ability, source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClockworkAvianEffect copy() {
|
||||
return new ClockworkAvianEffect(this);
|
||||
}
|
||||
}
|
|
@ -30,29 +30,28 @@ package mage.cards.c;
|
|||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
|
||||
import mage.abilities.common.EndOfCombatTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
||||
import mage.abilities.condition.common.AttackedOrBlockedThisCombatSourceCondition;
|
||||
import mage.abilities.condition.common.IsStepCondition;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.decorator.ConditionalActivatedAbility;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -61,19 +60,23 @@ import mage.game.permanent.Permanent;
|
|||
public class ClockworkBeast extends CardImpl {
|
||||
|
||||
public ClockworkBeast(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{6}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}");
|
||||
this.subtype.add("Beast");
|
||||
this.power = new MageInt(0);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// Clockwork Beast enters the battlefield with seven +1/+0 counters on it.
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P0.createInstance(7)), "{this} enters the battlefield with seven +1/+0 counters on it"));
|
||||
|
||||
|
||||
// At end of combat, if Clockwork Beast attacked or blocked this combat, remove a +1/+0 counter from it.
|
||||
this.addAbility(new AttacksOrBlocksTriggeredAbility(new ClockworkBeastEffect(), false));
|
||||
|
||||
this.addAbility(new ConditionalTriggeredAbility(
|
||||
new EndOfCombatTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P0.createInstance()), false),
|
||||
new AttackedOrBlockedThisCombatSourceCondition(),
|
||||
"At end of combat, if {this} attacked or blocked this combat, remove a +1/+0 counter from it."),
|
||||
new AttackedOrBlockedThisCombatWatcher());
|
||||
|
||||
// {X}, {tap}: Put up to X +1/+0 counters on Clockwork Beast. This ability can't cause the total number of +1/+0 counters on Clockwork Beast to be greater than seven. Activate this ability only during your upkeep.
|
||||
Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD,
|
||||
Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD,
|
||||
new BeastAddCountersSourceEffect(CounterType.P1P0.createInstance(), new ManacostVariableValue(), true, true), new ManaCostsImpl("{X}"), new IsStepCondition(PhaseStep.UPKEEP), null);
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
@ -89,49 +92,31 @@ public class ClockworkBeast extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class ClockworkBeastEffect extends OneShotEffect {
|
||||
|
||||
ClockworkBeastEffect() {
|
||||
super(Outcome.UnboostCreature);
|
||||
staticText = "remove a +1/+0 counter from {this} at end of combat";
|
||||
}
|
||||
|
||||
ClockworkBeastEffect(final ClockworkBeastEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P0.createInstance()));
|
||||
game.addDelayedTriggeredAbility(ability, source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClockworkBeastEffect copy() {
|
||||
return new ClockworkBeastEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BeastAddCountersSourceEffect extends AddCountersSourceEffect {
|
||||
|
||||
public BeastAddCountersSourceEffect (Counter counter, DynamicValue amount, boolean informPlayers, boolean putOnCard){
|
||||
super(counter, amount, informPlayers, putOnCard);
|
||||
public BeastAddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers, boolean putOnCard) {
|
||||
super(counter, amount, informPlayers, putOnCard);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Counters permCounters = game.getPermanent(source.getSourceId()).getCounters(game);
|
||||
int countersWas = permCounters.getCount(CounterType.P1P0);
|
||||
if (countersWas < 7){
|
||||
super.apply(game, source);
|
||||
if (permCounters.getCount(CounterType.P1P0) > 7){
|
||||
if (countersWas < 7) {
|
||||
super.apply(game, source);
|
||||
if (permCounters.getCount(CounterType.P1P0) > 7) {
|
||||
permCounters.removeCounter(CounterType.P1P0, permCounters.getCount(CounterType.P1P0) - 7);
|
||||
}//if countersWas < 7 then counter is min(current,7); there is no setCounters function though
|
||||
}//else this is a rare case of a Beast getting boosted by outside sources. Which is the sole purpose of this if, for the benefit of this rare but not impossible case
|
||||
}//else this is a rare case of a Beast getting boosted by outside sources. Which is the sole purpose of this if, for the benefit of this rare but not impossible case
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public BeastAddCountersSourceEffect(final BeastAddCountersSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeastAddCountersSourceEffect copy() {
|
||||
return new BeastAddCountersSourceEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,9 @@ package mage.cards.d;
|
|||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksOrBlocksTriggeredAbility;
|
||||
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
||||
import mage.abilities.common.EndOfCombatTriggeredAbility;
|
||||
import mage.abilities.condition.common.AttackedOrBlockedThisCombatSourceCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.CrewAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -42,6 +43,7 @@ import mage.counters.CounterType;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,7 +59,11 @@ public class DaredevilDragster extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// At end of combat, if Daredevil Dragster attacked or blocked this combat, put a velocity counter on it. Then if it has two or more velocity counters on it, sacrifice it and draw two cards.
|
||||
this.addAbility(new AttacksOrBlocksTriggeredAbility(new DaredevilDragsterEffect(), false));
|
||||
this.addAbility(new ConditionalTriggeredAbility(
|
||||
new EndOfCombatTriggeredAbility(new DaredevilDragsterEffect(), false),
|
||||
new AttackedOrBlockedThisCombatSourceCondition(),
|
||||
"At end of combat, if {this} attacked or blocked this combat, put a velocity counter on it. Then if it has two or more velocity counters on it, sacrifice it and draw two cards."),
|
||||
new AttackedOrBlockedThisCombatWatcher());
|
||||
|
||||
// Crew 2
|
||||
this.addAbility(new CrewAbility(2));
|
||||
|
@ -77,7 +83,7 @@ class DaredevilDragsterEffect extends OneShotEffect {
|
|||
|
||||
public DaredevilDragsterEffect() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "At end of combat, if {this} attacked or blocked this combat, put a velocity counter on it. Then if it has two or more velocity counters on it, sacrifice it and draw two cards";
|
||||
this.staticText = "put a velocity counter on it. Then if it has two or more velocity counters on it, sacrifice it and draw two cards";
|
||||
}
|
||||
|
||||
public DaredevilDragsterEffect(final DaredevilDragsterEffect effect) {
|
||||
|
@ -89,40 +95,13 @@ class DaredevilDragsterEffect extends OneShotEffect {
|
|||
return new DaredevilDragsterEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new DaredevilDragsterEffect2());
|
||||
game.addDelayedTriggeredAbility(ability, source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class DaredevilDragsterEffect2 extends OneShotEffect {
|
||||
|
||||
public DaredevilDragsterEffect2() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "put a velocity counter on it. Then if it has two or more velocity counters on it, sacrifice it and draw two cards";
|
||||
}
|
||||
|
||||
public DaredevilDragsterEffect2(final DaredevilDragsterEffect2 effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaredevilDragsterEffect2 copy() {
|
||||
return new DaredevilDragsterEffect2(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && permanent != null) {
|
||||
permanent.addCounters(CounterType.VELOCITY.createInstance(), source, game);
|
||||
if (permanent != null && permanent.getCounters(game).getCount(CounterType.VELOCITY) >= 2) {
|
||||
if (permanent.getCounters(game).getCount(CounterType.VELOCITY) >= 2) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
controller.drawCards(2, game);
|
||||
}
|
||||
|
|
|
@ -41,15 +41,15 @@ import mage.abilities.effects.common.ExileAndReturnTransformedSourceEffect.Gende
|
|||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
import mage.abilities.keyword.IndestructibleAbility;
|
||||
import mage.abilities.keyword.TransformAbility;
|
||||
import mage.cards.g.GideonBattleForged;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.g.GideonBattleForged;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.AttackedThisCombatWatcher;
|
||||
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -58,26 +58,26 @@ import mage.watchers.common.AttackedThisCombatWatcher;
|
|||
public class KytheonHeroOfAkros extends CardImpl {
|
||||
|
||||
public KytheonHeroOfAkros(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}");
|
||||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Human");
|
||||
this.subtype.add("Soldier");
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
|
||||
this.transformable = true;
|
||||
this.secondSideCardClazz = GideonBattleForged.class;
|
||||
|
||||
// At end of combat, if Kytheon, Hero of Akros and at least two other creatures attacked this combat, exile Kytheon,
|
||||
// At end of combat, if Kytheon, Hero of Akros and at least two other creatures attacked this combat, exile Kytheon,
|
||||
// then return him to the battlefield transformed under his owner's control.
|
||||
this.addAbility(new TransformAbility());
|
||||
this.addAbility(new ConditionalTriggeredAbility(new EndOfCombatTriggeredAbility(new ExileAndReturnTransformedSourceEffect(Gender.MALE), false),
|
||||
new KytheonHeroOfAkrosCondition(), "At end of combat, if {this} and at least two other creatures attacked this combat, exile {this}, " +
|
||||
"then return him to the battlefield transformed under his owner's control."), new AttackedThisCombatWatcher());
|
||||
|
||||
this.addAbility(new ConditionalTriggeredAbility(new EndOfCombatTriggeredAbility(new ExileAndReturnTransformedSourceEffect(Gender.MALE), false),
|
||||
new KytheonHeroOfAkrosCondition(), "At end of combat, if {this} and at least two other creatures attacked this combat, exile {this}, "
|
||||
+ "then return him to the battlefield transformed under his owner's control."), new AttackedOrBlockedThisCombatWatcher());
|
||||
|
||||
// {2}{W}: Kytheon gains indestructible until end of turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl<>("{2}{W}")));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public KytheonHeroOfAkros(final KytheonHeroOfAkros card) {
|
||||
|
@ -91,16 +91,16 @@ public class KytheonHeroOfAkros extends CardImpl {
|
|||
}
|
||||
|
||||
class KytheonHeroOfAkrosCondition implements Condition {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
if (sourceObject != null) {
|
||||
AttackedThisCombatWatcher watcher = (AttackedThisCombatWatcher) game.getState().getWatchers().get("AttackedThisCombat");
|
||||
AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getName());
|
||||
if (watcher != null) {
|
||||
boolean sourceFound = false;
|
||||
int number = 0;
|
||||
for (MageObjectReference mor: watcher.getAttackedThisTurnCreatures()) {
|
||||
for (MageObjectReference mor : watcher.getAttackedThisTurnCreatures()) {
|
||||
if (mor.refersTo(sourceObject, game)) {
|
||||
sourceFound = true;
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AttackedOrBlockedThisCombatSourceCondition implements Condition {
|
||||
|
||||
private static final AttackedOrBlockedThisCombatSourceCondition fInstance = new AttackedOrBlockedThisCombatSourceCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (sourceObject != null) {
|
||||
AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getName());
|
||||
if (watcher != null) {
|
||||
for (MageObjectReference mor : watcher.getAttackedThisTurnCreatures()) {
|
||||
if (mor.refersTo(sourceObject, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (MageObjectReference mor : watcher.getBlockedThisTurnCreatures()) {
|
||||
if (mor.refersTo(sourceObject, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{this} attacked or blocked this combat";
|
||||
}
|
||||
}
|
|
@ -17,37 +17,45 @@ import mage.watchers.Watcher;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class AttackedThisCombatWatcher extends Watcher {
|
||||
public class AttackedOrBlockedThisCombatWatcher extends Watcher {
|
||||
|
||||
public final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
|
||||
public final Set<MageObjectReference> blockedThisTurnCreatures = new HashSet<>();
|
||||
|
||||
public AttackedThisCombatWatcher() {
|
||||
super("AttackedThisCombat", WatcherScope.GAME);
|
||||
public AttackedOrBlockedThisCombatWatcher() {
|
||||
super(AttackedOrBlockedThisCombatWatcher.class.getName(), WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AttackedThisCombatWatcher(final AttackedThisCombatWatcher watcher) {
|
||||
public AttackedOrBlockedThisCombatWatcher(final AttackedOrBlockedThisCombatWatcher watcher) {
|
||||
super(watcher);
|
||||
this.attackedThisTurnCreatures.addAll(watcher.attackedThisTurnCreatures);
|
||||
this.blockedThisTurnCreatures.addAll(watcher.blockedThisTurnCreatures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGIN_COMBAT_STEP_PRE) {
|
||||
this.attackedThisTurnCreatures.clear();
|
||||
}
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
|
||||
this.attackedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(),game));
|
||||
this.attackedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
|
||||
this.blockedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<MageObjectReference> getAttackedThisTurnCreatures() {
|
||||
|
||||
public Set<MageObjectReference> getAttackedThisTurnCreatures() {
|
||||
return this.attackedThisTurnCreatures;
|
||||
}
|
||||
|
||||
public Set<MageObjectReference> getBlockedThisTurnCreatures() {
|
||||
return this.blockedThisTurnCreatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttackedThisCombatWatcher copy() {
|
||||
return new AttackedThisCombatWatcher(this);
|
||||
public AttackedOrBlockedThisCombatWatcher copy() {
|
||||
return new AttackedOrBlockedThisCombatWatcher(this);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue