mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
Changed Kentaro, the Smiling Cat's ability to be an alternate cost
instead of a set cost effect. Also cleaned up dash names to be "dash" instead of "evoke".
This commit is contained in:
parent
7af6d76f02
commit
5a3c90a295
4 changed files with 138 additions and 69 deletions
|
|
@ -51,6 +51,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
protected String rule;
|
||||
protected FilterCard filter;
|
||||
protected boolean onlyMana;
|
||||
protected DynamicCost dynamicCost;
|
||||
|
||||
public AlternativeCostSourceAbility(Cost cost) {
|
||||
this(cost, null);
|
||||
|
|
@ -78,13 +79,23 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
*/
|
||||
public AlternativeCostSourceAbility(Cost cost, Condition condition, String rule, FilterCard filter, boolean onlyMana) {
|
||||
super(Zone.ALL, null);
|
||||
this.convertToAlternativeCostAndAdd(cost);
|
||||
this.addCost(cost);
|
||||
this.setRuleAtTheTop(true);
|
||||
this.condition = condition;
|
||||
this.rule = rule;
|
||||
this.filter = filter;
|
||||
this.onlyMana = onlyMana;
|
||||
}
|
||||
|
||||
public AlternativeCostSourceAbility(Condition condition, String rule, FilterCard filter, boolean onlyMana, DynamicCost dynamicCost) {
|
||||
super(Zone.ALL, null);
|
||||
this.setRuleAtTheTop(true);
|
||||
this.condition = condition;
|
||||
this.rule = rule;
|
||||
this.filter = filter;
|
||||
this.onlyMana = onlyMana;
|
||||
this.dynamicCost = dynamicCost;
|
||||
}
|
||||
|
||||
public AlternativeCostSourceAbility(final AlternativeCostSourceAbility ability) {
|
||||
super(ability);
|
||||
|
|
@ -93,18 +104,19 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
this.rule = ability.rule;
|
||||
this.filter = ability.filter;
|
||||
this.onlyMana = ability.onlyMana;
|
||||
this.dynamicCost = ability.dynamicCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCost(Cost cost) {
|
||||
this.convertToAlternativeCostAndAdd(cost);
|
||||
AlternativeCost2 alternativeCost = convertToAlternativeCost(cost);
|
||||
if(alternativeCost != null) {
|
||||
this.alternateCosts.add(alternativeCost);
|
||||
}
|
||||
}
|
||||
|
||||
private void convertToAlternativeCostAndAdd(Cost cost) {
|
||||
if (cost != null) {
|
||||
AlternativeCost2 alternativeCost = new AlternativeCost2Impl(null, null, cost);
|
||||
this.alternateCosts.add(alternativeCost);
|
||||
}
|
||||
private AlternativeCost2 convertToAlternativeCost(Cost cost) {
|
||||
return cost != null ? new AlternativeCost2Impl(null, cost.getText(), cost) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -131,13 +143,29 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
}
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player != null) {
|
||||
if (alternateCosts.canPay(ability, ability.getSourceId(), ability.getControllerId(), game) &&
|
||||
player.chooseUse(Outcome.Detriment, alternateCosts.isEmpty() ? "Cast without paying its mana cost?":"Pay alternative costs? (" + alternateCosts.getText() +")", game)) {
|
||||
Costs<AlternativeCost2> alternativeCosts;
|
||||
if(dynamicCost != null) {
|
||||
alternativeCosts = new CostsImpl<>();
|
||||
alternativeCosts.add(convertToAlternativeCost(dynamicCost.getCost(ability, game)));
|
||||
} else {
|
||||
alternativeCosts = this.alternateCosts;
|
||||
}
|
||||
|
||||
String costChoiceText;
|
||||
if(dynamicCost != null) {
|
||||
costChoiceText = dynamicCost.getText(ability, game);
|
||||
} else {
|
||||
costChoiceText = alternativeCosts.isEmpty() ? "Cast without paying its mana cost?" : "Pay alternative costs? (" + alternativeCosts.getText() +")";
|
||||
}
|
||||
|
||||
|
||||
if (alternativeCosts.canPay(ability, ability.getSourceId(), ability.getControllerId(), game) &&
|
||||
player.chooseUse(Outcome.Benefit, costChoiceText, game)) {
|
||||
ability.getManaCostsToPay().clear();
|
||||
if(!onlyMana) {
|
||||
ability.getCosts().clear();
|
||||
}
|
||||
for (Cost cost : alternateCosts) {
|
||||
for (Cost cost : alternativeCosts) {
|
||||
AlternativeCost2 alternateCost = (AlternativeCost2) cost;
|
||||
alternateCost.activate();
|
||||
for (Iterator it = ((Costs) alternateCost).iterator(); it.hasNext();) {
|
||||
|
|
@ -161,7 +189,14 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
|
||||
@Override
|
||||
public boolean isActivated(Ability source, Game game) {
|
||||
for (AlternativeCost2 cost : alternateCosts) {
|
||||
Costs<AlternativeCost2> alternativeCosts;
|
||||
if(dynamicCost != null) {
|
||||
alternativeCosts = new CostsImpl<>();
|
||||
alternativeCosts.add(convertToAlternativeCost(dynamicCost.getCost(source, game)));
|
||||
} else {
|
||||
alternativeCosts = this.alternateCosts;
|
||||
}
|
||||
for (AlternativeCost2 cost : alternativeCosts) {
|
||||
if (cost.isActivated(game)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
12
Mage/src/mage/abilities/costs/DynamicCost.java
Normal file
12
Mage/src/mage/abilities/costs/DynamicCost.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package mage.abilities.costs;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
public interface DynamicCost {
|
||||
|
||||
Cost getCost(Ability ability, Game game);
|
||||
|
||||
String getText(Ability ability, Game game);
|
||||
|
||||
}
|
||||
|
|
@ -131,13 +131,13 @@ public class DashAbility extends StaticAbility implements AlternativeSourceCosts
|
|||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) {
|
||||
this.resetDash();
|
||||
for (AlternativeCost2 evokeCost: alternativeSourceCosts) {
|
||||
if (evokeCost.canPay(ability, sourceId, controllerId, game) &&
|
||||
player.chooseUse(Outcome.Benefit, new StringBuilder(KEYWORD).append(" the creature for ").append(evokeCost.getText(true)).append(" ?").toString(), game)) {
|
||||
activateDash(evokeCost, game);
|
||||
for (AlternativeCost2 dashCost: alternativeSourceCosts) {
|
||||
if (dashCost.canPay(ability, sourceId, controllerId, game) &&
|
||||
player.chooseUse(Outcome.Benefit, new StringBuilder(KEYWORD).append(" the creature for ").append(dashCost.getText(true)).append(" ?").toString(), game)) {
|
||||
activateDash(dashCost, game);
|
||||
ability.getManaCostsToPay().clear();
|
||||
ability.getCosts().clear();
|
||||
for (Iterator it = ((Costs) evokeCost).iterator(); it.hasNext();) {
|
||||
for (Iterator it = ((Costs) dashCost).iterator(); it.hasNext();) {
|
||||
Cost cost = (Cost) it.next();
|
||||
if (cost instanceof ManaCostsImpl) {
|
||||
ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());
|
||||
|
|
@ -170,12 +170,12 @@ public class DashAbility extends StaticAbility implements AlternativeSourceCosts
|
|||
StringBuilder sb = new StringBuilder();
|
||||
int numberCosts = 0;
|
||||
String remarkText = "";
|
||||
for (AlternativeCost2 evokeCost: alternativeSourceCosts) {
|
||||
for (AlternativeCost2 dashCost: alternativeSourceCosts) {
|
||||
if (numberCosts == 0) {
|
||||
sb.append(evokeCost.getText(false));
|
||||
remarkText = evokeCost.getReminderText();
|
||||
sb.append(dashCost.getText(false));
|
||||
remarkText = dashCost.getReminderText();
|
||||
} else {
|
||||
sb.append(" and/or ").append(evokeCost.getText(true));
|
||||
sb.append(" and/or ").append(dashCost.getText(true));
|
||||
}
|
||||
++numberCosts;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue