mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
refactor: standardize to CantAttackYouAllEffect (#10923)
* adjust CantAttackYouAllEffect text, check permanent is planeswalker * switch 3 cards to main class, remove redundant class
This commit is contained in:
parent
77d0d3c07e
commit
035913988a
5 changed files with 16 additions and 85 deletions
|
|
@ -32,11 +32,11 @@ public class CantAttackYouAllEffect extends RestrictionEffect {
|
|||
this.filterAttacker = filter;
|
||||
this.alsoPlaneswalker = alsoPlaneswalker;
|
||||
staticText = filterAttacker.getMessage() + " can't attack you"
|
||||
+ (alsoPlaneswalker ? " or a planeswalker you control" : "")
|
||||
+ (alsoPlaneswalker ? " or planeswalkers you control" : "")
|
||||
+ (duration == Duration.UntilYourNextTurn || duration == Duration.UntilEndOfYourNextTurn ? " " + duration.toString() : "");
|
||||
}
|
||||
|
||||
CantAttackYouAllEffect(final CantAttackYouAllEffect effect) {
|
||||
protected CantAttackYouAllEffect(final CantAttackYouAllEffect effect) {
|
||||
super(effect);
|
||||
this.filterAttacker = effect.filterAttacker;
|
||||
this.alsoPlaneswalker = effect.alsoPlaneswalker;
|
||||
|
|
@ -54,7 +54,7 @@ public class CantAttackYouAllEffect extends RestrictionEffect {
|
|||
}
|
||||
if (alsoPlaneswalker) {
|
||||
Permanent planeswalker = game.getPermanent(defenderId);
|
||||
if (planeswalker != null) {
|
||||
if (planeswalker != null && planeswalker.isPlaneswalker(game)) {
|
||||
defenderId = planeswalker.getControllerId();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author fireshoes
|
||||
*/
|
||||
public class CantAttackYouOrPlaneswalkerAllEffect extends RestrictionEffect {
|
||||
|
||||
private final FilterCreaturePermanent filterAttacker;
|
||||
|
||||
public CantAttackYouOrPlaneswalkerAllEffect(Duration duration) {
|
||||
this(duration, new FilterCreaturePermanent());
|
||||
}
|
||||
|
||||
public CantAttackYouOrPlaneswalkerAllEffect(Duration duration, FilterCreaturePermanent filter) {
|
||||
super(duration, Outcome.Benefit);
|
||||
this.filterAttacker = filter;
|
||||
staticText = "Creatures can't attack you";
|
||||
}
|
||||
|
||||
CantAttackYouOrPlaneswalkerAllEffect(final CantAttackYouOrPlaneswalkerAllEffect effect) {
|
||||
super(effect);
|
||||
this.filterAttacker = effect.filterAttacker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return filterAttacker.match(permanent, source.getControllerId(), source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
|
||||
if (defenderId == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (defenderId.equals(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
Permanent planeswalker = game.getPermanent(defenderId);
|
||||
return planeswalker == null || !planeswalker.isControlledBy(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantAttackYouOrPlaneswalkerAllEffect copy() {
|
||||
return new CantAttackYouOrPlaneswalkerAllEffect(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue