magefree / mage

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

Bug with hint on Ramunap Hydra #9177

Closed jeffwadsworth closed 2 years ago

jeffwadsworth commented 2 years ago

If this card is in the game, the following error occurs:

java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:206)
    at mage.player.ai.ComputerPlayer6.addActionsTimed(ComputerPlayer6.java:442)
    at mage.player.ai.ComputerPlayer7.calculateActions(ComputerPlayer7.java:113)
    at mage.player.ai.ComputerPlayer7.priorityPlay(ComputerPlayer7.java:63)
    at mage.player.ai.ComputerPlayer7.priority(ComputerPlayer7.java:37)
    at mage.game.GameImpl.playPriority(GameImpl.java:1523)
    at mage.game.turn.Step.priority(Step.java:61)
    at mage.game.turn.Phase.playStep(Phase.java:184)
    at mage.game.turn.Phase.play(Phase.java:89)
    at mage.game.turn.Turn.play(Turn.java:132)
    at mage.game.GameImpl.playTurn(GameImpl.java:1042)
    at mage.game.GameImpl.play(GameImpl.java:952)
    at mage.game.GameImpl.start(GameImpl.java:928)
    at mage.server.game.GameWorker.call(GameWorker.java:34)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at mage.abilities.AbilityImpl.<init>(AbilityImpl.java:133)
    at mage.abilities.StaticAbility.<init>(StaticAbility.java:40)
    at mage.abilities.common.SimpleStaticAbility.<init>(SimpleStaticAbility.java:23)
    at mage.abilities.common.SimpleStaticAbility.copy(SimpleStaticAbility.java:28)
    at mage.abilities.common.SimpleStaticAbility.copy(SimpleStaticAbility.java:12)
    at mage.abilities.AbilitiesImpl.<init>(AbilitiesImpl.java:33)
    at mage.abilities.AbilitiesImpl.copy(AbilitiesImpl.java:39)
    at mage.abilities.AbilitiesImpl.copy(AbilitiesImpl.java:21)
    at mage.MageObjectImpl.<init>(MageObjectImpl.java:72)
    at mage.cards.CardImpl.<init>(CardImpl.java:116)
    at mage.cards.r.RamunapHydra.<init>(RamunapHydra.java:60)
    at mage.cards.r.RamunapHydra.copy(RamunapHydra.java:65)
    at mage.cards.r.RamunapHydra.copy(RamunapHydra.java:33)
    at mage.game.GameImpl.<init>(GameImpl.java:180)
    at mage.game.FreeForAll.<init>(FreeForAll.java:22)
    at mage.game.FreeForAll.copy(FreeForAll.java:42)
    at mage.game.FreeForAll.copy(FreeForAll.java:13)
    at mage.player.ai.SimulatedPlayer2.simulatePriority(SimulatedPlayer2.java:70)
    at mage.player.ai.ComputerPlayer6.simulatePriority(ComputerPlayer6.java:478)
    at mage.player.ai.ComputerPlayer6.addActions(ComputerPlayer6.java:290)
    at mage.player.ai.ComputerPlayer6$1.call(ComputerPlayer6.java:432)
    at mage.player.ai.ComputerPlayer6$1.call(ComputerPlayer6.java:429)

The problem code line:

this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new RamunapHydraBoostEffect(1, 1)).addHint(DesertControlledOrGraveyardCondition.getHint()));
jeffwadsworth commented 2 years ago

[[Ramunap Hydra]]

github-actions[bot] commented 2 years ago

Ramunap Hydra - (Gatherer) (Scryfall) (EDHREC)

{3}{G} Creature — Snake Hydra 3/3 Vigilance, reach, trample Ramunap Hydra gets +1/+1 as long as you control a Desert. Ramunap Hydra gets +1/+1 as long as there is a Desert card in your graveyard.

Alex-Vasile commented 2 years ago

This looks suspicious: https://github.com/magefree/mage/blob/313a19865aa72f090679f5703f5c01a03afe8adf/Mage/src/main/java/mage/abilities/condition/common/DesertControlledOrGraveyardCondition.java#L63-L66

jeffwadsworth commented 2 years ago

Yes, testing a fix.

jeffwadsworth commented 2 years ago

Putting "instance" for null prevents the error, but the hint is not shown. Will check out later if no one else does.

theelk801 commented 2 years ago

it’s my fault, just replace return null with return this

Alex-Vasile commented 2 years ago

it’s my fault, just replace return null with return this

I've seen some enums return instance and some return this. Is there a difference?

theelk801 commented 2 years ago

if there’s only one enum value then it’s the same so on older implementations it returns instance but then I started making ones that have multiple enum values and realized that this is better

Alex-Vasile commented 2 years ago

Putting "instance" for null prevents the error, but the hint is not shown. Will check out later if no one else does.

The hint works (adding a desert makes it appear), but I feel like it should be the kind of hint that is always visible and has the red sign or the green checkmark beside it.