chessmasterhong/WaterEmblem — pull request #14 by DrkSephy (2014-02-27 21:44:24+00:00)
Title: Implemented simple version of item equipping/item swapping

This pull request contains the following:

* By Pressing [ i ], the item menu appears.
* Left clicking [items] spawns buttons to enumerate the active player's items.
* By left clicking on the first item or second item, the [EQUIP] button will appear.
* If we left click [EQUIP] after selected the first item, that item will be equipped. In the near future, we can insert an equip function here to add the stats of that weapon to the active player's stats.
* If we left click [EQUIP] after selecting the second item, the items will be swapped, making the second item swap places with the first item (After equipping an item, it moves to the first item slot). A function for swapping items has been implemented, it works for any number of elements.
* After equipping, if a swap occurs, the buttons will be redrawn to reflect the new ordering of the elements.

Problems with Implementation
----------------------------------------
Currently, there are a few problems with this approach. What is the player decides to equip a different weapon after equipping one already? We end up with having to spawn an infinite number of buttons to reflect this. There is no "state" persistence. We can't go back to a previous "state"...or can we?

Currently, we kill the [ITEM] Button when we click it. We could keep it around, and when the player clicks it again, it would repeat this process again (this time it would spawn the updated array of items, if a swap occurred). To do this, whenever the [ITEM] button is clicked, we could clear all existing buttons except itself to begin the loop again, then spawn the item buttons, and then proceed with selecting and equipping items. I think this would be the best approach for the time being, I think it can work. I'll explain more in person, but I think testing this out will make it clear what I'm saying.