mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
GameActionUtil > getAdditionalCostSpell() "AlternativeAdditionalCost" refactor to support more than two possible costs
This commit is contained in:
@@ -487,27 +487,18 @@ public final class GameActionUtil {
|
|||||||
final String keyword = inst.getOriginal();
|
final String keyword = inst.getOriginal();
|
||||||
if (keyword.startsWith("AlternateAdditionalCost")) {
|
if (keyword.startsWith("AlternateAdditionalCost")) {
|
||||||
final List<SpellAbility> newAbilities = Lists.newArrayList();
|
final List<SpellAbility> newAbilities = Lists.newArrayList();
|
||||||
String[] costs = TextUtil.split(keyword, ':');
|
final String[] costs = (keyword.split(":", 2)[1]).split(":");
|
||||||
|
|
||||||
|
for (String s : costs) {
|
||||||
final SpellAbility newSA = sa.copy();
|
final SpellAbility newSA = sa.copy();
|
||||||
newSA.setBasicSpell(false);
|
newSA.setBasicSpell(false);
|
||||||
|
|
||||||
final Cost cost1 = new Cost(costs[1], false);
|
final Cost cost = new Cost(s, false);
|
||||||
newSA.setDescription(sa.getDescription() + " (Additional cost " + cost1.toSimpleString() + ")");
|
newSA.setDescription(sa.getDescription() + " (Additional cost: " + cost.toSimpleString() + ")");
|
||||||
newSA.setPayCosts(cost1.add(sa.getPayCosts()));
|
newSA.setPayCosts(cost.add(sa.getPayCosts()));
|
||||||
if (newSA.canPlay()) {
|
if (newSA.canPlay()) {
|
||||||
newAbilities.add(newSA);
|
newAbilities.add(newSA);
|
||||||
}
|
}
|
||||||
|
|
||||||
//second option
|
|
||||||
final SpellAbility newSA2 = sa.copy();
|
|
||||||
newSA2.setBasicSpell(false);
|
|
||||||
|
|
||||||
final Cost cost2 = new Cost(costs[2], false);
|
|
||||||
newSA2.setDescription(sa.getDescription() + " (Additional cost " + cost2.toSimpleString() + ")");
|
|
||||||
newSA2.setPayCosts(cost2.add(sa.getPayCosts()));
|
|
||||||
if (newSA2.canPlay()) {
|
|
||||||
newAbilities.add(newSA2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abilities.clear();
|
abilities.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user