Bugs with X costs
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
11 posts
• Page 1 of 1
Bugs with X costs
by Sloth » 20 Apr 2013, 07:58
Numerous bugs with X costs have arised, where the player doesn't get to pay for X (X is set to 0).
Warbreak Trumpeter (morph up)
Clan Defiance (Charm)
Engineered Explosives (?)
I made some attempts to fix them (but nothing seriously) and failed, but this should get fixed for the next beta. So any ideas?
Warbreak Trumpeter (morph up)
Clan Defiance (Charm)
Engineered Explosives (?)
I made some attempts to fix them (but nothing seriously) and failed, but this should get fixed for the next beta. So any ideas?
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Bugs with X costs
by Max mtg » 20 Apr 2013, 09:19
Idea:
- Code: Select all
Index: CostPartMana.java
===================================================================
--- CostPartMana.java (revision 21085)
+++ CostPartMana.java (working copy)
@@ -112,7 +112,8 @@
ManaCostBeingPaid toPay = new ManaCostBeingPaid(getManaToPay(), restriction);
boolean xWasBilled = false;
- if (this.getAmountOfX() > 0 && !ability.getSVar("X").equals("Count$xPaid")) { // announce X will overwrite whatever was in card script
+ String xInCard = source.getSVar("X");
+ if (this.getAmountOfX() > 0 && !"Count$xPaid".equals(xInCard)) { // announce X will overwrite whatever was in card script
// this currently only works for things about Targeted object
int xCost = AbilityUtils.calculateAmount(source, "X", ability) * this.getAmountOfX();
byte xColor = MagicColor.fromName(ability.hasParam("XColor") ? ability.getParam("XColor") : "1");
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: Bugs with X costs
by Max mtg » 21 Apr 2013, 05:11
The patch worked for me, and noone has left any comment here, although they did have a chance to do so - ie Sloth and Sol both have been online since I posted the 'idea' patch.
Ok then, I'll commit.
Ok then, I'll commit.
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: Bugs with X costs
by Sloth » 21 Apr 2013, 06:57
Warbreak Trumpeter and Clan Defiance work now, but Engineered Explosives still does not.Max mtg wrote:The patch worked for me, and noone has left any comment here, although they did have a chance to do so - ie Sloth and Sol both have been online since I posted the 'idea' patch.
Ok then, I'll commit.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Bugs with X costs
by Max mtg » 21 Apr 2013, 07:54
That's a scripting problem already.Sloth wrote:but Engineered Explosives still does not.
To let human pay any X, the SVar:X needs to be Count$xPaid for cards that use X in cost and don't use announce (And I don't know how to turn on announce for SpellPermanents).
expression ValidCards$ Permanent.nonLand+cmcEQX also uses X, there is no code to use other variable here.
Solution? let there be EQY, EQZ and just any variable
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: Bugs with X costs
by Sloth » 21 Apr 2013, 08:15
Yup that worked. Thanks Max.Max mtg wrote:That's a scripting problem already.
To let human pay any X, the SVar:X needs to be Count$xPaid for cards that use X in cost and don't use announce (And I don't know how to turn on announce for SpellPermanents).
expression ValidCards$ Permanent.nonLand+cmcEQX also uses X, there is no code to use other variable here.
Solution? let there be EQY, EQZ and just any variable
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Bugs with X costs
by Max mtg » 21 Apr 2013, 08:25
That did work to pay an arbitrary X cost, but the card effect must be broken now (I didn't test it).
To enable other variables in 'EQ*' expression one needs to pay a visit to AbilityUtils:680.
To enable other variables in 'EQ*' expression one needs to pay a visit to AbilityUtils:680.
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: Bugs with X costs
by Max mtg » 21 Apr 2013, 08:37
Something like this:
- Code: Select all
String valid = type;
int eqIndex = valid.indexOf("EQ");
if (eqIndex >= 0) {
char reference = valid.charAt(eqIndex + 2); // take whatever goes after EQ
if( Character.isLetter(reference)) {
String varName = valid.substring(eqIndex + 2, 1); // single-letter names, not sure how to learn variable name length
valid = valid.replace(varName, Integer.toString(calculateAmount(source, varName, sa)));
}
}
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: Bugs with X costs
by Sloth » 21 Apr 2013, 09:38
No, it works correctly. hasProperty handles that.Max mtg wrote:That did work to pay an arbitrary X cost, but the card effect must be broken now (I didn't test it).
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Bugs with X costs
by Max mtg » 21 Apr 2013, 09:56
Ok, glad my assumption was wrong.
Let me commit the code quoted above anyway - maybe it'll be useful for some other cases.
Let me commit the code quoted above anyway - maybe it'll be useful for some other cases.
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: Bugs with X costs
by friarsol » 21 Apr 2013, 12:53
You could create a PermanentCreature (or noncreature as appropriate) to force Announce to be on in these circumstances.(And I don't know how to turn on announce for SpellPermanents).
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
11 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 17 guests