The process of a player summoning a creature is as follows:
- Open the creature dashboard to summon a creature
- Select creature to summon
- Click on the summon button
- 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
- A unit on the map
- Empty space on the map
- Anywhere on the map
After a bit of investigation, I found the issue leading to the bug
- Right clicking a creature to view it calls showCreature function from the hexgrid.js
- The showCreature accepts a parameter of the passed creatureType
- The shown creature is then saved in a variable called this.selectedCreature
- 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!