forked from External/mage
[LTC] Implement Champions of Minas Tirith (#10726)
repurposed (and renamed) CantAttackYouEffect.java, that was actually not used.
This commit is contained in:
parent
9bff5000e0
commit
9979208f05
5 changed files with 141 additions and 22 deletions
|
|
@ -20,7 +20,7 @@ public class GenericManaCost extends ManaCostImpl {
|
|||
this.options.addMana(Mana.GenericMana(mana));
|
||||
}
|
||||
|
||||
public GenericManaCost(GenericManaCost manaCost) {
|
||||
protected GenericManaCost(GenericManaCost manaCost) {
|
||||
super(manaCost);
|
||||
this.mana = manaCost.mana;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,21 +30,25 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
}
|
||||
|
||||
public DoIfCostPaid(Effect effectOnPaid, Effect effectOnNotPaid, Cost cost, boolean optional) {
|
||||
this(effectOnPaid, cost, null, optional);
|
||||
if (effectOnNotPaid != null) {
|
||||
this.otherwiseEffects.add(effectOnNotPaid);
|
||||
}
|
||||
this(effectOnPaid, effectOnNotPaid, cost, null, optional);
|
||||
}
|
||||
|
||||
public DoIfCostPaid(Effect effectOnPaid, Cost cost, String chooseUseText) {
|
||||
this(effectOnPaid, cost, chooseUseText, true);
|
||||
this(effectOnPaid, null, cost, chooseUseText, true);
|
||||
}
|
||||
|
||||
public DoIfCostPaid(Effect effectOnPaid, Cost cost, String chooseUseText, boolean optional) {
|
||||
this(effectOnPaid, null, cost, chooseUseText, optional);
|
||||
}
|
||||
|
||||
public DoIfCostPaid(Effect effectOnPaid, Effect effectOnNotPaid, Cost cost, String chooseUseText, boolean optional) {
|
||||
super(Outcome.Benefit);
|
||||
if (effectOnPaid != null) {
|
||||
this.executingEffects.add(effectOnPaid);
|
||||
}
|
||||
if (effectOnNotPaid != null) {
|
||||
this.otherwiseEffects.add(effectOnNotPaid);
|
||||
}
|
||||
this.cost = cost;
|
||||
this.chooseUseText = chooseUseText;
|
||||
this.optional = optional;
|
||||
|
|
@ -149,7 +153,7 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
public Cost getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -1,45 +1,44 @@
|
|||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class CantAttackYouEffect extends RestrictionEffect {
|
||||
import java.util.UUID;
|
||||
|
||||
public CantAttackYouEffect(Duration duration) {
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class TargetPlayerCantAttackYouEffect extends RestrictionEffect {
|
||||
|
||||
public TargetPlayerCantAttackYouEffect(Duration duration) {
|
||||
super(duration);
|
||||
}
|
||||
|
||||
protected CantAttackYouEffect(final CantAttackYouEffect effect) {
|
||||
protected TargetPlayerCantAttackYouEffect(final TargetPlayerCantAttackYouEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantAttackYouEffect copy() {
|
||||
return new CantAttackYouEffect(this);
|
||||
public TargetPlayerCantAttackYouEffect copy() {
|
||||
return new TargetPlayerCantAttackYouEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return this.getTargetPointer().getTargets(game, source).contains(permanent.getId());
|
||||
return this.getTargetPointer().getTargets(game, source).contains(permanent.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
|
||||
if (defenderId == null
|
||||
|| game.getState().getPlayersInRange(attacker.getControllerId(), game).size() == 2) { // just 2 players left, so it may attack you
|
||||
if (defenderId == null) {
|
||||
return true;
|
||||
}
|
||||
// A planeswalker controlled by the controller is the defender
|
||||
// A planeswalker/battle controlled by the defender, not affected by the effect
|
||||
if (game.getPermanent(defenderId) != null) {
|
||||
return !game.getPermanent(defenderId).getControllerId().equals(source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
// The controller is the defender
|
||||
return !defenderId.equals(source.getControllerId());
|
||||
Loading…
Add table
Add a link
Reference in a new issue