Skip to content

Commit

Permalink
Clean up logic (#6928)
Browse files Browse the repository at this point in the history
  • Loading branch information
tool4ever authored Jan 29, 2025
1 parent e6fc666 commit 2a7bd8b
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 25 deletions.
6 changes: 6 additions & 0 deletions forge-game/src/main/java/forge/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,12 @@ public void onCleanupPhase() {
for (Player player : getRegisteredPlayers()) {
player.onCleanupPhase();
}
for (final Card c : getCardsIncludePhasingIn(ZoneType.Battlefield)) {
c.onCleanupPhase(getPhaseHandler().getPlayerTurn());
}
for (final Card card : getCardsInGame()) {
card.resetActivationsPerTurn();
}
}

public void addCounterAddedThisTurn(Player putter, CounterType cType, Card card, Integer value) {
Expand Down
6 changes: 0 additions & 6 deletions forge-game/src/main/java/forge/game/GameAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ public GameAction(Game game0) {
game = game0;
}

public final void resetActivationsPerTurn() {
for (final Card card : game.getCardsInGame()) {
card.resetActivationsPerTurn();
}
}

public Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer position, SpellAbility cause) {
return changeZone(zoneFrom, zoneTo, c, position, cause, null);
}
Expand Down
4 changes: 0 additions & 4 deletions forge-game/src/main/java/forge/game/card/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -7271,10 +7271,6 @@ public void onEndOfCombat(final Player active) {
}

public void onCleanupPhase(final Player turn) {
if (!StaticAbilityNoCleanupDamage.damageNotRemoved(this)) {
setDamage(0);
}
setHasBeenDealtDeathtouchDamage(false);
resetExcessDamage();
setRegeneratedThisTurn(0);
resetShieldCount();
Expand Down
1 change: 0 additions & 1 deletion forge-game/src/main/java/forge/game/combat/CombatUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ public static void checkDeclaredAttacker(final Game game, final Card c, final Co
final GameEntity defender = combat.getDefenderByAttacker(c);
final List<Card> otherAttackers = combat.getAttackers();

// Run triggers
if (triggers) {
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Attacker, c);
Expand Down
8 changes: 5 additions & 3 deletions forge-game/src/main/java/forge/game/phase/PhaseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import forge.game.replacement.ReplacementType;

import forge.game.spellability.SpellAbility;
import forge.game.staticability.StaticAbilityNoCleanupDamage;
import forge.game.trigger.Trigger;
import forge.game.trigger.TriggerType;
import forge.game.zone.Zone;
Expand Down Expand Up @@ -180,8 +181,6 @@ private void advanceToNextPhase() {
}
playerTurn.incrementTurn();

game.getAction().resetActivationsPerTurn();

final int lands = CardLists.count(playerTurn.getLandsInPlay(), CardPredicates.UNTAPPED);
playerTurn.setNumPowerSurgeLands(lands);
}
Expand Down Expand Up @@ -395,7 +394,10 @@ private void onPhaseBegin() {
// Rule 514.2
// Reset Damage received map
for (final Card c : game.getCardsIncludePhasingIn(ZoneType.Battlefield)) {
c.onCleanupPhase(playerTurn);
if (!StaticAbilityNoCleanupDamage.damageNotRemoved(c)) {
c.setDamage(0);
}
c.setHasBeenDealtDeathtouchDamage(false);
}

game.getEndOfTurn().executeUntil();
Expand Down
4 changes: 2 additions & 2 deletions forge-game/src/main/java/forge/game/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -1994,8 +1994,8 @@ public final void createSpeedEffect() {
final PlayerZone com = getZone(ZoneType.Command);
DetachedCardEffect eff = new DetachedCardEffect(this, "Speed Effect");
String trigger = "Mode$ LifeLost | ValidPlayer$ Opponent | TriggerZones$ Command | ActivationLimit$ 1 | " +
"PlayerTurn$ True | TriggerDescription$ Your speed increases once on each of your turns when an " +
"opponent loses life.";
"PlayerTurn$ True | CheckSVar$ Count$YourSpeed | SVarCompare$ LT4 | "
+ "TriggerDescription$ Your speed increases once on each of your turns when an opponent loses life.";
String speedUp = "DB$ ChangeSpeed";
Trigger lifeLostTrigger = TriggerHandler.parseTrigger(trigger, eff, true);
lifeLostTrigger.setOverridingAbility(AbilityFactory.getAbility(speedUp, eff));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ public TriggerAttackerBlockedByCreature(final Map<String, String> params, final
public final boolean performTest(final Map<AbilityKey, Object> runParams) {
final Object a = runParams.get(AbilityKey.Attacker),
b = runParams.get(AbilityKey.Blocker);
if (!(a instanceof Card && b instanceof Card)) {
return false;
}

final Card attacker = (Card) a,
blocker = (Card) b;
Expand Down
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/b/battle_cry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ManaCost:2 W
Types:Instant
A:SP$ UntapAll | ValidCards$ Creature.White+YouCtrl | SubAbility$ Battlecry | SpellDescription$ Untap all white creatures you control. Whenever a creature blocks this turn, it gets +0/+1 until end of turn.
SVar:Battlecry:DB$ Effect | Triggers$ TrigBlocking
SVar:TrigBlocking:Mode$ AttackerBlocked | Execute$ Pump | TriggerDescription$ Whenever a creature blocks this turn, it gets +0/+1 until end of turn.
SVar:TrigBlocking:Mode$ Blocks | Execute$ Pump | TriggerDescription$ Whenever a creature blocks this turn, it gets +0/+1 until end of turn.
SVar:Pump:DB$ Pump | Defined$ TriggeredBlockerLKICopy | NumDef$ 1
AI:RemoveDeck:All
Oracle:Untap all white creatures you control.\nWhenever a creature blocks this turn, it gets +0/+1 until end of turn.
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/i/ian_malcolm_chaotician.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Types:Legendary Creature Human Scientist
PT:2/2
T:Mode$ Drawn | ValidPlayer$ Player | Number$ 2 | TriggerZones$ Battlefield | Execute$ TrigDig | TriggerDescription$ Whenever a player draws their second card each turn, that player exiles the top card of their library.
SVar:TrigDig:DB$ Dig | Defined$ TriggeredPlayer | DigNum$ 1 | Reveal$ True | ChangeNum$ All | ChangeValid$ Card | RememberChanged$ True | DestinationZone$ Exile
S:Mode$ Continuous | Affected$ Card.ExiledWithSource+YouDontOwn | MayPlay$ True | MayPlayLimit$ 1 | MayPlayIgnoreType$ True | MayPlayPlayer$ ActivePlayer | EffectZone$ Battlefield | AffectedZone$ Exile | Description$ During each player's turn, that player may cast a spell from among the cards they don't own exiled with CARDNAME and mana of any type can be spent to cast it.
S:Mode$ Continuous | Affected$ Card.ExiledWithSource+!OwnedBy ActivePlayer | MayPlay$ True | MayPlayLimit$ 1 | MayPlayIgnoreType$ True | MayPlayPlayer$ ActivePlayer | EffectZone$ Battlefield | AffectedZone$ Exile | Description$ During each player's turn, that player may cast a spell from among the cards they don't own exiled with CARDNAME and mana of any type can be spent to cast it.
Oracle:Whenever a player draws their second card each turn, that player exiles the top card of their library.\nDuring each player's turn, that player may cast a spell from among the cards they don't own exiled with Ian Malcolm, Chaotician, and mana of any type can be spent to cast it.
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/m/mage_hunters_onslaught.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ ManaCost:2 B B
Types:Sorcery
A:SP$ Destroy | ValidTgts$ Creature,Planeswalker | TgtPrompt$ Select target creature or planeswalker | SubAbility$ DBEffect | SpellDescription$ Destroy target creature or planeswalker.
SVar:DBEffect:DB$ Effect | Triggers$ TrigBlocking
SVar:TrigBlocking:Mode$ AttackerBlocked | Execute$ TrigLoseLife | TriggerDescription$ Whenever a creature blocks this turn, its controller loses 1 life.
SVar:TrigBlocking:Mode$ Blocks | Execute$ TrigLoseLife | TriggerDescription$ Whenever a creature blocks this turn, its controller loses 1 life.
SVar:TrigLoseLife:DB$ LoseLife | Defined$ TriggeredBlockerController | LifeAmount$ 1
Oracle:Destroy target creature or planeswalker.\nWhenever a creature blocks this turn, its controller loses 1 life.
6 changes: 3 additions & 3 deletions forge-gui/res/cardsfolder/s/swashbuckler_extraordinaire.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.S
SVar:TrigTreasure:DB$ Token | TokenAmount$ 1 | TokenScript$ c_a_treasure_sac | TokenOwner$ You
T:Mode$ AttackersDeclared | AttackingPlayer$ You | Execute$ TrigSac | TriggerZones$ Battlefield | TriggerDescription$ Whenever you attack, you may sacrifice one or more Treasures. When you do, up to that many target creatures gain double strike until end of turn.
SVar:TrigSac:DB$ Sacrifice | Defined$ You | Amount$ X | SacValid$ Treasure | SacMessage$ treasure | Optional$ True | RememberSacrificed$ True | SubAbility$ TrigImmediateTrig
SVar:TrigImmediateTrig:DB$ ImmediateTrigger | Execute$ DBPump | TriggerDescription$ When you do, up to that many target creatures gain double strike until end of turn.
SVar:DBPump:DB$ Pump | ValidTgts$ Creature | KW$ Double Strike | TargetMin$ 0 | TargetMax$ DBSize | SubAbility$ DBCleanup | TgtPrompt$ Select target creatures | StackDescription$ {c:Targeted} gain double strike until end of turn. | SpellDescription$ Up to that many target creatures gain double strike until end of turn.
SVar:TrigImmediateTrig:DB$ ImmediateTrigger | Execute$ DBPump | ConditionDefined$ RememberedLKI | ConditionPresent$ Card | RememberObjects$ RememberedLKI | SubAbility$ DBCleanup | TriggerDescription$ When you do, up to that many target creatures gain double strike until end of turn.
SVar:DBPump:DB$ Pump | ValidTgts$ Creature | KW$ Double Strike | TargetMin$ 0 | TargetMax$ DBSize | TgtPrompt$ Select target creatures | StackDescription$ {c:Targeted} gain double strike until end of turn. | SpellDescription$ Up to that many target creatures gain double strike until end of turn.
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:DBSize:Count$RememberedSize
SVar:DBSize:TriggerRemembered$Amount
SVar:X:Count$Valid Treasure.YouCtrl
AI:RemoveDeck:All
DeckHas:Ability$Token|Sacrifice & Type$Treasure|Artifact
Expand Down

0 comments on commit 2a7bd8b

Please sign in to comment.