mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
CardFactoryUtil & CombatUtil & PhaseHandler: move Rampage to CardFactoryUtil
Keyword: fixed Reminder for Rampage
This commit is contained in:
@@ -2532,6 +2532,9 @@ public class CardFactoryUtil {
|
||||
else if (keyword.equals("Flanking")) {
|
||||
addTriggerAbility(keyword, card, null);
|
||||
}
|
||||
else if (keyword.startsWith("Rampage")) {
|
||||
addTriggerAbility(keyword, card, null);
|
||||
}
|
||||
else if (keyword.equals("Evolve")) {
|
||||
final String evolveTrigger = "Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | "
|
||||
+ " ValidCard$ Creature.YouCtrl+Other | EvolveCondition$ True | "
|
||||
@@ -3003,6 +3006,27 @@ public class CardFactoryUtil {
|
||||
if (!intrinsic) {
|
||||
kws.addTrigger(cardTrigger);
|
||||
}
|
||||
} else if (keyword.startsWith("Rampage")) {
|
||||
final String[] k = keyword.split(" ");
|
||||
final String n = k[1];
|
||||
|
||||
final String trigStr = "Mode$ AttackerBlocked | ValidCard$ Card.Self | TriggerZones$ Battlefield " +
|
||||
" | ValidBlocker$ Creature | MinBlockers$ 1 | Execute$ RampagePump" + n + " | Secondary$ True " +
|
||||
" | TriggerDescription$ Rampage " + n + " (" + Keyword.getInstance(keyword).getReminderText() + ")";
|
||||
|
||||
final String abStringRampage = "DB$ Pump | Defined$ TriggeredAttacker" +
|
||||
" | NumAtt$ Rampage" + n + " | NumDef$ Rampage" + n + " | References$ Rampage" + n;
|
||||
|
||||
final Trigger rampageTrigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
|
||||
final Trigger cardTrigger = card.addTrigger(rampageTrigger);
|
||||
|
||||
card.setSVar("RampagePump" + n, abStringRampage);
|
||||
card.setSVar("Rampage" + n, "SVar$RampageCount/Times." + n);
|
||||
|
||||
card.setSVar("RampageCount", "TriggerCount$NumBlockers/Minus.1");
|
||||
if (!intrinsic) {
|
||||
kws.addTrigger(cardTrigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1066,42 +1066,4 @@ public class CombatUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void handleRampage(final Game game, final Card a, final List<Card> blockers) {
|
||||
for (final String keyword : a.getKeywords()) {
|
||||
final int idx = keyword.indexOf("Rampage ");
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
final int numBlockers = blockers.size();
|
||||
final int magnitude = Integer.valueOf(keyword.substring(idx + "Rampage ".length()));
|
||||
CombatUtil.executeRampageAbility(game, a, magnitude, numBlockers);
|
||||
} // end Rampage
|
||||
}
|
||||
|
||||
/**
|
||||
* executes Rampage abilities for a given card.
|
||||
* @param game
|
||||
*
|
||||
* @param c
|
||||
* the card to add rampage bonus to
|
||||
* @param magnitude
|
||||
* the magnitude of rampage (ie Rampage 2 means magnitude should
|
||||
* be 2)
|
||||
* @param numBlockers
|
||||
* - the number of creatures blocking this rampaging creature
|
||||
*/
|
||||
private static void executeRampageAbility(final Game game, final Card c, final int magnitude, final int numBlockers) {
|
||||
final int totalBonus = Math.max(0, (numBlockers - 1) * magnitude);
|
||||
final String effect = "AB$ Pump | Cost$ 0 | " + c.getId() + " | NumAtt$ " + totalBonus + " | NumDef$ " + totalBonus + " | ";
|
||||
final String desc = "StackDescription$ Rampage " + magnitude + " (Whenever CARDNAME becomes blocked, it gets +" + magnitude + "/+"
|
||||
+ magnitude + " until end of turn for each creature blocking it beyond the first.)";
|
||||
|
||||
final SpellAbility ability = AbilityFactory.getAbility(effect + desc, c);
|
||||
ability.setActivatingPlayer(c.getController());
|
||||
ability.setDescription(ability.getStackDescription());
|
||||
ability.setTrigger(true);
|
||||
|
||||
game.getStack().addSimultaneousStackEntry(ability);
|
||||
}
|
||||
|
||||
} // end class CombatUtil
|
||||
|
||||
@@ -87,7 +87,7 @@ public enum Keyword {
|
||||
PROVOKE(SimpleKeyword.class, false, "Whenever this creature attacks, you may choose to have target creature defending player controls block this creature this combat if able. If you do, untap that creature."),
|
||||
PROWESS(SimpleKeyword.class, false, "Whenever you cast a noncreature spell, this creature gets +1/+1 until end of turn."),
|
||||
PROWL(KeywordWithCost.class, false, "You may cast this card by paying %s rather than paying its mana cost if you dealt combat damage to a player this turn with a creature that shares any of this spell's creature types."),
|
||||
RAMPAGE(KeywordWithAmount.class, false, "Whenever this creature becomes blocked, it gets +%d/+%d until end of turn for each creature blocking it beyond the first."),
|
||||
RAMPAGE(KeywordWithAmount.class, false, "Whenever this creature becomes blocked, it gets +%1$d/+%1$d until end of turn for each creature blocking it beyond the first."),
|
||||
REACH(SimpleKeyword.class, true, "This creature can block creatures with flying."),
|
||||
REBOUND(SimpleKeyword.class, true, "If you cast this spell from your hand, exile it as it resolves. At the beginning of your next upkeep, you may cast this card from exile without paying its mana cost."),
|
||||
RECOVER(KeywordWithCost.class, false, "When a creature is put into your graveyard from the battlefield, you may pay %s. If you do, return this card from your graveyard to your hand. Otherwise, exile this card."),
|
||||
|
||||
@@ -698,9 +698,6 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
for (final SpellAbility ab : CardFactoryUtil.getBushidoEffects(a)) {
|
||||
game.getStack().add(ab);
|
||||
}
|
||||
|
||||
// Rampage
|
||||
CombatUtil.handleRampage(game, a, blockers);
|
||||
}
|
||||
|
||||
a.getDamageHistory().setCreatureGotBlockedThisCombat(true);
|
||||
|
||||
Reference in New Issue
Block a user