mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
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:
parent
044e8b70f0
commit
21061ac928
8 changed files with 62 additions and 82 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue