It is currently 10 Sep 2025, 18:04
   
Text Size

Weird behavior of the Stack

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Weird behavior of the Stack

Postby Sloth » 19 Sep 2011, 17:05

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Weird behavior of the Stack

Postby Max mtg » 19 Sep 2011, 17:51

Most definetelly, give me a WTR for each, I'll check them.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Weird behavior of the Stack

Postby Sloth » 19 Sep 2011, 18:05

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)
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Weird behavior of the Stack

Postby Hellfish » 19 Sep 2011, 18:08

Way To Reproduce? ;)
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Weird behavior of the Stack

Postby Sloth » 19 Sep 2011, 18:19

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Weird behavior of the Stack

Postby friarsol » 19 Sep 2011, 18:39

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Weird behavior of the Stack

Postby Max mtg » 19 Sep 2011, 19:20

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
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Weird behavior of the Stack

Postby Max mtg » 19 Sep 2011, 23:02

Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Weird behavior of the Stack

Postby Sloth » 20 Sep 2011, 17:53

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?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Weird behavior of the Stack

Postby Max mtg » 20 Sep 2011, 21:28

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
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Weird behavior of the Stack

Postby Hellfish » 20 Sep 2011, 21:35

Oh, hehe.. sorry :oops:
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 54 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 54 users online :: 0 registered, 0 hidden and 54 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 54 guests

Login Form