forked from External/mage
Implement [BOT] Optimus Prime; adjust Bolster effect (#10129)
* Added implementation for Optimus Prime * Added setCardName text and switch case for activateAlternateOrAdditionalCosts as disturb instead of default * Fixed doubling effect bug * Add only regular card number * Added back alternate card for Optimus Prime and fixed Autobot Leader colors * Convert before return from graveyard * Convert before return from graveyard * Fix images * Resolve conflict with master * don't manually set trigger phrase * add additional effect capability to BolsterEffect, adjust text, flatten logic * adjust Optimus Prime, Hero * reimplement Optimus Prime, Autobot Leader * add test --------- Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
This commit is contained in:
parent
e26bcd0bf5
commit
77d0d3c07e
6 changed files with 346 additions and 40 deletions
|
|
@ -430,7 +430,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (this instanceof SpellAbility) {
|
||||
// A player can't apply two alternative methods of casting or two alternative costs to a single spell.
|
||||
switch (((SpellAbility) this).getSpellAbilityCastMode()) {
|
||||
|
||||
case FLASHBACK:
|
||||
case MADNESS:
|
||||
case TRANSFORMED:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ package mage.abilities.effects.keyword;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.constants.ComparisonType;
|
||||
|
|
@ -19,6 +21,7 @@ import mage.players.Player;
|
|||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
|
@ -27,6 +30,8 @@ public class BolsterEffect extends OneShotEffect {
|
|||
|
||||
private final DynamicValue amount;
|
||||
|
||||
private Effects additionalEffects = new Effects();
|
||||
|
||||
public BolsterEffect(int amount) {
|
||||
this(StaticValue.get(amount));
|
||||
}
|
||||
|
|
@ -40,6 +45,7 @@ public class BolsterEffect extends OneShotEffect {
|
|||
protected BolsterEffect(final BolsterEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
this.additionalEffects = effect.additionalEffects.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -47,55 +53,72 @@ public class BolsterEffect extends OneShotEffect {
|
|||
return new BolsterEffect(this);
|
||||
}
|
||||
|
||||
// Text must be set manually
|
||||
public BolsterEffect withAdditionalEffect(Effect effect) {
|
||||
additionalEffects.add(effect);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (amount.calculate(game, source, this) <= 0) {
|
||||
return true;
|
||||
}
|
||||
int leastToughness = Integer.MAX_VALUE;
|
||||
Permanent selectedCreature = null;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
|
||||
if (leastToughness > permanent.getToughness().getValue()) {
|
||||
leastToughness = permanent.getToughness().getValue();
|
||||
selectedCreature = permanent;
|
||||
} else if (leastToughness == permanent.getToughness().getValue()) {
|
||||
leastToughness = permanent.getToughness().getValue();
|
||||
selectedCreature = null;
|
||||
}
|
||||
}
|
||||
if (leastToughness != Integer.MAX_VALUE) {
|
||||
if (selectedCreature == null) {
|
||||
FilterPermanent filter = new FilterControlledCreaturePermanent("creature you control with toughness " + leastToughness);
|
||||
filter.add(new ToughnessPredicate(ComparisonType.EQUAL_TO, leastToughness));
|
||||
Target target = new TargetPermanent(1, 1, filter, true);
|
||||
if (controller.chooseTarget(outcome, target, source, game)) {
|
||||
selectedCreature = game.getPermanent(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
if (selectedCreature != null) {
|
||||
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(amount.calculate(game, source, this)));
|
||||
effect.setTargetPointer(new FixedTarget(selectedCreature, game));
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
if (amount.calculate(game, source, this) <= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
int leastToughness = Integer.MAX_VALUE;
|
||||
Permanent selectedCreature = null;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
|
||||
if (leastToughness > permanent.getToughness().getValue()) {
|
||||
leastToughness = permanent.getToughness().getValue();
|
||||
selectedCreature = permanent; // automatically select if only one
|
||||
} else if (leastToughness == permanent.getToughness().getValue()) {
|
||||
leastToughness = permanent.getToughness().getValue();
|
||||
selectedCreature = null; // more than one so need to manually select
|
||||
}
|
||||
}
|
||||
if (leastToughness == Integer.MAX_VALUE) {
|
||||
return false; // no creature found
|
||||
}
|
||||
if (selectedCreature == null) {
|
||||
FilterPermanent filter = new FilterControlledCreaturePermanent("creature you control with toughness " + leastToughness);
|
||||
filter.add(new ToughnessPredicate(ComparisonType.EQUAL_TO, leastToughness));
|
||||
Target target = new TargetPermanent(1, 1, filter, true);
|
||||
if (controller.chooseTarget(outcome, target, source, game)) {
|
||||
selectedCreature = game.getPermanent(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
if (selectedCreature == null) {
|
||||
return false;
|
||||
}
|
||||
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(amount.calculate(game, source, this)));
|
||||
FixedTarget fixedTarget = new FixedTarget(selectedCreature, game);
|
||||
effect.setTargetPointer(fixedTarget);
|
||||
effect.apply(game, source);
|
||||
if (!additionalEffects.isEmpty()) {
|
||||
for (Effect additionalEffect : additionalEffects) {
|
||||
additionalEffect.setTargetPointer(fixedTarget);
|
||||
if (additionalEffect instanceof OneShotEffect) {
|
||||
additionalEffect.apply(game, source);
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) additionalEffect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("bolster ");
|
||||
if (amount instanceof StaticValue) {
|
||||
sb.append(amount);
|
||||
sb.append(". <i>(Choose a creature with the least toughness or tied with the least toughness among creatures you control. Put ");
|
||||
sb.append(amount).append(" +1/+1 counters on it.)</i>");
|
||||
int number = ((StaticValue) amount).getValue();
|
||||
return "bolster " + number
|
||||
+". <i>(Choose a creature with the least toughness among creatures you control and put "
|
||||
+ CardUtil.numberToText(number, "a") + " +1/+1 counter" + (number == 1 ? "" : "s") + " on it.)</i>";
|
||||
} else {
|
||||
sb.append("X, where X is the number of ");
|
||||
sb.append(amount.getMessage());
|
||||
sb.append(". (Choose a creature with the least toughness among creatures you control and put X +1/+1 counters on it.)");
|
||||
return "bolster X, where X is the number of " + amount.getMessage()
|
||||
+ ". <i>(Choose a creature with the least toughness among creatures you control and put X +1/+1 counters on it.)</i>";
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue