It is currently 29 Oct 2025, 05:03
   
Text Size

Soulshift

Post MTG Forge Related Programming Questions Here

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

Soulshift

Postby Chris H. » 11 Dec 2010, 18:36

Someone reported that the cards with Soulshift no longer state that they have Soulshift in the card detail panel. I added the following code to Card.keywordsToText() right below Sloth's recent addition to remove "Curse" from auras:

Code: Select all
else if (keyword.get(i).startsWith("Soulshift")) {
    String k = keyword.get(i);
    sbLong.append(k).append("\r\n");
}
`
and Soulshift still does not appear. There is a short section of code in CardFactory that removes the intrinsicKeyword Soulshift. It then adds a DestroyCommand which is found in CardFactoryUtil.

The DestroyCommand creates an ability and the ability includes a setDescription() and a setStackDescription() statement. In a test game a creature with Soulshift was sacrificed and the Soulshift command was executed correctly. The setStackDescription() text appeared on the stack. But no setDescription() text was seen.

I had fun looking at the code and trying to figure this out but I am stuck. I added the missing Soulshift text to the text line for the 18 card txt files that have this ability. It is something of a cop out.
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: Soulshift

Postby friarsol » 11 Dec 2010, 18:51

My code (as usual after a release) is a mess right now. Try this:

In CardFactory after hasKeyword function add this function:

Code: Select all
    final static int hasKeyword(Card c, String k, int startPos) {
        ArrayList<String> a = c.getKeyword();
        for(int i = startPos; i < a.size(); i++)
            if(a.get(i).toString().startsWith(k)) return i;
       
        return -1;
    }
Also in Cardfactory, change Soulshift block that currently starts with:

Code: Select all
 while(hasKeyword(card, "Soulshift") != -1) {
to the following:
Code: Select all
int shiftPos = hasKeyword(card, "Soulshift");
while(shiftPos != -1) {
   int n = shiftPos;
   String parse = card.getKeyword().get(n).toString();
   
   String k[] = parse.split(":");
   final String manacost = k[1];
   
   card.addDestroyCommand(CardFactoryUtil.ability_Soulshift(card, manacost));
   shiftPos = hasKeyword(card, "Soulshift", n+1);
}//Soulshift
And see if that works.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Soulshift

Postby Chris H. » 11 Dec 2010, 22:48

Thank you Sol.

I just found a few spare moments and tried your suggestion. It works. I will merge this and a few improvements here and there. Another bug bites the dust.

:D
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: Soulshift

Postby Chris H. » 12 Dec 2010, 02:32

Chris H. wrote:I just found a few spare moments and tried your suggestion. It works. I will merge this and a few improvements here and there. Another bug bites the dust.
`
OK, I merged the bug fix, reverted the Soulshift cards and improved the readability of a few of the keywords that are listed in the card detail panel as part of Card.keywordsToText().

Overall, things are working correctly. I discovered that we appear to no longer have the madness keyword appearing in the card detail panel but I think I know how to fix this 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: Soulshift

Postby Chris H. » 12 Dec 2010, 02:50

Chris H. wrote:I discovered that we appear to no longer have the madness keyword appearing in the card detail panel but I think I know how to fix this issue.
`
Yep, I mis-typed the madness keyword into the filter.
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 12 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 12 users online :: 0 registered, 0 hidden and 12 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 12 guests

Login Form