Fixed some attack forcing cards to only force to attack once a turn instead of wrongly forcing to attack each combat.

This commit is contained in:
LevelX2 2015-09-24 08:25:45 +02:00
parent 044e8b70f0
commit 21061ac928
8 changed files with 62 additions and 82 deletions

View file

@ -40,6 +40,7 @@ import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.watchers.common.AttackedThisTurnWatcher;
/**
*
@ -63,7 +64,7 @@ public class FumikoTheLowblood extends CardImpl {
// Creatures your opponents control attack each turn if able.
FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures your opponents control");
filter.add(new ControllerPredicate(TargetController.OPPONENT));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AttacksIfAbleAllEffect(filter)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AttacksIfAbleAllEffect(filter)), new AttackedThisTurnWatcher());
}

View file

@ -41,6 +41,7 @@ import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.watchers.common.AttackedThisTurnWatcher;
/**
*
@ -62,7 +63,7 @@ public class AvatarOfSlaughter extends CardImpl {
effect = new AttacksIfAbleAllEffect(new FilterCreaturePermanent("creatures"));
effect.setText("and attack each turn if able");
ability.addEffect(effect);
this.addAbility(ability);
this.addAbility(ability, new AttackedThisTurnWatcher());
}
public AvatarOfSlaughter(final AvatarOfSlaughter card) {

View file

@ -62,7 +62,7 @@ public class WarmongerHellkite extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// All creatures attack each combat if able.
Effect effect = new AttacksIfAbleAllEffect(new FilterCreaturePermanent("creatures"));
Effect effect = new AttacksIfAbleAllEffect(new FilterCreaturePermanent("creatures"), Duration.WhileOnBattlefield, true);
effect.setText("All creatures attack each combat if able");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));

View file

@ -50,6 +50,7 @@ import mage.filter.predicate.permanent.AnotherPredicate;
import mage.filter.predicate.permanent.AttackingPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.permanent.token.Token;
import mage.watchers.common.AttackedThisTurnWatcher;
/**
*
@ -59,15 +60,15 @@ public class GoblinRabblemaster extends CardImpl {
private static final FilterCreaturePermanent otherGoblinFilter = new FilterCreaturePermanent("Goblin", "Other Goblin creatures you control");
private static final FilterCreaturePermanent attackingFilter = new FilterCreaturePermanent("Goblin", "other attacking Goblin");
static {
otherGoblinFilter.add(new AnotherPredicate());
otherGoblinFilter.add(new ControllerPredicate(TargetController.YOU));
attackingFilter.add(new AttackingPredicate());
attackingFilter.add(new AnotherPredicate());
}
public GoblinRabblemaster(UUID ownerId) {
super(ownerId, 145, "Goblin Rabblemaster", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.expansionSetCode = "M15";
@ -79,11 +80,11 @@ public class GoblinRabblemaster extends CardImpl {
// Other Goblin creatures you control attack each turn if able.
Effect effect = new AttacksIfAbleAllEffect(otherGoblinFilter);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect), new AttackedThisTurnWatcher());
// At the beginning of combat on your turn, put a 1/1 red Goblin creature token with haste onto the battlefield.
this.addAbility(new BeginningOfCombatTriggeredAbility(new CreateTokenEffect(new GoblinToken()), TargetController.YOU, false));
// When Goblin Rabblemaster attacks, it gets +1/+0 until end of turn for each other attacking Goblin.
this.addAbility(new AttacksTriggeredAbility(new BoostSourceEffect(new PermanentsOnBattlefieldCount(attackingFilter), new StaticValue(0), Duration.EndOfTurn, true), false));
}
@ -110,5 +111,5 @@ class GoblinToken extends Token {
toughness = new MageInt(1);
addAbility(HasteAbility.getInstance());
}
}

View file

@ -48,18 +48,19 @@ import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.watchers.common.AttackedThisTurnWatcher;
/**
*
* @author fireshoes
*/
public class InciteWar extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
}
}
public InciteWar(UUID ownerId) {
super(ownerId, 96, "Incite War", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{R}");
@ -68,12 +69,13 @@ public class InciteWar extends CardImpl {
// Choose one - Creatures target player controls attack this turn if able;
this.getSpellAbility().addEffect(new InciteWarMustAttackEffect());
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addWatcher(new AttackedThisTurnWatcher());
// or creatures you control gain first strike until end of turn.
Mode mode = new Mode();
mode.getEffects().add(new GainAbilityAllEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, filter));
this.getSpellAbility().getModes().addMode(mode);
// Entwine {2}
this.addAbility(new EntwineAbility("{2}"));
}
@ -91,7 +93,7 @@ public class InciteWar extends CardImpl {
class InciteWarMustAttackEffect extends OneShotEffect {
public InciteWarMustAttackEffect() {
super(Outcome.Detriment);
super(Outcome.Detriment);
staticText = "Creatures target player control attack this turn if able";
}
@ -116,4 +118,4 @@ class InciteWarMustAttackEffect extends OneShotEffect {
}
return false;
}
}
}

