It is currently 29 Oct 2025, 00:50
   
Text Size

enPump & enPumpCurse Auras missing spell description

Post MTG Forge Related Programming Questions Here

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

enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 14 Jun 2011, 20:06

I think that I finally may have found the reason why Auras with enPump or enPumpCurse do not have the spell description that is built in the keyword passed on ... it looks like the method public Spell_Permanent(Card sourceCard, Cost cost, Target tgt) {} is overwriting the text.

I think that line 152 in Spell_Permanent.Spell_Permanent(Card sourceCard, Cost cost, Target tgt) is the source of the problem.

I am not sure how to fix this. Slapshot fixed a similar bug that was adding a getSpellText to the end of the text returned by a call to getText.

Slapshot, can you work the same type of magic on this one?

Code: Select all
    public Spell_Permanent(Card sourceCard, Cost cost, Target tgt) {
        super(sourceCard, cost, tgt);
       
        if(CardFactory.hasKeyword(sourceCard,"Champion") != -1) {
            int n = CardFactory.hasKeyword(sourceCard, "Champion");
           
            String parse = sourceCard.getKeyword().get(n).toString();
            willChampion = true;
            championType = parse.split(":")[1];
        }
       
        if(sourceCard.isCreature()) {
           
            StringBuilder sb = new StringBuilder();
            sb.append(sourceCard.getName()).append(" - Creature ").append(sourceCard.getNetAttack());
            sb.append(" / ").append(sourceCard.getNetDefense());
            setStackDescription(sb.toString());
        }
        else setStackDescription(sourceCard.getName());
       
        setDescription(getStackDescription());
        if(willChampion) {
            sourceCard.addComesIntoPlayCommand(championCommandComes);
            sourceCard.addLeavesPlayCommand(championCommandLeavesPlay);
        }
       
    }//Spell_Permanent()
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby slapshot5 » 14 Jun 2011, 22:51

does something like:

Code: Select all
if( getDescription().equals("") ) {
       setDescription(getStackDescription());
}
-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 15 Jun 2011, 00:03

slapshot5 wrote:does something like:

Code: Select all
if( getDescription().equals("") ) {
       setDescription(getStackDescription());
}
`
Thank you for the code.

It looks like there may be something else happening here, not sure if I will be able to figure it out. I will at least try.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 15 Jun 2011, 19:26

I added Slapshot's code to forge.card.spellability.Spell_Permanent(Card sourceCard, Cost cost, Target tgt) and it unfortunately did not correct the problem. I did comment out the original:

Code: Select all
// setDescription(getStackDescription());
`
As a test I added these lines to the end of the .forge.card.cardFActory.enPump_Enchant() method:

Code: Select all
        System.out.println("sourceCard =               " + sourceCard.getName());
        System.out.println("spellDescription[0] =      " + spellDescription[0]);
        System.out.println("enchant.getDescription() = " + enchant.getDescription());
        System.out.println("\n");
`
I built and then ran the project and in the console I see for each of the auras using the enPump keyword the correct data. For example, this is what I see for Launch:

sourceCard = Launch
spellDescription[0] = Enchanted creature has flying.
enchant.getDescription() = Enchanted creature has flying.
`
To me it appears that the code is working at this point and the sa is being assigned the correct spell description. Yet something is apparently over writing it.

I now suspect that forge.card.spellability.Spell_Permanent(Card sourceCard, Cost cost, Target tgt) is not the culprit. Does anyone have an idea where else in the code this sa description may be overwritten?
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 19 Jun 2011, 14:09

Chris H. wrote:I now suspect that forge.card.spellability.Spell_Permanent(Card sourceCard, Cost cost, Target tgt) is not the culprit. Does anyone have an idea where else in the code this sa description may be overwritten?
`
I have spent some additional time trying to figure this problem out.

In my previous message I stated that the enPump keyword code is correctly building the spell description. And the Spell_Permanent() code does not appear to be over writing this spell description.

Several of the enPump auras have the spell description included in the "Text:" portion of the card txt file. I could add this missing data to the rest of the auras but I feel that this should be a last ditch effort.

Some of the auras using the enPump Keyword also have the cycling keyword. When cast, we want the choose window to display the descriptive spell text for both of the choices.

In a moment of either desperation or insight, I created a test deck with the aura Sicken. When I cast the Sicken aura the choose window displayed the descriptive spell text for both of the choices. Hmmm...

So I now feel that the problem is located in the forge.Card.getAbilityText() method. The getText() method calls the getAbilityText() method and the getAbilityText() method is supposed to be adding the SpellAbility to the descriptive text located in the card detail panel.

I am now getting in over my head unfortunately. But I think that the getAbilityText() method needs a few lines of code to add in the missing spell text.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Sloth » 20 Jun 2011, 16:46

I did some testing myself and this is what I found out:
If I add Auras to this check,
| Open
public String getAbilityText() {
if(isInstant() || isSorcery()) {

the ability text will be there, but "Enchant Creature" will be gone. :shock:

UPDATE: I think the problem lies here:
| Open
if (sa instanceof Spell_Permanent){
sb.insert(0, "\r\n");
sb.insert(0, sAbility);
}
else{
sb.append(sAbility);
sb.append("\r\n");
}
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Sloth » 20 Jun 2011, 17:16

I have a possible fix (in getAbilityText()):
| Open
Code: Select all
        for(SpellAbility sa : abilities){
           // only add abilities not Spell portions of cards
           if (!isPermanent())
              continue;
           
           if (sa instanceof Spell_Permanent && primaryCost && !isAura()){
              // For Alt costs, make sure to display the cost!
              primaryCost = false;
              continue;
           }

            String sAbility = sa.toString();
           
            if (sa instanceof Ability_Mana){
               if (addedManaStrings.contains(sAbility))
                  continue;
              addedManaStrings.add(sAbility);
            }

            if (sa instanceof Spell_Permanent && !isAura()){
               sb.insert(0, "\r\n");
               sb.insert(0, sAbility);
            }
            else{
               sb.append(sAbility);
               sb.append("\r\n");
            }
        }
Note the 2 "!isAura()" checks.
Maybe Auras with alternate costs will display wrong now. What do you think?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 20 Jun 2011, 18:10

Sloth wrote:I did some testing myself and this is what I found out:
If I add Auras to this check,

| Open
public String getAbilityText() {
if(isInstant() || isSorcery()) {


the ability text will be there, but "Enchant Creature" will be gone. :shock:
`
This part of the code has confused me on several occasions. The code is fairly long and complicated and it is hard to tell where the

