mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
CardFactoryUtil: moved "At the beginning of your upkeep, sacrifice" as "UpkeepCost" in CardFactoryUtil
delete Upkeep class because its not needed anymore
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -608,7 +608,6 @@ forge-game/src/main/java/forge/game/phase/Phase.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/phase/PhaseHandler.java -text
|
||||
forge-game/src/main/java/forge/game/phase/PhaseType.java -text
|
||||
forge-game/src/main/java/forge/game/phase/Untap.java -text
|
||||
forge-game/src/main/java/forge/game/phase/Upkeep.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/phase/package-info.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/player/AchievementTracker.java -text
|
||||
forge-game/src/main/java/forge/game/player/DelayedReveal.java -text
|
||||
|
||||
@@ -163,7 +163,7 @@ public class CreatureEvaluator implements Function<Card, Integer> {
|
||||
value -= subValue(50, "eot-leaves");
|
||||
} else if (c.hasStartOfKeyword("Cumulative upkeep")) {
|
||||
value -= subValue(30, "cupkeep");
|
||||
} else if (c.hasStartOfKeyword("At the beginning of your upkeep, sacrifice CARDNAME unless you pay")) {
|
||||
} else if (c.hasStartOfKeyword("UpkeepCost")) {
|
||||
value -= subValue(20, "sac-unless");
|
||||
} else if (c.hasStartOfKeyword("Echo") && c.cameUnderControlSinceLastUpkeep()) {
|
||||
value -= subValue(10, "echo-unpaid");
|
||||
|
||||
@@ -135,9 +135,9 @@ public class PermanentAi extends SpellAbilityAi {
|
||||
|
||||
// don't play cards without being able to pay the upkeep for
|
||||
for (String ability : card.getKeywords()) {
|
||||
if (ability.startsWith("At the beginning of your upkeep, sacrifice CARDNAME unless you pay")) {
|
||||
final String[] k = ability.split(" pay ");
|
||||
final String costs = k[1].replaceAll("[{]", "").replaceAll("[}]", " ");
|
||||
if (ability.startsWith("UpkeepCost")) {
|
||||
final String[] k = ability.split(":");
|
||||
final String costs = k[1];
|
||||
|
||||
final SpellAbility emptyAbility = new SpellAbility.EmptySa(card, ai);
|
||||
emptyAbility.setPayCosts(new Cost(costs, true));
|
||||
|
||||
@@ -43,7 +43,6 @@ import forge.game.phase.Phase;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.phase.Untap;
|
||||
import forge.game.phase.Upkeep;
|
||||
import forge.game.player.IGameEntitiesFactory;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
@@ -77,7 +76,7 @@ public class Game {
|
||||
public final Phase endOfCombat;
|
||||
public final Phase endOfTurn;
|
||||
public final Untap untap;
|
||||
public final Upkeep upkeep;
|
||||
public final Phase upkeep;
|
||||
public final MagicStack stack;
|
||||
public final CostPaymentStack costPaymentStack = new CostPaymentStack();
|
||||
private final PhaseHandler phaseHandler;
|
||||
@@ -239,7 +238,7 @@ public class Game {
|
||||
phaseHandler = new PhaseHandler(this);
|
||||
|
||||
untap = new Untap(this);
|
||||
upkeep = new Upkeep(this);
|
||||
upkeep = new Phase(PhaseType.UPKEEP);
|
||||
cleanup = new Phase(PhaseType.CLEANUP);
|
||||
endOfCombat = new Phase(PhaseType.COMBAT_END);
|
||||
endOfTurn = new Phase(PhaseType.END_OF_TURN);
|
||||
@@ -304,7 +303,7 @@ public class Game {
|
||||
public final Untap getUntap() {
|
||||
return untap;
|
||||
}
|
||||
public final Upkeep getUpkeep() {
|
||||
public final Phase getUpkeep() {
|
||||
return upkeep;
|
||||
}
|
||||
public final Phase getEndOfCombat() {
|
||||
|
||||
@@ -1428,7 +1428,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|| keyword.startsWith("Cycling") || keyword.startsWith("TypeCycling")
|
||||
|| keyword.startsWith("ETBReplacement") || keyword.startsWith("MayEffectFromOpeningHand")
|
||||
|| keyword.equals("Undaunted") || keyword.startsWith("Monstrosity")
|
||||
|| keyword.startsWith("Graft")) {
|
||||
|| keyword.startsWith("Graft") || keyword.startsWith("UpkeepCost")) {
|
||||
} else if (keyword.startsWith("Provoke") || keyword.startsWith("Devour") || keyword.equals("Unleash")
|
||||
|| keyword.startsWith("Soulbond") || keyword.equals("Partner") || keyword.equals("Retrace")
|
||||
|| keyword.equals("Living Weapon") || keyword.equals("Myriad") || keyword.equals("Exploit")
|
||||
|
||||
@@ -2248,6 +2248,8 @@ public class CardFactoryUtil {
|
||||
}
|
||||
else if (keyword.equals("Evolve")) {
|
||||
addTriggerAbility(keyword, card, null);
|
||||
} else if (keyword.startsWith("UpkeepCost")) {
|
||||
addTriggerAbility(keyword, card, null);
|
||||
}
|
||||
else if (keyword.startsWith("Dredge")) {
|
||||
final int dredgeAmount = card.getKeywordMagnitude("Dredge");
|
||||
@@ -3249,6 +3251,36 @@ public class CardFactoryUtil {
|
||||
parsedTrigger.setOverridingAbility(AbilityFactory.getAbility(effect, card));
|
||||
final Trigger cardTrigger = card.addTrigger(parsedTrigger);
|
||||
|
||||
if (!intrinsic) {
|
||||
kws.addTrigger(cardTrigger);
|
||||
}
|
||||
} else if (keyword.startsWith("UpkeepCost")) {
|
||||
final String[] k = keyword.split(":");
|
||||
final Cost cost = new Cost(k[1], true);
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("At the beginning of your upkeep, sacrifice CARDNAME unless you ");
|
||||
if (cost.isOnlyManaCost()) {
|
||||
sb.append("pay ");
|
||||
}
|
||||
final String costStr = k.length == 3 ? k[2] : cost.toSimpleString();
|
||||
|
||||
sb.append(costStr.substring(0,1).toLowerCase() + costStr.substring(1));
|
||||
sb.append(".");
|
||||
|
||||
String upkeepTrig = "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | " +
|
||||
"TriggerDescription$ " + sb.toString();
|
||||
|
||||
String effect = "DB$ Sacrifice | SacValid$ Self | UnlessPayer$ You | UnlessCost$ " + k[1];
|
||||
|
||||
if (!StringUtils.isNumeric(k[1])) {
|
||||
effect += " | References$ " + k[1];
|
||||
}
|
||||
|
||||
final Trigger parsedTrigger = TriggerHandler.parseTrigger(upkeepTrig, card, intrinsic);
|
||||
parsedTrigger.setOverridingAbility(AbilityFactory.getAbility(effect, card));
|
||||
final Trigger cardTrigger = card.addTrigger(parsedTrigger);
|
||||
|
||||
if (!intrinsic) {
|
||||
kws.addTrigger(cardTrigger);
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that itinksidd will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.phase;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollectionView;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The Upkeep class handles ending effects with "until your next upkeep" and
|
||||
* "until next upkeep".
|
||||
*
|
||||
* It also handles hardcoded triggers "At the beginning of upkeep".
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Upkeep extends Phase {
|
||||
private static final long serialVersionUID = 6906459482978819354L;
|
||||
|
||||
protected final Game game;
|
||||
public Upkeep(final Game game) {
|
||||
super(PhaseType.UPKEEP);
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Handles all the hardcoded events that happen at the beginning of each
|
||||
* Upkeep Phase.
|
||||
*
|
||||
* This will freeze the Stack at the start, and unfreeze the Stack at the
|
||||
* end.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public final void executeAt() {
|
||||
game.getStack().freezeStack();
|
||||
|
||||
Upkeep.upkeepUpkeepCost(game); // sacrifice unless upkeep cost is paid
|
||||
|
||||
game.getStack().unfreezeStack();
|
||||
}
|
||||
|
||||
private static void upkeepUpkeepCost(final Game game) {
|
||||
final CardCollectionView list = game.getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
final Card c = list.get(i);
|
||||
final Player controller = c.getController();
|
||||
for (String ability : c.getKeywords()) {
|
||||
// sacrifice
|
||||
if (ability.startsWith("At the beginning of your upkeep, sacrifice")) {
|
||||
|
||||
final StringBuilder sb = new StringBuilder("Sacrifice upkeep for " + c);
|
||||
final String[] k = ability.split(" pay ");
|
||||
final String cost = k[1].replaceAll("[{]", "").replaceAll("[}]", " ");
|
||||
|
||||
String effect = "AB$ Sacrifice | Cost$ 0 | SacValid$ Self"
|
||||
+ "| UnlessPayer$ You | UnlessCost$ " + cost;
|
||||
|
||||
SpellAbility upkeepAbility = AbilityFactory.getAbility(effect, c);
|
||||
upkeepAbility.setActivatingPlayer(controller);
|
||||
upkeepAbility.setStackDescription(sb.toString());
|
||||
upkeepAbility.setDescription(sb.toString());
|
||||
upkeepAbility.setTrigger(true);
|
||||
|
||||
game.getStack().addSimultaneousStackEntry(upkeepAbility);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user