View file

@ -28,22 +28,22 @@
package mage.sets.shardsofalara;
import java.util.UUID;
import mage.constants.*;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.RequirementEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.combat.AttacksIfAbleAllEffect;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.watchers.common.AttackedThisTurnWatcher;
/**
*
@ -51,15 +51,21 @@ import mage.game.permanent.token.Token;
*/
public class GoblinAssault extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Goblin creatures");
static {
filter.add(new SubtypePredicate("Goblin"));
}
public GoblinAssault(UUID ownerId) {
super(ownerId, 101, "Goblin Assault", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}");
this.expansionSetCode = "ALA";
// At the beginning of your upkeep, put a 1/1 red Goblin creature token with haste onto the battlefield.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new CreateTokenEffect(new GoblinAssaultToken()), TargetController.YOU, false));
// Goblin creatures attack each turn if able.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GoblinAssaultEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AttacksIfAbleAllEffect(filter, Duration.WhileOnBattlefield)), new AttackedThisTurnWatcher());
}
public GoblinAssault(final GoblinAssault card) {
@ -72,48 +78,6 @@ public class GoblinAssault extends CardImpl {
}
}
class GoblinAssaultEffect extends RequirementEffect {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Goblin creatures");
static {
filter.add(new SubtypePredicate("Goblin"));
}
public GoblinAssaultEffect() {
super(Duration.WhileOnBattlefield);
staticText = "Goblin creatures attack each turn if able";
}
public GoblinAssaultEffect(final GoblinAssaultEffect effect) {
super(effect);
}
@Override
public GoblinAssaultEffect copy() {
return new GoblinAssaultEffect(this);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
return true;
}
return false;
}
@Override
public boolean mustAttack(Game game) {
return true;
}
@Override
public boolean mustBlock(Game game) {
return false;
}
}
class GoblinAssaultToken extends Token {
public GoblinAssaultToken() {

View file

@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -12,6 +11,7 @@ import mage.constants.Duration;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.watchers.common.AttackedThisTurnWatcher;
/**
*
@ -24,19 +24,28 @@ public class AttacksIfAbleAllEffect extends RequirementEffect {
public AttacksIfAbleAllEffect(FilterCreaturePermanent filter) {
this(filter, Duration.WhileOnBattlefield);
}
boolean eachCombat;
public AttacksIfAbleAllEffect(FilterCreaturePermanent filter, Duration duration) {
this(filter, duration, false);
}
public AttacksIfAbleAllEffect(FilterCreaturePermanent filter, Duration duration, boolean eachCombat) {
super(duration);
staticText = new StringBuilder(filter.getMessage())
.append(" attack ")
.append(duration.equals(Duration.EndOfTurn) ? "this":"each")
.append(" turn if able").toString();
this.filter = filter;
this.eachCombat = eachCombat;
if (this.duration == Duration.EndOfTurn) {
staticText = filter.getMessage() + " attack " + (eachCombat ? "each combat" : "this turn") + " if able";
} else {
staticText = filter.getMessage() + " attack each " + (eachCombat ? "combat" : "turn") + " if able";
}
}
public AttacksIfAbleAllEffect(final AttacksIfAbleAllEffect effect) {
super(effect);
this.filter = effect.filter;
this.eachCombat = effect.eachCombat;
}
@Override
@ -46,7 +55,14 @@ public class AttacksIfAbleAllEffect extends RequirementEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
if (eachCombat) {
return true;
}
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(permanent.getId());
}
return false;
}
@Override

View file

@ -25,13 +25,12 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common.combat;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.RequirementEffect;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -56,10 +55,7 @@ public class AttacksIfAbleTargetEffect extends RequirementEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (this.getTargetPointer().getTargets(game, source).contains(permanent.getId())) {
return true;
}
return false;
return this.getTargetPointer().getTargets(game, source).contains(permanent.getId());
}
@Override
@ -79,8 +75,7 @@ public class AttacksIfAbleTargetEffect extends RequirementEffect {
}
if (this.duration == Duration.EndOfTurn) {
return new StringBuilder("Target ").append(mode.getTargets().get(0).getTargetName()).append(" attacks this turn if able").toString();
}
else {
} else {
return new StringBuilder("Target ").append(mode.getTargets().get(0).getTargetName()).append(" attacks each turn if able").toString();
}
}