Merge pull request #3205 from tool4ever/fixes

Fix NPE
This commit is contained in:
Anthony Calosa
2023-06-05 06:10:55 +08:00
committed by GitHub
6 changed files with 22 additions and 20 deletions

View File

@@ -49,8 +49,10 @@ public class ChangeCombatantsEffect extends SpellAbilityEffect {
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();
final GameEntity originalDefender = combat.getDefenderByAttacker(c); final GameEntity originalDefender = combat.getDefenderByAttacker(c);
final FCollection<GameEntity> defs = new FCollection<>(); final FCollection<GameEntity> defs = new FCollection<>(combat.getDefendingPlayers());
defs.addAll(sa.hasParam("PlayerOnly") ? combat.getDefendingPlayers() : combat.getDefenders()); if (!sa.hasParam("PlayerOnly")) {
defs.addAll(combat.getDefendingPlaneswalkers());
}
String title = Localizer.getInstance().getMessage("lblChooseDefenderToAttackWithCard", cardString); String title = Localizer.getInstance().getMessage("lblChooseDefenderToAttackWithCard", cardString);
Map<String, Object> params = Maps.newHashMap(); Map<String, Object> params = Maps.newHashMap();

View File

@@ -236,7 +236,7 @@ public class CombatUtil {
// attacker got goaded by defender or defender is not player // attacker got goaded by defender or defender is not player
if (goadedByDefender || !(defender instanceof Player)) { if (goadedByDefender || !(defender instanceof Player)) {
for (GameEntity ge : getAllPossibleDefenders(attacker.getController())) { for (GameEntity ge : getAllPossibleDefenders(attacker.getController())) {
if (!defender.equals(ge) && ge instanceof Player) { if (!ge.equals(defender) && ge instanceof Player) {
// found a player which does not goad that creature // found a player which does not goad that creature
// and creature can attack this player or planeswalker // and creature can attack this player or planeswalker
if (!attacker.isGoadedBy((Player) ge) && !ge.hasKeyword("Creatures your opponents control attack a player other than you if able.") && canAttack(attacker, ge)) { if (!attacker.isGoadedBy((Player) ge) && !ge.hasKeyword("Creatures your opponents control attack a player other than you if able.") && canAttack(attacker, ge)) {
@@ -250,7 +250,7 @@ public class CombatUtil {
// Quasi-goad logic for "Kardur, Doomscourge" etc. that isn't goad but behaves the same // Quasi-goad logic for "Kardur, Doomscourge" etc. that isn't goad but behaves the same
if (defender != null && defender.hasKeyword("Creatures your opponents control attack a player other than you if able.")) { if (defender != null && defender.hasKeyword("Creatures your opponents control attack a player other than you if able.")) {
for (GameEntity ge : getAllPossibleDefenders(attacker.getController())) { for (GameEntity ge : getAllPossibleDefenders(attacker.getController())) {
if (!defender.equals(ge) && ge instanceof Player) { if (!ge.equals(defender) && ge instanceof Player) {
if (!ge.hasKeyword("Creatures your opponents control attack a player other than you if able.") && canAttack(attacker, ge)) { if (!ge.hasKeyword("Creatures your opponents control attack a player other than you if able.") && canAttack(attacker, ge)) {
return false; return false;
} }

View File

@@ -55,12 +55,6 @@ public class TriggerCounterAddedOnce extends Trigger {
* @param runParams*/ * @param runParams*/
@Override @Override
public final boolean performTest(final Map<AbilityKey, Object> runParams) { public final boolean performTest(final Map<AbilityKey, Object> runParams) {
if (hasParam("FirstTime")) {
if (!(boolean) runParams.get(AbilityKey.FirstTime)) {
return false;
}
}
if (hasParam("CounterType")) { if (hasParam("CounterType")) {
final CounterType addedType = (CounterType) runParams.get(AbilityKey.CounterType); final CounterType addedType = (CounterType) runParams.get(AbilityKey.CounterType);
final String type = getParam("CounterType"); final String type = getParam("CounterType");
@@ -83,6 +77,12 @@ public class TriggerCounterAddedOnce extends Trigger {
return false; return false;
} }
if (hasParam("FirstTime")) {
if (!(boolean) runParams.get(AbilityKey.FirstTime)) {
return false;
}
}
return true; return true;
} }

View File

@@ -4,9 +4,10 @@ Types:Creature Wolf
PT:5/5 PT:5/5
T:Mode$ AttackerBlockedByCreature | ValidCard$ Creature | ValidBlocker$ Card.Self | Execute$ TrigDamageAttacker | TriggerDescription$ Whenever CARDNAME blocks or becomes blocked by a creature, CARDNAME deals 3 damage to that creature and 3 damage to that creature's controller. T:Mode$ AttackerBlockedByCreature | ValidCard$ Creature | ValidBlocker$ Card.Self | Execute$ TrigDamageAttacker | TriggerDescription$ Whenever CARDNAME blocks or becomes blocked by a creature, CARDNAME deals 3 damage to that creature and 3 damage to that creature's controller.
T:Mode$ AttackerBlockedByCreature | ValidCard$ Card.Self | ValidBlocker$ Creature | Execute$ TrigDamageBlocker | Secondary$ True | TriggerDescription$ Whenever CARDNAME blocks or becomes blocked by a creature, CARDNAME deals 3 damage to that creature and 3 damage to that creature's controller. T:Mode$ AttackerBlockedByCreature | ValidCard$ Card.Self | ValidBlocker$ Creature | Execute$ TrigDamageBlocker | Secondary$ True | TriggerDescription$ Whenever CARDNAME blocks or becomes blocked by a creature, CARDNAME deals 3 damage to that creature and 3 damage to that creature's controller.
SVar:TrigDamageAttacker:DB$ DealDamage | Defined$ TriggeredAttackerLKICopy | NumDmg$ 3 | SubAbility$ DBDamageAtk SVar:TrigDamageAttacker:DB$ DealDamage | Defined$ TriggeredAttackerLKICopy | NumDmg$ 3 | DamapeMap$ True | SubAbility$ DBDamageAtk
SVar:TrigDamageBlocker:DB$ DealDamage | Defined$ TriggeredBlockerLKICopy | NumDmg$ 3 | SubAbility$ DBDamageBlk SVar:TrigDamageBlocker:DB$ DealDamage | Defined$ TriggeredBlockerLKICopy | NumDmg$ 3 | DamapeMap$ True | SubAbility$ DBDamageBlk
SVar:DBDamageAtk:DB$ DealDamage | Defined$ TriggeredAttackerController | NumDmg$ 3 SVar:DBDamageAtk:DB$ DealDamage | Defined$ TriggeredAttackerController | NumDmg$ 3 | SubAbility$ DBDamageResolve
SVar:DBDamageBlk:DB$ DealDamage | Defined$ TriggeredBlockerController | NumDmg$ 3 SVar:DBDamageBlk:DB$ DealDamage | Defined$ TriggeredBlockerController | NumDmg$ 3 | SubAbility$ DBDamageResolve
SVar:DBDamageResolve:DB$ DamageResolve
SVar:HasCombatEffect:TRUE SVar:HasCombatEffect:TRUE
Oracle:Whenever Assembled Alphas blocks or becomes blocked by a creature, Assembled Alphas deals 3 damage to that creature and 3 damage to that creature's controller. Oracle:Whenever Assembled Alphas blocks or becomes blocked by a creature, Assembled Alphas deals 3 damage to that creature and 3 damage to that creature's controller.

View File

@@ -1,10 +1,9 @@
Name:Reins of Power Name:Reins of Power
ManaCost:2 U U ManaCost:2 U U
Types:Instant Types:Instant
A:SP$ UntapAll | Cost$ 2 U U | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | ValidCards$ Creature | RememberTargets$ True | RememberUntapped$ True | SubAbility$ DBUnTapYours | SpellDescription$ Untap all creatures you control and all creatures target opponent controls. You and that opponent each gain control of all creatures the other controls until end of turn. Those creatures gain haste until end of turn. A:SP$ UntapAll | Cost$ 2 U U | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | ValidCards$ Creature.YouCtrl,Creature.TargetedPlayerCtrl | SubAbility$ DBGainCtrl | SpellDescription$ Untap all creatures you control and all creatures target opponent controls. You and that opponent each gain control of all creatures the other controls until end of turn. Those creatures gain haste until end of turn.
SVar:DBUnTapYours:DB$ UntapAll | ValidCards$ Creature.YouCtrl | RememberUntapped$ True | SubAbility$ DBGainCtrl SVar:DBGainCtrl:DB$ GainControl | AllValid$ Creature.TargetedPlayerCtrl | AddKWs$ Haste | NewController$ You | LoseControl$ EOT | RememberControlled$ True | StackDescription$ None | SubAbility$ DBGainCtrlOpp
SVar:DBGainCtrl:DB$ GainControl | AllValid$ Creature.IsRemembered+RememberedPlayerCtrl | AddKWs$ Haste | NewController$ You | LoseControl$ EOT | ForgetControlled$ True | StackDescription$ None | SubAbility$ DBGainCtrlOpp SVar:DBGainCtrlOpp:DB$ GainControl | AllValid$ Creature.IsNotRemembered+YouCtrl | AddKWs$ Haste | NewController$ Targeted | LoseControl$ EOT | StackDescription$ None | SubAbility$ DBCleanup
SVar:DBGainCtrlOpp:DB$ GainControl | AllValid$ Creature.IsRemembered+YouCtrl | AddKWs$ Haste | NewController$ Player.IsRemembered | LoseControl$ EOT | StackDescription$ None | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
AI:RemoveDeck:All AI:RemoveDeck:All
Oracle:Untap all creatures you control and all creatures target opponent controls. You and that opponent each gain control of all creatures the other controls until end of turn. Those creatures gain haste until end of turn. Oracle:Untap all creatures you control and all creatures target opponent controls. You and that opponent each gain control of all creatures the other controls until end of turn. Those creatures gain haste until end of turn.

View File

@@ -1,8 +1,8 @@
Name:Twist Allegiance Name:Twist Allegiance
ManaCost:6 R ManaCost:6 R
Types:Sorcery Types:Sorcery
A:SP$ GainControl | Cost$ 6 R | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | AllValid$ Creature.TargetedPlayerCtrl | RememberTargets$ True | AddKWs$ Haste | Untap$ True | NewController$ You | LoseControl$ EOT | RememberControlled$ True | StackDescription$ SpellDescription | SubAbility$ DBGainCtrlOpp | SpellDescription$ You and target opponent each gain control of all creatures the other controls until end of turn. Untap those creatures. Those creatures gain haste until end of turn. A:SP$ GainControl | Cost$ 6 R | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | AllValid$ Creature.TargetedPlayerCtrl | AddKWs$ Haste | Untap$ True | NewController$ You | LoseControl$ EOT | RememberControlled$ True | StackDescription$ SpellDescription | SubAbility$ DBGainCtrlOpp | SpellDescription$ You and target opponent each gain control of all creatures the other controls until end of turn. Untap those creatures. Those creatures gain haste until end of turn.
SVar:DBGainCtrlOpp:DB$ GainControl | AllValid$ Creature.IsNotRemembered+YouCtrl | AddKWs$ Haste | NewController$ Player.IsRemembered | Untap$ True | LoseControl$ EOT | StackDescription$ None | SubAbility$ DBCleanup SVar:DBGainCtrlOpp:DB$ GainControl | AllValid$ Creature.IsNotRemembered+YouCtrl | AddKWs$ Haste | NewController$ Targeted | Untap$ True | LoseControl$ EOT | StackDescription$ None | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
AI:RemoveDeck:All AI:RemoveDeck:All
Oracle:You and target opponent each gain control of all creatures the other controls until end of turn. Untap those creatures. Those creatures gain haste until end of turn. Oracle:You and target opponent each gain control of all creatures the other controls until end of turn. Untap those creatures. Those creatures gain haste until end of turn.