Skip to content

Commit

Permalink
Clean up (Card-Forge#4239)
Browse files Browse the repository at this point in the history
* Fix NPE

* Clean up

* Fix script
  • Loading branch information
tool4ever authored and Northmoc committed Dec 5, 2023
1 parent 9bb66ff commit 713e665
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 25 deletions.
5 changes: 1 addition & 4 deletions forge-ai/src/main/java/forge/ai/AiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1091,17 +1091,14 @@ public CardCollection getCardsToDiscard(int min, final int max, final CardCollec
return discards;
}
}

}

// look for good discards
while (count < min) {
Card prefCard = null;
if (sa != null && sa.getActivatingPlayer() != null && sa.getActivatingPlayer().isOpponentOf(player)) {
for (Card c : validCards) {
if (c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME,"
+ " put it onto the battlefield instead of putting it into your graveyard.")
|| !c.getSVar("DiscardMeByOpp").isEmpty()) {
if (c.hasSVar("DiscardMeByOpp")) {
prefCard = c;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion forge-ai/src/main/java/forge/ai/ComputerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ else if (pref.contains("DiscardCost")) { // search for permanents with DiscardMe
}
}

if (ComputerUtilCost.isFreeCastAllowedByPermanent(ai, "Discard")) {
if (activate != null && ComputerUtilCost.isFreeCastAllowedByPermanent(ai, "Discard")) {
// Dream Halls allows to discard 1 worthless card to cast 1 expensive for free
// Do it even if nothing marked for discard in hand, if it's worth doing!
int mana = ComputerUtilMana.getAvailableManaEstimate(ai, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public void resolve(final SpellAbility sa) {
}

ListMultimap<Object, Player> votes = ArrayListMultimap.create();

Player voter = game.getControlVote();

for (final Player p : tgtPlayers) {
Expand All @@ -100,7 +99,7 @@ public void resolve(final SpellAbility sa) {
Localizer.getInstance().getMessage("lblCurrentVote") + ":" + votes, p);
}
if (record.length() > 0) {
record.append("\r\n");
record.append("\r\n");
}
record.append(p).append(" ").append(Localizer.getInstance().getMessage("lblVotedFor", result));
}
Expand All @@ -112,7 +111,6 @@ public void resolve(final SpellAbility sa) {
}
game.fireEvent(new GameEventRandomLog(voteResult));


final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.AllVotes, votes);
game.getTriggerHandler().runTrigger(TriggerType.Vote, runParams, false);
Expand Down
12 changes: 5 additions & 7 deletions forge-game/src/main/java/forge/game/phase/PhaseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -782,13 +782,11 @@ private void declareBlockersTurnBasedAction() {
continue;
}

if (!c1.getDamageHistory().getCreatureBlockedThisCombat()) {
// Run triggers
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Blocker, c1);
runParams.put(AbilityKey.Attackers, combat.getAttackersBlockedBy(c1));
game.getTriggerHandler().runTrigger(TriggerType.Blocks, runParams, false);
}
// Run triggers
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Blocker, c1);
runParams.put(AbilityKey.Attackers, combat.getAttackersBlockedBy(c1));
game.getTriggerHandler().runTrigger(TriggerType.Blocks, runParams, false);

c1.getDamageHistory().setCreatureBlockedThisCombat(true);
c1.getDamageHistory().clearNotBlockedSinceLastUpkeepOf();
Expand Down
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/a/axelrod_gunnarson.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ManaCost:4 B B R R
Types:Legendary Creature Giant
PT:5/5
K:Trample
T:Mode$ ChangesZone | Origin$ Any | Destination$ Graveyard | ValidCard$ Creature.DamagedBy | Execute$ DBGainLife | TriggerDescription$ Whenever a creature dealt damage by CARDNAME this turn dies, you gain 1 life and CARDNAME deals 1 damage to target player or planeswalker.
T:Mode$ ChangesZone | Origin$ Any | Destination$ Graveyard | ValidCard$ Creature.DamagedBy | Execute$ DBGainLife | TriggerDescription$ Whenever a creature dealt damage by CARDNAME this turn dies, you gain 1 life and NICKNAME deals 1 damage to target player or planeswalker.
SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ 1 | SubAbility$ DBDealDamage
SVar:DBDealDamage:DB$ DealDamage | ValidTgts$ Player,Planeswalker | TgtPrompt$ Select target player or planeswalker | NumDmg$ 1
DeckHas:Ability$LifeGain
Expand Down
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/g/garza_zol_plague_queen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ K:Flying
K:Haste
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Creature.DamagedBy | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever a creature dealt damage by CARDNAME this turn dies, put a +1/+1 counter on CARDNAME.
SVar:TrigPutCounter:DB$ PutCounter | Defined$ Self | CounterNum$ 1 | CounterType$ P1P1
T:Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage$ True | TriggerZones$ Battlefield | Execute$ TrigDraw | OptionalDecider$ You | TriggerDescription$ Whenever CARDNAME deals combat damage to a player, you may draw a card.
T:Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage$ True | TriggerZones$ Battlefield | Execute$ TrigDraw | OptionalDecider$ You | TriggerDescription$ Whenever NICKNAME deals combat damage to a player, you may draw a card.
SVar:TrigDraw:DB$ Draw | Defined$ You | NumCards$ 1
Oracle:Flying, haste\nWhenever a creature dealt damage by Garza Zol, Plague Queen this turn dies, put a +1/+1 counter on Garza Zol.\nWhenever Garza Zol deals combat damage to a player, you may draw a card.
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/k/kagemaro_first_to_suffer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ManaCost:3 B B
Types:Legendary Creature Demon Spirit
PT:*/*
S:Mode$ Continuous | EffectZone$ All | CharacteristicDefining$ True | SetPower$ X | SetToughness$ X | Description$ CARDNAME's power and toughness are each equal to the number of cards in your hand.
A:AB$ PumpAll | Cost$ B Sac<1/CARDNAME> | ValidCards$ Creature | NumAtt$ -X | NumDef$ -X | IsCurse$ True | SpellDescription$ All creatures get -X/-X until end of turn, where X is the number of cards in your hand.
A:AB$ PumpAll | Cost$ B Sac<1/NICKNAME> | ValidCards$ Creature | NumAtt$ -X | NumDef$ -X | IsCurse$ True | SpellDescription$ All creatures get -X/-X until end of turn, where X is the number of cards in your hand.
SVar:X:Count$InYourHand
AI:RemoveDeck:All
Oracle:Kagemaro, First to Suffer's power and toughness are each equal to the number of cards in your hand.\n{B}, Sacrifice Kagemaro: All creatures get -X/-X until end of turn, where X is the number of cards in your hand.
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/k/karona_false_god.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Types:Legendary Creature Avatar
PT:5/5
K:Haste
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ Player | TriggerZones$ Battlefield | Execute$ TrigControl | TriggerDescription$ At the beginning of each player's upkeep, that player untaps CARDNAME and gains control of it.
T:Mode$ Attacks | ValidCard$ Card.Self | TriggerZones$ Battlefield | Execute$ TrigChoosePump | TriggerDescription$ Whenever Karona attacks, creatures of the creature type of your choice get +3/+3 until end of turn.
T:Mode$ Attacks | ValidCard$ Card.Self | TriggerZones$ Battlefield | Execute$ TrigChoosePump | TriggerDescription$ Whenever NICKNAME attacks, creatures of the creature type of your choice get +3/+3 until end of turn.
SVar:TrigControl:DB$ GainControl | Defined$ Self | NewController$ TriggeredPlayer | Untap$ True | SpellDescription$ Untap CARDNAME and gain control of it.
SVar:TrigChoosePump:DB$ ChooseType | Defined$ You | Type$ Creature | AILogic$ MostProminentComputerControls | SubAbility$ DBPumpAll | SpellDescription$ Creatures of the creature type of your choice get +3/+3 until end of turn.
SVar:DBPumpAll:DB$ PumpAll | ValidCards$ Creature.ChosenType | NumAtt$ 3 | NumDef$ 3
Expand Down
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/k/kumano_master_yamabushi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ ManaCost:3 R R
Types:Legendary Creature Human Shaman
PT:4/4
A:AB$ DealDamage | Cost$ 1 R | ValidTgts$ Any | NumDmg$ 1 | SpellDescription$ CARDNAME deals 1 damage to any target.
R:Event$ Moved | ValidLKI$ Creature.DamagedBy | Destination$ Graveyard | ReplaceWith$ DBExile | ActiveZones$ Battlefield | Description$ If a creature dealt damage by CARDNAME this turn would die, exile it instead.
R:Event$ Moved | ValidLKI$ Creature.DamagedBy | Destination$ Graveyard | ReplaceWith$ DBExile | ActiveZones$ Battlefield | Description$ If a creature dealt damage by NICKNAME this turn would die, exile it instead.
SVar:DBExile:DB$ ChangeZone | Defined$ ReplacedCard | Origin$ Battlefield | Destination$ Exile
Oracle:{1}{R}: Kumano, Master Yamabushi deals 1 damage to any target.\nIf a creature dealt damage by Kumano this turn would die, exile it instead.
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/m/maga_traitor_to_mortals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Types:Legendary Creature Human Wizard
PT:0/0
K:etbCounter:P1P1:X
SVar:X:Count$xPaid
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigDrain | TriggerDescription$ When CARDNAME enters the battlefield, target player loses life equal to the number of +1/+1 counters on it.
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigDrain | TriggerDescription$ When NICKNAME enters the battlefield, target player loses life equal to the number of +1/+1 counters on it.
SVar:TrigDrain:DB$ LoseLife | ValidTgts$ Player | TgtPrompt$ Select target player | LifeAmount$ Y
SVar:Y:Count$CardCounters.P1P1
Oracle:Maga, Traitor to Mortals enters the battlefield with X +1/+1 counters on it.\nWhen Maga enters the battlefield, target player loses life equal to the number of +1/+1 counters on it.
4 changes: 2 additions & 2 deletions forge-gui/res/cardsfolder/s/sekki_seasons_guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ ManaCost:5 G G G
Types:Legendary Creature Spirit
PT:0/0
K:etbCounter:P1P1:8
R:Event$ DamageDone | ActiveZones$ Battlefield | ValidTarget$ Card.Self | ReplaceWith$ SekkiCounters | PreventionEffect$ True | AlwaysReplace$ True | Description$ If damage would be dealt to Sekki, prevent that damage, remove that many +1/+1 counters from Sekki, and create that many 1/1 colorless Spirit creature tokens.
R:Event$ DamageDone | ActiveZones$ Battlefield | ValidTarget$ Card.Self | ReplaceWith$ SekkiCounters | PreventionEffect$ True | AlwaysReplace$ True | Description$ If damage would be dealt to NICKNAME, prevent that damage, remove that many +1/+1 counters from NICKNAME, and create that many 1/1 colorless Spirit creature tokens.
SVar:SekkiCounters:DB$ RemoveCounter | CounterType$ P1P1 | CounterNum$ SekkiX | SubAbility$ DBSekkiToken
SVar:DBSekkiToken:DB$ Token | TokenAmount$ SekkiX | TokenScript$ c_1_1_spirit
A:AB$ ChangeZone | Cost$ Sac<8/Spirit> | Defined$ Self | ActivationZone$ Graveyard | Origin$ Graveyard | Destination$ Battlefield | SpellDescription$ Return Sekki from your graveyard to the battlefield.
A:AB$ ChangeZone | Cost$ Sac<8/Spirit> | Defined$ Self | ActivationZone$ Graveyard | Origin$ Graveyard | Destination$ Battlefield | SpellDescription$ Return NICKNAME from your graveyard to the battlefield.
SVar:SekkiX:ReplaceCount$DamageAmount
Oracle:Sekki, Seasons' Guide enters the battlefield with eight +1/+1 counters on it.\nIf damage would be dealt to Sekki, prevent that damage, remove that many +1/+1 counters from Sekki, and create that many 1/1 colorless Spirit creature tokens.\nSacrifice eight Spirits: Return Sekki from your graveyard to the battlefield.
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/s/shimatsu_the_bloodcloaked.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Name:Shimatsu the Bloodcloaked
ManaCost:3 R
Types:Legendary Creature Demon Spirit
PT:0/0
R:Event$ Moved | ValidCard$ Card.Self | Destination$ Battlefield | ReplaceWith$ TrigSac | ReplacementResult$ Updated | Description$ As CARDNAME enters the battlefield, sacrifice any number of permanents. Shimatsu enters the battlefield with that many +1/+1 counters on it.
R:Event$ Moved | ValidCard$ Card.Self | Destination$ Battlefield | ReplaceWith$ TrigSac | ReplacementResult$ Updated | Description$ As CARDNAME enters the battlefield, sacrifice any number of permanents. NICKNAME enters the battlefield with that many +1/+1 counters on it.
SVar:TrigSac:DB$ Sacrifice | Amount$ SacX | SacValid$ Permanent | Defined$ You | RememberSacrificed$ True | Optional$ True | SubAbility$ DBPutcounter
SVar:DBPutcounter:DB$ PutCounter | ETB$ True | CounterType$ P1P1 | Defined$ Self | CounterNum$ X | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
Expand Down
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/upcoming/goblin_tomb_raider.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Name:Goblin Tomb Raider
ManaCost:R
Types:Creature Goblin Pirate
PT:1/2
S:Mode$ Continuous | Affected$ Creature.YouCtrl | AddPower$ 1 | IsPresent$ Artifact.YouCtrl | PresentCompare$ GE1 | AddKeyword$ Haste | Description$ As long as you control an artifact, CARDNAME gets +1/+0 and has haste.
S:Mode$ Continuous | Affected$ Card.Self | AddPower$ 1 | IsPresent$ Artifact.YouCtrl | AddKeyword$ Haste | Description$ As long as you control an artifact, CARDNAME gets +1/+0 and has haste.
DeckHints:Type$Artifact
Oracle:As long as you control an artifact, Goblin Tomb Raider gets +1/+0 and has haste.

0 comments on commit 713e665

Please sign in to comment.