chessmasterhong/WaterEmblem — pull request #23 by DrkSephy (2014-03-07 00:49:05+00:00)
Title: Adding stat computation methods, fleshing out equipment system

This pull request contains a bunch of helper methods to compute stats, as well as working on an actual equipment system. Here is a rundown of the changes:

**Methods**

* Added method for computing the base hit rate of a unit, which is derived from their skl and luk stats.
* Added method for computing the critical hit rate aspects of a unit.
* Added method for computing the attack speed of a unit, useful for determining the number of attacks a unit will perform (max 2).
* Added method for computing the evade rate of a unit. This is dependent of the attack speed of a unit.
* Added derived stats to enemies and players, used for accumulating stats from weapons.

**Equipment System**
* Added method for storing the stats of an equipped weapon. The stats are initially stored inside of the mods of the units.
* Added method for adding and storing the final stats applied, which are stored inside of derived stats. Derived stats is equal to the sum of the mods + base stats.
* Fixed all bugs regarding stats being able to stack infinitely, by separating stats into mod, stat and derived_stat.
* Added method for clearing the mods of a weapon, to prevent derived_stats from climbing infinitely.
* Hooked up the equipment summary modal. It shows the improvements/downgrades by equipping various weapons.
* I've tested this system by equipping different weapons and battling, everything works fine.
* As of right now, the equipment system is basically almost complete.
* I've currently console.log'ed most of the computable stats inside of the equipping menus, just as a test.

**Bugs**
* Due to the way the text of an item is spawned, the game will through errors if a unit with no items tries to open the inventory.
* When equipping weapons, the modal will not update if the player selected different weapons in a row. For example, if you selected "Iron Sword", it will update to show you the bonuses/losses of equipping it. However, clicking another weapon will not update it; the player has to equip the item they first selected and then try and equip something else to see the changes.

**Future**
* Currently, I'm not sure of the best place/how to equip the first item in the unit's inventory. Currently, the unit has to rely on their base stats until they equip an item, which isn't good.
* By having the first item equipped (if equip-able), it will be a good touch to the game. I'll look into this.
* More stuff to come in the future.