Wednesday, October 30, 2019

Release 0.2 Third Issue

A bug was discovered while testing my enhancement of my second pull request, which after testing on the stable release, existed before my PR. I was feeling confident from my second pull request so I asked to tackle this bug. Man what a mistake, I didn't think it would take 3 weeks to fix and was even able to submit my fourth PR before this one, but damn was I proud albeit extremely exhausted after this was accepted and merged.
The process of a player summoning a creature is as follows:
  1. Open the creature dashboard to summon a creature
  2. Select creature to summon
  3. Click on the summon button
  4. Place the creature on the map
There are multiple ways to open the creature dashboard, one of which is by right clicking on the mouse. A bug was appearing when the player was trying to place a creature on the map but right clicked on
  1. A unit on the map
  2. Empty space on the map
  3. Anywhere on the map
After a bit of investigation, I found the issue leading to the bug
  1. Right clicking a creature to view it calls showCreature function from the hexgrid.js
  2. The showCreature accepts a parameter of the passed creatureType
  3. The shown creature is then saved in a variable called this.selectedCreature
  4. When materializing(summoning) the creature, it uses the this.selectedCreature value. This causes an error because a player cannot have two of the same creatures on the field at one time.
The fix was extremely frustrating, because as a contributor starting out in open source and randomly choosing projects we don't read the whole code base. After all was said and done I had contributed about ~200 lines as the simple bug was actually a lot more complicated due to all the other functions interacting with each other.


I was extremely grateful as the maintainer is always available, usually replying within the hour and extremely thorough with his testing. After submitting which I thought was a fix, I found out there were other ways to access the creature dashboard... by clicking on the portrait of creatures on the field. Even worse this portrait option was written totally different from opening the dashboard by right clicking, or through a hotkey on the keyboard. This caused a lot of headaches as one fix, affected the other way of opening a dashboard. 

After some discussion and back and forth with the maintainer, I was able to submit a PR which took care of the bug and enhanced game play at the request of the maintainer. Feel free to view all the changes here!

No comments:

Post a Comment

Attempt at Creating a Clone of Adventure Capitalist

After about 3 weeks working on this project, I'm kind of done. Built with React/Node/Redis/SocketIO I learned a lot. The reason I say I&...