It is currently 25 Apr 2024, 10:20
   
Text Size

Bug Fix & Request for Commit Privileges

Post MTG Forge Related Programming Questions Here

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

Bug Fix & Request for Commit Privileges

Postby rikimbo » 07 Jun 2014, 00:40

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);
   }

   (...)
}
User avatar
rikimbo
 
Posts: 52
Joined: 25 Mar 2014, 14:15
Location: Winnipeg
Has thanked: 10 times
Been thanked: 7 times

Re: Bug Fix & Request for Commit Privileges

Postby Chris H. » 08 Jun 2014, 13:01

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.
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: Bug Fix & Request for Commit Privileges

Postby rikimbo » 09 Jun 2014, 01:03

Awesome. I just committed the changes to fix the bug. I'm excited to start contributing more to this project. :)
User avatar
rikimbo
 
Posts: 52
Joined: 25 Mar 2014, 14:15
Location: Winnipeg
Has thanked: 10 times
Been thanked: 7 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 71 guests


Who is online

In total there are 71 users online :: 0 registered, 0 hidden and 71 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 71 guests

Login Form