Page 1 of 1

Bug Fix & Request for Commit Privileges

PostPosted: 07 Jun 2014, 00:40
by rikimbo
I recently checked out a copy of the repository, and I've fixed a bug on my local copy. As Chris suggested, I'm going to post the bug fix here, as well as a bit of my background. I'd like to contribute to this project.

Me:
I am a software developer for a small robotics company. I work primarily in C#, but most of my programming during my undergraduate degree was in Java. I'm mostly interested in the AI component of Forge, but I want to spend some time tracking down bugs to learn the code base.

The bug:
The Licids (such as Leeching Licid) go into an alternate state when they their ability is activated and become enchantments. When a Licid is in the alternate state, its picture does not show on the battlefield, or in the card image panel.

The problem:
The getCard method in CardFactory sets the image key for a card. It sets an image key for each alternate state of the card, as well. There is no branch for the Licid alternate state, so the key set for this state is the default (""). When the image cache is queried to obtain the image for a card in this state, the key that gets sent to the cache is "".

The solution:
Add a method to the Card class to identify whether or not the card has the alternate Licid state. (This fits wit the current model, which also has methods for isFlipCard and isSplitCard, which have a similar structure.)
Code: Select all
public final boolean isLicid() {
    return characteristicsMap.containsKey(CardCharacteristicName.Licid);
}
Then add a branch to the logic in the CardFactory.getCard method, to set the image key for the alternate Licid state to the same key as the original card image:
Code: Select all
if (c.hasAlternateState()) {
   if (c.isFlipCard()) {
      (...)
   }
   else if (c.isDoubleFaced() && cp instanceof PaperCard) {
      (...)
   }
   else if (c.isSplitCard()) {
      (...)
   }
   else if (c.isLicid()) {
      c.setState(CardCharacteristicName.Licid);
      c.setImageKey(originalPicture);
   }

   (...)
}

Re: Bug Fix & Request for Commit Privileges

PostPosted: 08 Jun 2014, 13:01
by Chris H.
Looks good to me. If you make an official request to join the forge usergroup via the

slightly magic -> user control panel -> usergroups -> developers - forge

then someone will likely give you your commit privs within a couple of days.

Re: Bug Fix & Request for Commit Privileges

PostPosted: 09 Jun 2014, 01:03
by rikimbo
Awesome. I just committed the changes to fix the bug. I'm excited to start contributing more to this project. :)