Code: Select all
if(isInstant() || isSorcery())
`
code block ends and therefore where the code for permanents start. It may just be me but then again it might be nice to add in an easy to see comment.

The missing "Enchant Creature" that you noticed might be because we are not testing for this particular keyword in that section. Then again, the getText() method is now handling so much detail that is is hard to follow this code ... at least I understand it better than the old WheneverKeyword. :mrgreen:
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 20 Jun 2011, 18:34

Sloth wrote:UPDATE: I think the problem lies here:

| Open
if (sa instanceof Spell_Permanent){
sb.insert(0, "\r\n");
sb.insert(0, sAbility);
}
else{
sb.append(sAbility);
sb.append("\r\n");
}
`
Yep, I had come to the conclusion that the problem might be in this spot.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 21 Jun 2011, 20:14

I see that you merged in your fix. I quickly scanned through the auras and noticed a few oddities.

Some auras now have a second copy of the enPump text. I suspect that someone added the missing enPump text to the "Text:" line. Should be easy to find and to fix.

At least one aura now has it's card name at the end of the spell text. Gift of the Woods is the card that I noticed. These may be hard coded, but I am not sure at this time. If so, removing the spell text from the Text:" line and placing it into a spellDescription() in the code block might help.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Sloth » 21 Jun 2011, 20:29

Chris H. wrote:I see that you merged in your fix. I quickly scanned through the auras and noticed a few oddities.

Some auras now have a second copy of the enPump text. I suspect that someone added the missing enPump text to the "Text:" line. Should be easy to find and to fix.

At least one aura now has it's card name at the end of the spell text. Gift of the Woods is the card that I noticed. These may be hard coded, but I am not sure at this time. If so, removing the spell text from the Text:" line and placing it into a spellDescription() in the code block might help.
Mmh, Gift of the Woods has "K:enPump:0/0" so no description is generated. I guess we have to filter those out.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 21 Jun 2011, 20:42

Sloth wrote:
Chris H. wrote:I see that you merged in your fix. I quickly scanned through the auras and noticed a few oddities.

Some auras now have a second copy of the enPump text. I suspect that someone added the missing enPump text to the "Text:" line. Should be easy to find and to fix.

At least one aura now has it's card name at the end of the spell text. Gift of the Woods is the card that I noticed. These may be hard coded, but I am not sure at this time. If so, removing the spell text from the Text:" line and placing it into a spellDescription() in the code block might help.
Mmh, Gift of the Woods has "K:enPump:0/0" so no description is generated. I guess we have to filter those out.
`
Ugh, it looks like we both are right.

Checkout the hard coded card Earthbind:

Enchant creature

When Earthbind enters the battlefield, if enchanted creature has flying, Earthbind deals 2 damage to that creature and enchanted creature loses flying.
When Earthbind enters the battlefield, if enchanted creature has flying, Earthbind deals 2 damage to that creature and enchanted creature loses flying.
Earthbind
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 21 Jun 2011, 21:46

Chris H. wrote:Checkout the hard coded card Earthbind:

Enchant creature

When Earthbind enters the battlefield, if enchanted creature has flying, Earthbind deals 2 damage to that creature and enchanted creature loses flying.
When Earthbind enters the battlefield, if enchanted creature has flying, Earthbind deals 2 damage to that creature and enchanted creature loses flying.
Earthbind
`
I removed the spell description from the card txt file and I added a

Code: Select all
spell.setDescription("When Earthbind enters the battlefield, if enchanted creature has flying, Earthbind deals 2 damage to that creature and enchanted creature loses flying.");
`
to the code block for Earthbind and the card detail panel now looks like this:

Enchant creature

When Earthbind enters the battlefield, if enchanted creature has flying, Earthbind deals 2 damage to that creature and enchanted creature loses flying.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 22 Jun 2011, 23:09

Spent some more time trying to figure this out. I think that this is responsible for the double spell text and I think that it is safe to comment out this portion of the bug fix.

Code: Select all
        if(isAura()) {
            // Give spellText line breaks for easier reading
            sb.append(getSpellText().replaceAll("\\\\r\\\\n", "\r\n")).append("\r\n");
        }
`
This will still leave us with a handful of cards with the card name in the spell description. Not sure how we should fix this last issue.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: enPump & enPumpCurse Auras missing spell description

Postby Chris H. » 23 Jun 2011, 00:09

Chris H. wrote:This will still leave us with a handful of cards with the card name in the spell description. Not sure how we should fix this last issue.
`
I believe that rev 9966 will finally fix this issue. :mrgreen:
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 25 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 25 users online :: 0 registered, 0 hidden and 25 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 25 guests

Login Form