Page 1 of 1

Weird behavior of the Stack

PostPosted: 19 Sep 2011, 17:05
by Sloth
I've just noticed a change in the behavior of the stack:
- When there are two abilities on the stack, I can only see the description of the last (even when I mouse over the other). Also the first ability takes the color of the second.
- When I cast Counterspell I get this error:
| Open
java.lang.NullPointerException
at forge.AllZoneUtil.getCardsIn(AllZoneUtil.java:83)
at forge.card.spellability.Target_Selection.chooseValidInput(Target_Selection.java:191)
at forge.card.spellability.Target_Selection.chooseTargets(Target_Selection.java:158)
at forge.card.spellability.SpellAbility_Requirements.fillRequirements(SpellAbility_Requirements.java:90)
at forge.card.spellability.SpellAbility_Requirements.fillRequirements(SpellAbility_Requirements.java:62)
at forge.GameAction.playSpellAbility(GameAction.java:2111)
at forge.GameAction.playCard(GameAction.java:1598)
at forge.gui.input.Input_PassPriority.selectCard(Input_PassPriority.java:57)

- I also noticed a lot of cases where I can't cast certain spells in my hand.

I guess your changes are responsible for this Max.

Re: Weird behavior of the Stack

PostPosted: 19 Sep 2011, 17:51
by Max mtg
Most definetelly, give me a WTR for each, I'll check them.

Re: Weird behavior of the Stack

PostPosted: 19 Sep 2011, 18:05
by Sloth
Max mtg wrote:Most definetelly, give me a WTR for each, I'll check them.
What do you want a Weapons Test Range for? (sorry I don't know this abbreviation)

Re: Weird behavior of the Stack

PostPosted: 19 Sep 2011, 18:08
by Hellfish
Way To Reproduce? ;)

Re: Weird behavior of the Stack

PostPosted: 19 Sep 2011, 18:19
by Sloth
Hellfish wrote:Way To Reproduce? ;)
Ah.
Use this in a setup game state file:
| Open
HumanCardsInHand=Arcbound Worker; Chaotic Goo; Counterspell; Brainstorm; Avian Changeling; Vindicate; Melira, Sylvok Outcast

Cast something then cast Brainstorm then try to cast Counterspell.

By the way, I remembered something:
I once tried to add the stack zone to this batch of code you replaced Max:
| Open
Code: Select all
/**
     * <p>getCardsInZone.</p>
     *
     * @param zone a {@link java.lang.String} object.
     * @param player a {@link forge.Player} object.
     * @return a {@link forge.CardList} object.
     */
    public static CardList getCardsInZone(final String zone, final Player player) {
        CardList all = new CardList();

        if (zone.contains(Constant.Zone.Graveyard)) {
            if (player == null || player.isHuman()) {
                all.addAll(AllZone.getHumanGraveyard().getCards());
            }
            if (player == null || player.isComputer()) {
                all.addAll(AllZone.getComputerGraveyard().getCards());
            }
        }
        if (zone.contains(Constant.Zone.Hand)) {
            if (player == null || player.isHuman()) {
                all.addAll(AllZone.getHumanHand().getCards());
            }
            if (player == null || player.isComputer()) {
                all.addAll(AllZone.getComputerHand().getCards());
            }
        }
        if (zone.contains(Constant.Zone.Battlefield)) {
            if (player == null || player.isHuman()) {
                all.addAll(AllZone.getHumanBattlefield().getCards());
            }
            if (player == null || player.isComputer()) {
                all.addAll(AllZone.getComputerBattlefield().getCards());
            }
        }
        if (zone.contains(Constant.Zone.Exile)) {
            if (player == null || player.isHuman()) {
                all.addAll(AllZone.getHumanExile().getCards());
            }
            if (player == null || player.isComputer()) {
                all.addAll(AllZone.getComputerExile().getCards());
            }
        }
        if (zone.contains(Constant.Zone.Library)) {
            if (player == null || player.isHuman()) {
                all.addAll(AllZone.getHumanLibrary().getCards());
            }
            if (player == null || player.isComputer()) {
                all.addAll(AllZone.getComputerLibrary().getCards());
            }
        }

        return all;
    }
I think I got some similar bugs, just by adding the entry and not even using the function. There must be some part of the code that uses the function with the stack as parameter, but can't handle it actually returning cards on the stack.

Re: Weird behavior of the Stack

PostPosted: 19 Sep 2011, 18:39
by friarsol
Hellfish wrote:Way To Reproduce? ;)
I've never seen this abbreviation before either. I guessed it might be that from the context but had to stare at it for a few minutes.

Re: Weird behavior of the Stack

PostPosted: 19 Sep 2011, 19:20
by Max mtg
I replaced that code for good, because we might have more players in some bright future and writing a code to check each zone personally, that is specifying its name right there, is no fun.
Stack... yes, no player owns it, so it should have been included here as a special case. It was in 10557

Game does not crash, but Counterspell is not working anyway - I'm investigating

Re: Weird behavior of the Stack

PostPosted: 19 Sep 2011, 23:02
by Max mtg

Re: Weird behavior of the Stack

PostPosted: 20 Sep 2011, 17:53
by Sloth
Sloth wrote:- When there are two abilities on the stack, I can only see the description of the last (even when I mouse over the other). Also the first ability takes the color of the second.
Did you find out where this bug came from Max?

Re: Weird behavior of the Stack

PostPosted: 20 Sep 2011, 21:28
by Max mtg
Sloth wrote:
Sloth wrote:- When there are two abilities on the stack, I can only see the description of the last (even when I mouse over the other). Also the first ability takes the color of the second.
Did you find out where this bug came from Max?
Of course, my friend, it comes from Hellfish's change at 10450. GuiDisplay4.java:736, index is missing at peekInstance

Re: Weird behavior of the Stack

PostPosted: 20 Sep 2011, 21:35
by Hellfish
Oh, hehe.. sorry :oops: