mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Clones are able to copy LevelUp abilities
This commit is contained in:
@@ -3,7 +3,8 @@ ManaCost:3 W
|
|||||||
Types:Enchantment
|
Types:Enchantment
|
||||||
T:Mode$ Phase | Phase$ BeginCombat | ValidPlayer$ Player.Opponent | Execute$ TrigTwoPile | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of each opponent's combat, separate all creatures that player controls into two piles. Only creatures in the pile of his or her choice can attack this turn.
|
T:Mode$ Phase | Phase$ BeginCombat | ValidPlayer$ Player.Opponent | Execute$ TrigTwoPile | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of each opponent's combat, separate all creatures that player controls into two piles. Only creatures in the pile of his or her choice can attack this turn.
|
||||||
SVar:TrigTwoPile:AB$ TwoPiles | Cost$ 0 | Defined$ TriggeredPlayer | Chooser$ TriggeredPlayer | ValidCards$ Creature | Zone$ Battlefield | Separator$ You | ChosenPile$ DBEffect
|
SVar:TrigTwoPile:AB$ TwoPiles | Cost$ 0 | Defined$ TriggeredPlayer | Chooser$ TriggeredPlayer | ValidCards$ Creature | Zone$ Battlefield | Separator$ You | ChosenPile$ DBEffect
|
||||||
SVar:DBEffect:DB$ EFfect | RememberObjects$ Remembered | StaticAbilities$ STCantAttack
|
SVar:DBEffect:DB$ EFfect | RememberObjects$ Remembered | StaticAbilities$ STCantAttack | SubAbility$ DBCleanup
|
||||||
|
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||||
SVar:STCantAttack:Mode$ CantAttack | EffectZone$ Command | ValidCard$ Creature.IsNotRemembered | Description$ Only creatures in the pile of his or her choice can attack this turn.
|
SVar:STCantAttack:Mode$ CantAttack | EffectZone$ Command | ValidCard$ Creature.IsNotRemembered | Description$ Only creatures in the pile of his or her choice can attack this turn.
|
||||||
SVar:NonStackingAttachEffect:True
|
SVar:NonStackingAttachEffect:True
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/fight_or_flight.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/fight_or_flight.jpg
|
||||||
|
|||||||
@@ -77,6 +77,19 @@ public class CountersPutAi extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sa.hasParam("LevelUp")) {
|
||||||
|
// creatures enchanted by curse auras have low priority
|
||||||
|
if (source.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||||
|
for (Card aura : source.getEnchantedBy()) {
|
||||||
|
if (aura.getController().isOpponentOf(ai)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int maxLevel = Integer.parseInt(sa.getParam("MaxLevel"));
|
||||||
|
return source.getCounters(CounterType.LEVEL) < maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO handle proper calculation of X values based on Cost
|
// TODO handle proper calculation of X values based on Cost
|
||||||
int amount = AbilityUtils.calculateAmount(source, amountStr, sa);
|
int amount = AbilityUtils.calculateAmount(source, amountStr, sa);
|
||||||
|
|
||||||
|
|||||||
@@ -170,8 +170,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
private boolean canCounter = true;
|
private boolean canCounter = true;
|
||||||
private boolean evoked = false;
|
private boolean evoked = false;
|
||||||
|
|
||||||
private boolean levelUp = false;
|
|
||||||
|
|
||||||
private boolean unearthed;
|
private boolean unearthed;
|
||||||
|
|
||||||
private boolean monstrous = false;
|
private boolean monstrous = false;
|
||||||
@@ -1296,28 +1294,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
this.counters.clear();
|
this.counters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* hasLevelUp() - checks to see if a creature has the "Level up" ability
|
|
||||||
* introduced in Rise of the Eldrazi.
|
|
||||||
*
|
|
||||||
* @return true if this creature can "Level up", false otherwise
|
|
||||||
*/
|
|
||||||
public final boolean hasLevelUp() {
|
|
||||||
return this.levelUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Setter for the field <code>levelUp</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param b
|
|
||||||
* a boolean.
|
|
||||||
*/
|
|
||||||
public final void setLevelUp(final boolean b) {
|
|
||||||
this.levelUp = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getSVar.
|
* getSVar.
|
||||||
@@ -6143,9 +6119,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (property.startsWith("hasLevelUp")) {
|
} else if (property.startsWith("hasLevelUp")) {
|
||||||
if (!this.hasLevelUp()) {
|
for (final SpellAbility sa : this.getSpellAbilities()) {
|
||||||
return false;
|
if (sa.getApi() == ApiType.PutCounter && sa.hasParam("LevelUp")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
} else if (property.startsWith("DrawnThisTurn")) {
|
} else if (property.startsWith("DrawnThisTurn")) {
|
||||||
if (!this.getDrawnThisTurn()) {
|
if (!this.getDrawnThisTurn()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import forge.game.ability.AbilityUtils;
|
|||||||
import forge.game.ability.ApiType;
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.ability.effects.CharmEffect;
|
import forge.game.ability.effects.CharmEffect;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
import forge.game.phase.PhaseType;
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.replacement.ReplacementHandler;
|
import forge.game.replacement.ReplacementHandler;
|
||||||
import forge.game.spellability.AbilityActivated;
|
import forge.game.spellability.AbilityActivated;
|
||||||
@@ -701,77 +700,6 @@ public class CardFactory {
|
|||||||
// ***************************************************
|
// ***************************************************
|
||||||
// end of card specific code
|
// end of card specific code
|
||||||
// ***************************************************
|
// ***************************************************
|
||||||
|
|
||||||
final int iLvlUp = CardFactoryUtil.hasKeyword(card, "Level up");
|
|
||||||
final int iLvlMax = CardFactoryUtil.hasKeyword(card, "maxLevel");
|
|
||||||
|
|
||||||
if (iLvlUp != -1 && iLvlMax != -1) {
|
|
||||||
final String parse = card.getKeyword().get(iLvlUp);
|
|
||||||
final String parseMax = card.getKeyword().get(iLvlMax);
|
|
||||||
card.addSpellAbility(makeLevellerAbility(card, parse, parseMax));
|
|
||||||
card.setLevelUp(true);
|
|
||||||
} // level up
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static SpellAbility makeLevellerAbility(final Card card, final String strLevelCost, final String strMaxLevel) {
|
|
||||||
card.removeIntrinsicKeyword(strLevelCost);
|
|
||||||
card.removeIntrinsicKeyword(strMaxLevel);
|
|
||||||
|
|
||||||
final String[] k = strLevelCost.split(":");
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append('{').append(k[1].replace(" ", "}{")).append('}');
|
|
||||||
final String manacost = k[1];
|
|
||||||
final String formattedMana = sb.toString();
|
|
||||||
|
|
||||||
final String[] l = strMaxLevel.split(":");
|
|
||||||
final int maxLevel = Integer.parseInt(l[1]);
|
|
||||||
|
|
||||||
class LevelUpAbility extends AbilityActivated {
|
|
||||||
public LevelUpAbility(final Card ca, final String s) {
|
|
||||||
super(ca, new Cost(manacost, true), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AbilityActivated getCopy() {
|
|
||||||
AbilityActivated levelUp = new LevelUpAbility(getSourceCard(), getPayCosts().toString());
|
|
||||||
levelUp.getRestrictions().setSorcerySpeed(true);
|
|
||||||
return levelUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 3998280279949548652L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resolve() {
|
|
||||||
card.addCounter(CounterType.LEVEL, 1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayAI(Player aiPlayer) {
|
|
||||||
// creatures enchanted by curse auras have low priority
|
|
||||||
if (card.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
|
||||||
for (Card aura : card.getEnchantedBy()) {
|
|
||||||
if (aura.getController().isOpponentOf(aiPlayer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return card.getCounters(CounterType.LEVEL) < maxLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
final StringBuilder sbDesc = new StringBuilder();
|
|
||||||
sbDesc.append("Level up ").append(formattedMana).append(" (").append(formattedMana);
|
|
||||||
sbDesc.append(": Put a level counter on this. Level up only as a sorcery.)");
|
|
||||||
return sbDesc.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final SpellAbility levelUp = new LevelUpAbility(card, manacost);
|
|
||||||
levelUp.getRestrictions().setSorcerySpeed(true);
|
|
||||||
final StringBuilder sbStack = new StringBuilder();
|
|
||||||
sbStack.append(card).append(" - put a level counter on this.");
|
|
||||||
levelUp.setStackDescription(sbStack.toString());
|
|
||||||
return levelUp;
|
|
||||||
}
|
|
||||||
} // end class AbstractCardFactory
|
} // end class AbstractCardFactory
|
||||||
|
|||||||
@@ -2189,6 +2189,32 @@ public class CardFactoryUtil {
|
|||||||
card.getUnparsedAbilities().add(effect);
|
card.getUnparsedAbilities().add(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int iLvlUp = hasKeyword(card, "Level up");
|
||||||
|
final int iLvlMax = hasKeyword(card, "maxLevel");
|
||||||
|
|
||||||
|
if (iLvlUp != -1 && iLvlMax != -1) {
|
||||||
|
final String strLevelCost = card.getKeyword().get(iLvlUp);
|
||||||
|
final String strMaxLevel = card.getKeyword().get(iLvlMax);
|
||||||
|
card.removeIntrinsicKeyword(strLevelCost);
|
||||||
|
card.removeIntrinsicKeyword(strMaxLevel);
|
||||||
|
final String[] k = strLevelCost.split(":");
|
||||||
|
final String manacost = k[1];
|
||||||
|
|
||||||
|
final String[] l = strMaxLevel.split(":");
|
||||||
|
final int maxLevel = Integer.parseInt(l[1]);
|
||||||
|
|
||||||
|
String effect = "AB$ PutCounter | Cost$ " + manacost + " | " +
|
||||||
|
"SorcerySpeed$ True | LevelUp$ True | CounterNum$ 1" +
|
||||||
|
" | CounterType$ LEVEL | PrecostDesc$ Level Up | MaxLevel$ " +
|
||||||
|
maxLevel + " | SpellDescription$ (Put a level counter on" +
|
||||||
|
" this permanent. Activate this ability only any time you" +
|
||||||
|
" could cast a sorcery.)";
|
||||||
|
|
||||||
|
card.addSpellAbility(AbilityFactory.getAbility(effect, card));
|
||||||
|
// add ability to instrinic strings so copies/clones create the ability also
|
||||||
|
card.getUnparsedAbilities().add(effect);
|
||||||
|
} // level up
|
||||||
|
|
||||||
if (hasKeyword(card, "Cycling") != -1) {
|
if (hasKeyword(card, "Cycling") != -1) {
|
||||||
final int n = hasKeyword(card, "Cycling");
|
final int n = hasKeyword(card, "Cycling");
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user