mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 06:22:01 -08:00
* Minor fixes to Morph tootip generation. Minor changes to other framwork classes.
This commit is contained in:
parent
96fd7e1d85
commit
2aeb61b2e6
6 changed files with 40 additions and 31 deletions
|
|
@ -67,4 +67,10 @@ public class KickedCondition implements Condition {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{this} was kicked";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,22 +4,25 @@ import mage.MageObject;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
public class DoIfCostPaid extends OneShotEffect {
|
||||
private final OneShotEffect executingEffect;
|
||||
private final Effect executingEffect;
|
||||
private final Cost cost;
|
||||
private String chooseUseText;
|
||||
|
||||
public DoIfCostPaid(OneShotEffect effect, Cost cost) {
|
||||
public DoIfCostPaid(Effect effect, Cost cost) {
|
||||
this(effect, cost, null);
|
||||
}
|
||||
|
||||
public DoIfCostPaid(OneShotEffect effect, Cost cost, String chooseUseText) {
|
||||
public DoIfCostPaid(Effect effect, Cost cost, String chooseUseText) {
|
||||
super(Outcome.Benefit);
|
||||
this.executingEffect = effect;
|
||||
this.cost = cost;
|
||||
|
|
@ -28,7 +31,7 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
|
||||
public DoIfCostPaid(final DoIfCostPaid effect) {
|
||||
super(effect);
|
||||
this.executingEffect = (OneShotEffect) effect.executingEffect.copy();
|
||||
this.executingEffect = effect.executingEffect.copy();
|
||||
this.cost = effect.cost.copy();
|
||||
this.chooseUseText = effect.chooseUseText;
|
||||
}
|
||||
|
|
@ -49,7 +52,14 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
|
||||
executingEffect.setTargetPointer(this.targetPointer);
|
||||
return executingEffect.apply(game, source);
|
||||
if (executingEffect instanceof OneShotEffect) {
|
||||
if (!(executingEffect instanceof PostResolveEffect)) {
|
||||
return executingEffect.apply(game, source);
|
||||
}
|
||||
}
|
||||
else {
|
||||
game.addEffect((ContinuousEffect) executingEffect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public class TapSourceUnlessPaysEffect extends OneShotEffect {
|
|||
public TapSourceUnlessPaysEffect(Cost cost) {
|
||||
super(Outcome.Tap);
|
||||
this.cost = cost;
|
||||
staticText = "tap {this} unless you " + cost.getText();
|
||||
}
|
||||
|
||||
public TapSourceUnlessPaysEffect(final TapSourceUnlessPaysEffect effect) {
|
||||
|
|
@ -60,7 +61,7 @@ public class TapSourceUnlessPaysEffect extends OneShotEffect {
|
|||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
if (cost.canPay(source.getSourceId(), source.getControllerId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, cost.getText() + " or " + permanent.getName() + " comes into play tapped?", game)) {
|
||||
&& player.chooseUse(Outcome.Benefit, cost.getText() + "? (otherwise " + permanent.getName() + " becomes tapped)", game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import mage.abilities.costs.Cost;
|
|||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.CostsImpl;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.continious.SourceEffect;
|
||||
|
|
@ -103,7 +104,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
|
||||
protected static final String ABILITY_KEYWORD = "Morph";
|
||||
protected static final String REMINDER_TEXT = "(You may cast this face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.)";
|
||||
protected String morphCostsText;
|
||||
protected String ruleText;
|
||||
protected List<AlternativeCost2> alternateCosts = new LinkedList<>();
|
||||
|
||||
// needed to check activation status, if card changes zone after casting it
|
||||
|
|
@ -117,7 +118,15 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
super(Zone.HAND, null);
|
||||
card.setMorphCard(true);
|
||||
name = ABILITY_KEYWORD;
|
||||
morphCostsText = morphCosts.getText();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(ABILITY_KEYWORD).append(" ");
|
||||
if (!(morphCosts instanceof ManaCosts)) {
|
||||
sb.append("- ");
|
||||
}
|
||||
sb.append(morphCosts.getText()).append(" ");
|
||||
sb.append(REMINDER_TEXT);
|
||||
ruleText = sb.toString();
|
||||
|
||||
alternateCosts.add(new AlternativeCost2Impl(ABILITY_KEYWORD, REMINDER_TEXT, new GenericManaCost(3)));
|
||||
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesFaceDownCreatureEffect(morphCosts));
|
||||
|
|
@ -186,7 +195,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
ability.getCosts().clear();
|
||||
for (Iterator it = ((Costs) alternateCastingCost).iterator(); it.hasNext();) {
|
||||
Cost cost = (Cost) it.next();
|
||||
if (cost instanceof ManaCostsImpl) {
|
||||
if (cost instanceof ManaCosts) {
|
||||
ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());
|
||||
} else {
|
||||
ability.getCosts().add(cost.copy());
|
||||
|
|
@ -223,23 +232,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int numberCosts = 0;
|
||||
String remarkText = "";
|
||||
for (AlternativeCost2 alternateCastingCost: alternateCosts) {
|
||||
if (numberCosts == 0) {
|
||||
sb.append(alternateCastingCost.getText(false));
|
||||
remarkText = alternateCastingCost.getReminderText();
|
||||
} else {
|
||||
sb.append(" and/or ").append(alternateCastingCost.getText(true));
|
||||
}
|
||||
++numberCosts;
|
||||
}
|
||||
if (numberCosts == 1) {
|
||||
sb.append(" ").append(remarkText);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
return ruleText;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue