So today as well as doing the arduous task of refactoring and documentation, I managed to get a new feature in and solve a bug.
New Feature - Attacks in battle sorted by speed
Attacks now account for speed, originally they would be done in order (all the players first and then the enemies), now they are sorted by the speed stat. Although this had no effect on gameplay as Dead Enemies could attack the player, therefore who attacks first in a turn was redundant.
Bug Solved - Multiple enemies of the same type could only do a maximum of one attack
I found out that when I was fighting 2 Rhydon's only one of them was attacking. This which due to the unique identifer for the attack was using their unique specie id (each Rhydon is a Rhydon therefore same ID), I changed it so each enemy the player fights has a unique id.
Bug Solved - Dead enemies could attack the player
Dead enemies could attack the player, not great but easy fix - two boolean checks - one to stop the attack being generated, another to stop the attack being used (in case a faster player character kills them before they have the time to use their attack)
Refactor - HashMap<Integer, ArrayList<AttackAction>> to ArrayList<ArrayList<AttackAction>>
Since I duplicated the ID out of the key of the hash map which stores attacks (getId was now a function in the Entity class, so I could use that). I had no need for a hash map, I could just convert it to a list.
Took a while to bug fix for this, but significantly reduced LOC in a couple of functions. Just need to change their JavaDocs later... But time for Pokemon Black 2! (Inspiration NOT procrastion!)
Self explanitory - also removed warnings.
Bug Solved - Players can attack dead enemies
Instead of attacking the dead enemy, the player attacks a random enemy. This took a suprising amount of time to implement.
The current output of a battle is now:
Cat(speed 9) inflicted 2147483647 points of damage on Headcrab using Pistol
Headcrab attempted to attack but is dead
Crowbar(speed 7) healed 50 points of health on Cat using Heal Group
Tu(speed 5) inflicted 2147483647 points of damage on Crowbar using Pistol
Halik attack redirected from Headcrab to nowhere
Tu experience increased by 19384
Halik experience increased by 19384
Cat experience increased by 19384
Not very exciting so I'll leave with a screenshot of battle mode! (Apologies as it's a bit hard to see)
Before the next dev post I hope to implement:
-When you are fighting enemies with the same name in a battle such as two Crowbars, their names will change to Crowbar I and Crowbar II.
-Make the menu in battles have a proper cursor
-Plan more of the game!
Tidak ada komentar:
Posting Komentar