magefree / mage

Magic Another Game Engine
http://xmage.today
MIT License
1.81k stars 748 forks source link

NPE in Hall of the Bandit Lord, code needs reworked #12162

Open catman123456 opened 2 months ago

catman123456 commented 2 months ago

When the computer played [[Ratchet, Field Medic]] using [[Hall of the Bandit Lord]] this happened

java.lang.NullPointerException Server version: 1.4.52-V7-beta9 (build: 2024-04-16 23:12) Stack trace: mage.game.GameImpl.addEffect(GameImpl.java:1900) mage.cards.h.HallOfTheBanditLordWatcher.watch(HallOfTheBanditLord.java:101) mage.watchers.Watchers.watch(Watchers.java:37) mage.game.GameState.handleEvent(GameState.java:943) mage.game.GameState.handleSimultaneousEvent(GameState.java:803) mage.game.GameImpl.resolve(GameImpl.java:1775) mage.game.GameImpl.playPriority(GameImpl.java:1689) mage.game.turn.Step.priority(Step.java:67) mage.game.turn.Phase.playStep(Phase.java:205) mage.game.turn.Phase.play(Phase.java:91) mage.game.turn.Turn.play(Turn.java:137) mage.game.GameImpl.playTurn(GameImpl.java:1131) mage.game.GameImpl.play(GameImpl.java:1038) mage.game.GameImpl.start(GameImpl.java:1014) mage.server.game.GameWorker.call(GameWorker.java:34) mage.server.game.GameWorker.call(GameWorker.java:15) java.util.concurrent.FutureTask.run(FutureTask.java:266) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) java.lang.Thread.run(Thread.java:748)

image

github-actions[bot] commented 2 months ago

Ratchet, Field Medic // Ratchet, Rescue Racer - (Gatherer) (Scryfall) (EDHREC)

{2}{W} Legendary Artifact Creature — Robot 2/4 More Than Meets the Eye {1}{W} (You may cast this card converted for {1}{W}.) Lifelink Whenever you gain life, you may convert Ratchet. When you do, return target artifact card with mana value less than or equal to the amount of life you gained this turn from your graveyard to the battlefield tapped. :arrows_counterclockwise: Legendary Artifact — Vehicle 1/4 Living metal (As long as it's your turn, this Vehicle is also a creature.) Lifelink Whenever one or more nontoken artifacts you control are put into a graveyard from the battlefield, convert Ratchet. This ability triggers only once each turn.

Hall of the Bandit Lord - (Gatherer) (Scryfall) (EDHREC)

Legendary Land Hall of the Bandit Lord enters the battlefield tapped. {T}, Pay 3 life: Add {C}. If that mana is spent on a creature spell, it gains haste.

xenohedron commented 2 months ago

NPE presumably originates on line 100 here:

https://github.com/magefree/mage/blob/898952515e1270544b0d1f7ba63e81f97d7f2dab/Mage.Sets/src/mage/cards/h/HallOfTheBanditLord.java#L96-L104

but this code smells bad (effect added by watcher) and probably should be entirely reworked, see similar cards: https://scryfall.com/search?q=o%3A%22If%20that%20mana%20is%20spent%22