Bug Reports (snapshot builds)
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Bug Reports (snapshot builds)
by Agetian » 07 Jul 2013, 05:40
I tried it and it fixes one issue but seems to introduce another - I mean, you can definitely discard more than 1 card once it fires, but the effect can get screwed up later. Say, you discard your entire hand of 7 cards and your opponent has only 5 non-land cards in his hand. Then, you'll get a pop-up window asking you to choose cards from the opponent's hand to discard, but you can only select five (but the UI is waiting for you to select seven, so it won't let you click "OK"), which leads to a hang.swordshine wrote:I think it's a correct fix. Only four rites and Flux have "AnyNumber$ True" params in their discard effects.jsv wrote:From the 1.4.2 beta thread:I've looked at it, cards with "discard any number of cards" (Rites of Spring, Rites of Refusal, etc.) are all behave like this. As the code in DiscardEffect is rather hairy, I'm not sure if a simple hack in vein ofcc-drake wrote:- I can't discard more than one card to Last Rites.isn't going to introduce more problems than it solves...
- Code: Select all
--- card/ability/effects/DiscardEffect.java (revision 22427)
+++ card/ability/effects/DiscardEffect.java (working copy)
@@ -210,7 +210,7 @@
chooser.getGame().getAction().reveal(dPHand, p);
int min = sa.hasParam("AnyNumber") || sa.hasParam("Optional") ? 0 : numCards;
- int max = Math.min(validCards.size(), numCards);
+ int max = sa.hasParam("AnyNumber")? validCards.size(): Math.min(validCards.size(), numCards);
List<Card> toBeDiscarded = validCards.isEmpty() ? CardLists.emptyList : chooser.getController().chooseCardsToDiscardFrom(p, sa, validCards, min, max);
Also, I suggest to change line 399 in PlayerControllerHuman.java to this:
- Code: Select all
inp.setMessage(sa.hasParam("AnyNumber") ? "Discard up to %d cards" : "Discard %d cards");

- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 569 times
Re: Bug Reports (snapshot builds)
by swordshine » 07 Jul 2013, 06:09
swordshine wrote:Token cannot move to libraries when I cast Terminus or Azorius Charm
- Code: Select all
if (c.isToken()) {
return c;
}
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Bug Reports (snapshot builds)
by Agetian » 07 Jul 2013, 06:32
r22464: Actually committed an experimental fix for the bug with Last Rites and other similar cards. However, it contains an ugly hack that I'd like someone competent with effects to somehow resolve, if possible... Please take a look at lines 395-397 in PlayerControllerHuman.java. Right above that line, cntToKeepInHand is set to -1 deliberately if minimum is zero. However, with cards like Last Rites, where you have to discard up to N cards and then choose exactly N cards from the opponent's hand, having a negative cntToKeepInHand (say, it's set to -3 if you discarded 7 cards and the opponent only has 4 non-land cards in his hand) results in being unable to finish choosing cards for the AI to discard, leading to a hang. Setting it to 0 forcibly whenever there are not enough cards to account for the difference seems to fix Last Rites and similar cards, but...
This might actually break a lot... or not. I'm not sure. Please review, feel free to revert if necessary, and please consider properly fixing it. I'm not sure what to do with cntToKeepInHand properly.
- Agetian
This might actually break a lot... or not. I'm not sure. Please review, feel free to revert if necessary, and please consider properly fixing it. I'm not sure what to do with cntToKeepInHand properly.
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 569 times
Re: Bug Reports (snapshot builds)
by swordshine » 07 Jul 2013, 06:47
What about changing DiscardEffect line 213.Agetian wrote:r22464: Actually committed an experimental fix for the bug with Last Rites and other similar cards. However, it contains an ugly hack that I'd like someone competent with effects to somehow resolve, if possible... Please take a look at lines 395-397 in PlayerControllerHuman.java. Right above that line, cntToKeepInHand is set to -1 deliberately if minimum is zero. However, with cards like Last Rites, where you have to discard up to N cards and then choose exactly N cards from the opponent's hand, having a negative cntToKeepInHand (say, it's set to -3 if you discarded 7 cards and the opponent only has 4 non-land cards in his hand) results in being unable to finish choosing cards for the AI to discard, leading to a hang. Setting it to 0 forcibly whenever there are not enough cards to account for the difference seems to fix Last Rites and similar cards, but...
This might actually break a lot... or not. I'm not sure. Please review, feel free to revert if necessary, and please consider properly fixing it. I'm not sure what to do with cntToKeepInHand properly.
- Agetian
- Code: Select all
### Eclipse Workspace Patch 1.0
#P trunk
Index: src/main/java/forge/card/ability/effects/DiscardEffect.java
===================================================================
--- src/main/java/forge/card/ability/effects/DiscardEffect.java (revision 22464)
+++ src/main/java/forge/card/ability/effects/DiscardEffect.java (working copy)
@@ -210,7 +210,7 @@
if (mode.startsWith("Reveal") && p != chooser)
chooser.getGame().getAction().reveal(dPHand, p);
- int min = sa.hasParam("AnyNumber") || sa.hasParam("Optional") ? 0 : numCards;
+ int min = sa.hasParam("AnyNumber") || sa.hasParam("Optional") ? 0 : Math.min(validCards.size(), numCards);
int max = sa.hasParam("AnyNumber") ? validCards.size() : Math.min(validCards.size(), numCards);
List<Card> toBeDiscarded = validCards.isEmpty() ? CardLists.emptyList : chooser.getController().chooseCardsToDiscardFrom(p, sa, validCards, min, max);
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Bug Reports (snapshot builds)
by Agetian » 07 Jul 2013, 07:46
@ swordshine: Yep, agree! Committing the proper fix now.
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 569 times
Re: Bug Reports (snapshot builds)
by swordshine » 07 Jul 2013, 08:32
I cast Cloudshift on a token, that token can come back from the Exile zone.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Bug Reports (snapshot builds)
by Agetian » 07 Jul 2013, 10:20
r22464: AI opponent cast a spell that resulted in this crash (was fatal, had to shut down the game). The game that I played was a 1 vs. 3 Archenemy game.
- RuntimeException | Open
- Code: Select all
Forge Version: 1.4.3-SNAPSHOT-r22464M (mixed revisions detected; please update from the root directory)
Operating System: Linux 3.7.0-7-generic amd64
Java Version: 1.7.0_21 Oracle Corporation
java.lang.RuntimeException: ComputerUtil : payManaCost() cost was not paid for Recoil. Didn't find what to pay for B
at forge.game.ai.ComputerUtilMana.payManaCost(ComputerUtilMana.java:213)
at forge.game.ai.ComputerUtilMana.payManaCost(ComputerUtilMana.java:62)
at forge.card.cost.CostPartMana.payAI(CostPartMana.java:184)
at forge.card.cost.CostPayment.payComputerCosts(CostPayment.java:190)
at forge.game.ai.ComputerUtil.handlePlayingSpellAbility(ComputerUtil.java:109)
at forge.game.ai.AiController.playSpellAbilities(AiController.java:797)
at forge.game.ai.AiController.onPriorityRecieved(AiController.java:744)
at forge.game.player.PlayerControllerAi.takePriority(PlayerControllerAi.java:344)
at forge.game.phase.PhaseHandler.startFirstTurn(PhaseHandler.java:846)
at forge.game.GameAction.startGame(GameAction.java:1517)
at forge.game.Match$1.run(Match.java:102)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 569 times
Re: Bug Reports (snapshot builds)
by Agetian » 07 Jul 2013, 10:24
r22464: Dance, Pathetic Marionette (the Archenemy scheme) does not work properly - it always puts the creature from the first opponent into play, while it should instead give a choice letting the player choose which creature (from which opponent) to put into play.
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 569 times
Re: Bug Reports (snapshot builds)
by Sloth » 07 Jul 2013, 11:29
What mana sources where present?Agetian wrote:r22464: AI opponent cast a spell that resulted in this crash (was fatal, had to shut down the game). The game that I played was a 1 vs. 3 Archenemy game.
- RuntimeException | Open
- Code: Select all
Forge Version: 1.4.3-SNAPSHOT-r22464M (mixed revisions detected; please update from the root directory)
Operating System: Linux 3.7.0-7-generic amd64
Java Version: 1.7.0_21 Oracle Corporation
java.lang.RuntimeException: ComputerUtil : payManaCost() cost was not paid for Recoil. Didn't find what to pay for B
at forge.game.ai.ComputerUtilMana.payManaCost(ComputerUtilMana.java:213)
at forge.game.ai.ComputerUtilMana.payManaCost(ComputerUtilMana.java:62)
at forge.card.cost.CostPartMana.payAI(CostPartMana.java:184)
at forge.card.cost.CostPayment.payComputerCosts(CostPayment.java:190)
at forge.game.ai.ComputerUtil.handlePlayingSpellAbility(ComputerUtil.java:109)
at forge.game.ai.AiController.playSpellAbilities(AiController.java:797)
at forge.game.ai.AiController.onPriorityRecieved(AiController.java:744)
at forge.game.player.PlayerControllerAi.takePriority(PlayerControllerAi.java:344)
at forge.game.phase.PhaseHandler.startFirstTurn(PhaseHandler.java:846)
at forge.game.GameAction.startGame(GameAction.java:1517)
at forge.game.Match$1.run(Match.java:102)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Bug Reports (snapshot builds)
by Agetian » 07 Jul 2013, 13:10
Unfortunately, I didn't pay attention to that, there were 3 opponents, one of which was mono Black (and had, like, 4 Swamps), the other two-color R/W, and the other mono U. I'm not sure which lands those other two had in play, I'm sure they were mostly basic but there might have been a nonbasic land of some sort in play. If it happens again I'll pay extra attention to that and will let you know.Sloth wrote:What mana sources where present?Agetian wrote:r22464: AI opponent cast a spell that resulted in this crash (was fatal, had to shut down the game). The game that I played was a 1 vs. 3 Archenemy game.
- RuntimeException | Open
- Code: Select all
Forge Version: 1.4.3-SNAPSHOT-r22464M (mixed revisions detected; please update from the root directory)
Operating System: Linux 3.7.0-7-generic amd64
Java Version: 1.7.0_21 Oracle Corporation
java.lang.RuntimeException: ComputerUtil : payManaCost() cost was not paid for Recoil. Didn't find what to pay for B
at forge.game.ai.ComputerUtilMana.payManaCost(ComputerUtilMana.java:213)
at forge.game.ai.ComputerUtilMana.payManaCost(ComputerUtilMana.java:62)
at forge.card.cost.CostPartMana.payAI(CostPartMana.java:184)
at forge.card.cost.CostPayment.payComputerCosts(CostPayment.java:190)
at forge.game.ai.ComputerUtil.handlePlayingSpellAbility(ComputerUtil.java:109)
at forge.game.ai.AiController.playSpellAbilities(AiController.java:797)
at forge.game.ai.AiController.onPriorityRecieved(AiController.java:744)
at forge.game.player.PlayerControllerAi.takePriority(PlayerControllerAi.java:344)
at forge.game.phase.PhaseHandler.startFirstTurn(PhaseHandler.java:846)
at forge.game.GameAction.startGame(GameAction.java:1517)
at forge.game.Match$1.run(Match.java:102)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 569 times
Re: Bug Reports (snapshot builds)
by swordshine » 07 Jul 2013, 13:45
I got an NPE when I killed ai's Goblin Guide in the combat after its ability triggered. It seems this bug is related to DefendingPlayer.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Bug Reports (snapshot builds)
by Max mtg » 07 Jul 2013, 13:57
Agetian, this bug happens only when AI's first evaluation tells that there are enough usable mana sources... but when it comes to payment it turns out that restrictions don't allow to use that mana. So cards on table on AI's side matter.
swordshine, you ceratainly know how much we need a stack trace to locate the problem.
swordshine, you ceratainly know how much we need a stack trace to locate the problem.
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: Bug Reports (snapshot builds)
by friarsol » 07 Jul 2013, 16:15
r22480
I play Ante in Quest mode, and the Ante field doesn't actually seem to have the ante'd cards drawn anymore.
I play Ante in Quest mode, and the Ante field doesn't actually seem to have the ante'd cards drawn anymore.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Bug Reports (snapshot builds)
by Agetian » 07 Jul 2013, 16:37
kk I'll take a screenshot of the battlefield if it hits me again.Max mtg wrote:Agetian, this bug happens only when AI's first evaluation tells that there are enough usable mana sources... but when it comes to payment it turns out that restrictions don't allow to use that mana. So cards on table on AI's side matter.

- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 569 times
Re: Bug Reports (snapshot builds)
by friarsol » 07 Jul 2013, 19:05
r22480
Draws don't seem to resolve properly, and don't error.
Repro:
1. Start a new game
2. Add an Earthquake into your hand from Dev Panel
3. Generate mana and cast a X=20 Earthquake
4. Both player's life totals are listed as 0, but the GameEnd screen doesn't show up.
I thought I noticed another issue in the code where Game Draws weren't ignored during the games played to see if a match is over, but with this issue, I can't actually test that out.
Draws don't seem to resolve properly, and don't error.
Repro:
1. Start a new game
2. Add an Earthquake into your hand from Dev Panel
3. Generate mana and cast a X=20 Earthquake
4. Both player's life totals are listed as 0, but the GameEnd screen doesn't show up.
I thought I noticed another issue in the code where Game Draws weren't ignored during the games played to see if a match is over, but with this issue, I can't actually test that out.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Who is online
Users browsing this forum: No registered users and 31 guests