mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Refactored Entwine ability
This commit is contained in:
@@ -34,6 +34,7 @@ import forge.game.ability.AbilityFactory;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.ability.AbilityFactory.AbilityRecordType;
|
||||
import forge.game.ability.effects.CharmEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
@@ -408,6 +409,17 @@ public final class GameActionUtil {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} else if (keyword.startsWith("Entwine")) {
|
||||
for (int i = 0; i < abilities.size(); i++) {
|
||||
final SpellAbility newSA = abilities.get(i).copy();
|
||||
SpellAbility entwine = AbilityFactory.buildEntwineAbility(newSA);
|
||||
entwine.setPayCosts(new Cost(keyword.substring(8), false).add(newSA.getPayCosts()));
|
||||
entwine.addOptionalCost(OptionalCost.Entwine);
|
||||
if (newSA.canPlay()) {
|
||||
abilities.add(i, entwine);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} else if (keyword.startsWith("Kicker")) {
|
||||
for (int i = 0; i < abilities.size(); i++) {
|
||||
String[] sCosts = TextUtil.split(keyword.substring(7), ':');
|
||||
|
||||
@@ -366,4 +366,31 @@ public final class AbilityFactory {
|
||||
return left;
|
||||
}
|
||||
|
||||
public static final SpellAbility buildEntwineAbility(final SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final String[] saChoices = sa.getParam("Choices").split(",");
|
||||
if (sa.getApi() != ApiType.Charm || saChoices.length != 2)
|
||||
throw new IllegalStateException("Entwine ability may be built only on charm cards");
|
||||
final String ab = source.getSVar(saChoices[0]);
|
||||
Map<String, String> firstMap = getMapParams(ab);
|
||||
AbilityRecordType firstType = AbilityRecordType.getRecordType(firstMap);
|
||||
ApiType firstApi = firstType.getApiTypeOf(firstMap);
|
||||
firstMap.put("StackDecription", firstMap.get("SpellDescription"));
|
||||
firstMap.put("SpellDescription", sa.getDescription() + " Entwine (Choose both if you pay the entwine cost.)");
|
||||
SpellAbility entwineSA = getAbility(AbilityRecordType.Spell, firstApi, firstMap, new Cost(sa.getPayCosts().toSimpleString(), false), source);
|
||||
|
||||
final String ab2 = source.getSVar(saChoices[1]);
|
||||
Map<String, String> secondMap = getMapParams(ab2);
|
||||
ApiType secondApi = firstType.getApiTypeOf(secondMap);
|
||||
secondMap.put("StackDecription", secondMap.get("SpellDescription"));
|
||||
secondMap.put("SpellDescription", "");
|
||||
AbilitySub sub = (AbilitySub) getAbility(AbilityRecordType.SubAbility, secondApi, secondMap, null, source);
|
||||
entwineSA.appendSubAbility(sub);
|
||||
|
||||
entwineSA.setBasicSpell(false);
|
||||
entwineSA.setActivatingPlayer(sa.getActivatingPlayer());
|
||||
entwineSA.setRestrictions(sa.getRestrictions());
|
||||
return entwineSA;
|
||||
}
|
||||
|
||||
} // end class AbilityFactory
|
||||
|
||||
@@ -2434,6 +2434,9 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
} else if (keyword.startsWith("Buyback")) {
|
||||
final Cost cost = new Cost(keyword.substring(8), false);
|
||||
sb.append("Buyback " + cost.toSimpleString() + "\r\n");
|
||||
} else if (keyword.startsWith("Entwine")) {
|
||||
final Cost cost = new Cost(keyword.substring(8), false);
|
||||
sb.append("Entwine " + cost.toSimpleString() + "\r\n");
|
||||
} else if (keyword.startsWith("Kicker")) {
|
||||
final Cost cost = new Cost(keyword.substring(7), false);
|
||||
sb.append("Kicker " + cost.toSimpleString() + "\r\n");
|
||||
|
||||
@@ -2429,7 +2429,6 @@ public class CardFactoryUtil {
|
||||
card.addSpellAbility(makeAltCostAbility(card, altCost, sa1));
|
||||
}
|
||||
}
|
||||
|
||||
if (card.hasKeyword("Delve")) {
|
||||
card.getSpellAbilities().get(0).setDelve(true);
|
||||
}
|
||||
@@ -3446,7 +3445,7 @@ public class CardFactoryUtil {
|
||||
ripplePos = hasKeyword(card, "Ripple", n + 1);
|
||||
} // Ripple
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final static void refreshTotemArmor(Card c) {
|
||||
boolean hasKw = c.hasKeyword("Totem armor");
|
||||
|
||||
@@ -7,6 +7,7 @@ package forge.game.spellability;
|
||||
public enum OptionalCost {
|
||||
Conspire,
|
||||
Buyback,
|
||||
Entwine,
|
||||
Kicker1,
|
||||
Kicker2,
|
||||
AltCost, // used by prowl
|
||||
|
||||
@@ -1715,4 +1715,5 @@ public abstract class SpellAbility extends GameObject implements ISpellAbility {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import forge.card.mana.ManaCost;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.ability.effects.CharmEffect;
|
||||
@@ -49,7 +50,9 @@ import forge.game.cost.CostTapType;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.Ability;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.HumanPlaySpellAbility;
|
||||
import forge.game.spellability.OptionalCost;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -97,16 +100,19 @@ public class HumanPlay {
|
||||
|
||||
source.setSplitStateToPlayAbility(sa);
|
||||
|
||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||
CharmEffect.makeChoices(sa);
|
||||
}
|
||||
|
||||
sa = chooseOptionalAdditionalCosts(p, sa);
|
||||
|
||||
if (sa == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||
CharmEffect.makeChoices(sa);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Need to check PayCosts, and Ability + All SubAbilities for Target
|
||||
boolean newAbility = sa.getPayCosts() != null;
|
||||
SpellAbility ability = sa;
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract class ToggleButtonsFilter<T extends InventoryItem> extends ItemF
|
||||
int maxTextWidth = buttonWidth - 8; //account for padding
|
||||
|
||||
for (FLabel btn : buttons) {
|
||||
if (!btn.getText().isEmpty()) {
|
||||
if (btn.getText() != null && !btn.getText().isEmpty()) {
|
||||
int max = maxTextWidth;
|
||||
Icon icon = btn.getIcon();
|
||||
if (icon != null) {
|
||||
|
||||
Reference in New Issue
Block a user