Any of your old code that used erase and ++ on the iterator is WRONG! You need to re assign the iterator.
===

Recording mouse clicks and playback.

Draw a mouse cursor.

Record live or record at end?
<Record at end>

Make a vector that stores motions, let it save.

OR

Continuously append? Hard drive is slow, but it's atomic.

Save playback when vector is N entries large, then empty the vector.
At startup, clear the file.
At closing, save the remainder to file.

Automatically save? Sure why not.

Add option to the game menu to save the recording.

You need to save stages and maps to the file. NO save that to a separate but necessary part.

===
Time to implement enemies.

EnemyUnits are Map Units.
Some kind of AI loop (in enemy I guess) tells 'em what to do.
enemies can be guardians.

Goal 1:

Ruleset has MapWayPoint stuff in it. Do I need that in there?

Make a version of drawprimitive that only draws pixels. Then you can use the non-locking version of put pixel for massive speedup.
Make a pixel storm graphic object that represents a "random" spread of pixels.

=====
make a function for common comparison of z depth among buttons.
======
It's time to load individual levels

No wait, load enemies.

Wait, I can't do that until I make a battle.
No I can load abilities.

Enemies have

a name
a frame to represent themselves
hmm, some kind of stats?

Ruleset loads enemy stats into enemy when it reads a new map.

So map has a list of enemies and positions for them. THen you refer to enemy buffer or something.

-Enemy
-Name | string
#-X | number
#-Y | number
#-MapUnitFrame | mapunitframe

How to store MapUnitFrame?
Enemy should have the mapunitframe name, along with the other animation.
Enemy should have the name, too.

MapUnit has the type of anim it wants.

Map has enemymapunit.

EnemyDuringBattle has in-battle animation data.

Need to make enemy manifest.
===
Enemy is different than EnemyMapUnit.
===
Added multiple Animated States to Renderer
      How do they sync with Map?
      Map sends a bunch of animated states, one for each toon.
===
During battle:
 Player
  Health
  EquippedAbilities
  BattleToon

 Enemy
  Health
  Abilities
  BattleToon

Battle toon for player, monster

Need to add when enemy should react with animations.
Maybe add etc. Notes?
Like type of reaction to this frame. So store a number in the frame.
===
Loading stuff for player.

====

Reworking formatted text

HelpRef takes the given text as fixed and changes the dimension of the box around it.
TextFeeder takes the dimensions as fixed and changes the text around it.

2) __ handles adding and repositioning text
TTF fonts have variable widths, so you must print the text character-by-character to know the final width.

What handles repos of text?
Renderer handles drawing states.
shippling handles drawing primitives.

make an aux file to shippingHandler that draws interfaces.

This will affect help box. Test that before you move on.

TextFeeder
3) keep a running total of the width of the last line.
And only the last line.

====

Preparing abilities:

abilities need an icon that fits on the Power Selector.
Add a 1-line description.

When the power is selected, the text window says:
_
PowerName___Recharge/Quantity
1-line description
#allowed misses & bonus damage (if no damage is possible, write YOU CAN'T DEAL DAMAGE WITH THIS!)
Drawing Difficulty
_
====
Need to make the power selector.

How to implement?

a) 10 buttons
Code already exists, easy to show clicked/unclicked
Need to coordinate button presses externally

b) 1 object inherited from button
copypasta code
easy to coordinate
Like a button, you can click on multiple regions to activate its 10 subsections.

primitive for power selector
1 for the 9 selectable power boxes
1 for a selected power box
1 for the shading used to mark a power is recharging
1 for the wait box
1 for the selected wait box
1 for the wait command itself

so, inheret from button.
Tell Renderer how to load and release data for power selector.

====
split ruleset into multiple files
main
map
battle
====
While exiting, add the name of resource you are freeing so the user knows what he forgot to manually unload.
====
Time for a massive rewrite!

Change this so you simply start at drawing your attack.
-Throw out a lot of states from Renderer and GameState

StateHandler replaces GameState

Pass hashes for options (String -> String and String -> int)

Add debug hooks to start at certain states.
*Ask Ruleset to make up values.
*Ask Renderer to load default assets.

Session and Parameters to hold all the data so I don't have to pass parameters willy-nilly

Session has a clear()
Params are valid when you enter a state
*Each State gets 2 Params
**One is fixed
**One is empty
*State uses params from fixed and adds to empty params
*StateHandler makes 2 params and uses pointers to change which one is which
**ParamA ParamB
**ParamOld = ParamA, ParamNew = ParamB (B is empty)
**after calling end of State
***empty ParamA
***ParamOld = ParamB, ParamNew = ParamA

Add a jump to state method in state handler, called by main

HitBoxes!

statehandler calls get hitboxes
state calls each object and asks for its hitboxes
state makes a vector of hitbox*
state sends mouse position to each hitbox*, asks to see if it hit
state asks object if it was hit

when object is asked to return hitboxes
adds origin coordinates, sets up dimensions
returns iterators of hitbox*

hitbox has
bool washit
2 ints for origin location
1 int for shapetype
3 vectors for shape information
(see if you can import whatever primitives use)
when you check to hit, clear the hit status first

State loop==
start -- called when the state is changed.
 (also calls renderer to startup.)

beforeDraw -- used to move hitboxes/AI
renderer draws to screen
gatherInput--StateHandler uses this, no state needs to be called
applyInput -- each state handles their own AI
(change state -- IF it wants to change state:)
  call endState to give it a chance to clean up
  Swap Params

==
When Renderer is closed, try to release all resources.
StateHandler should call Renderer and ask it to close all resources.
==
Macro functions to:
Compare all input against all hitboxes
Set up hitboxes against primitives?
==
Add function to test hitboxes against inputs
===
I need to make a way to handle massive numbers of Animated States.
===
Now it's time to remove GraphicTransformations.
===
Next, bring back the power selector.

1) Draw it.
Use built in graphics-don't load resources. Make 2 stamps, one for normal and one for selected.
Add a vector to describe how filled they should be. vector of FixedInt.
Add a vector of symbol resources so it knows what to draw on each one.
2) Mouse interactions with buttons
StateHandler sends input to the power selector, PS figures out what to do with it. StateHandler gets reaction.

===
Stubs for battle

Player powers:
  I Win - This power is easy to complete (3 points, huge initial radius) and deals lots of bonus damage.
  This is used:
  -to quickly end a battle.
  -to test the success screen

  LOL Fail - This power is hard to complete and should deal little damage. It should have a long recharge.
  This is used:
  -to test failure to attack.
  -to test recharging.

  Boosh - This is an item that does nothing.
  This is used:
  -to test the inability to choose a power with no inventory.

Enemy powers:
  Die, player - This is one point, stands still for 3 seconds then quickly zooms. The initial size should be HUGE. This deals max damage to the player if it hits.
  This is used:
  -to quickly end a battle.
  -to test the failure screen.
  Meh - This attack is very quick and deals minimal damage.

Stub player
  Equipped the Boosh (1 charge), I Win and LOL Fail powers.
  Has 100 HP

Stub enemy
  Has the Die, Player attack
  1 HP

*Click on PS to show which power was
*set power based on selected power
*load player abilities
*switch to enemy turn

Add PS to AttackPreview
    change rules to check for a selected attack preview
You can select a power on the PS.
    The PS will highlight.
    The text box will show if you can use this power right now.
    If you can use it right now, the battle clickzone will show the power preview.

Need to make TextContainer.
     -width, height
     -4-way margins
     -text font colors
     -vector of formatted text (and access to it)
     -line spacing for the text

Battle initiation
       Look at player's abilities
       Load attack patterns player abils needs.
===
Add a slot storage container, the smart way to contain objects and store them by slot.
===
LoadBattleData

Choosing battle data.
Rules store the index of the chosen ability.

Whenever you need to retrieve data, retrieve the iterator to the data.
Make sure it's valid data before using it.

If trying to draw, don't draw if it's invalid.
If trying to apply logic, autofail during drawing. Do not check for a startpoint during preview.
===
Enemy Turn
-Load specific Enemy patterns
-Switch Rounds once you defend

NOW
You need a stub, always make a player ability with side house

Move attack path loading into AttackPath.

Make a battle starts state so you can load

Synchronize loading.
Renderer
StateHandler
Rules
I don't want to worry about the loading order of resources.
=======
===
The renderer, when it starts a battle, has to ask for the button icons.

===
Time to load all battle data.

Required to start a battle:
Player

Right now it needs to reply to get abilities.

I will dump BattleAbility and PlayerDuringBattle.

Add to Player:
    clearDuringBattleData();
    startDuringBattleData();
        This will reset abilities to the their maximums.

Need to refactor player item-equipment stuff!

Player should have the slot storage of ability to slots.
run function to retrieve the object.
How to handle eqiupment/consumable?
The real way to do this is to make a single item object.

You can have more than 10 abilities, but only 10 equipped abilities.

You can make a copy. Or you can have 2 containers and move data between the two.

Container that you need:
key/value, key is a string of the name.
quantity of value is stored, so you have a reference count.
Make global counts of all the items in the container.
This can be a map with external functions.
 Add Quantity to the item.

Problem: Where's the abstraction layer?
 With Player. Ruleset will ask Player to handle everything.

Add item to player
1) Make sure you have room
2) If the item exists, increment quantity and return.
3) If it doesn't exist, load the item, make sure it's valid and add to inventory. Return.
 (add to player abilities)

Sell item from player
(Refund sell value to player's cash)
Decrement item

Decrement Item from player (amount. Default is 1, -1 means completely remove)
Find item
decrement quantity
if quantity <= 0
  remove item
  (try to remove player ability)

Remove player ability
Make sure there is only one source of the player ability to remove.
aka make sure nothing takes responsibility for it.

PlayerAbilities
To maintain one copy of data.

map (string, PlayerAbility) playerAbilities
These are the PAs the player has ready to equip.

1 slot storage (string) readiedAbilities
This is what Rules gets
Rules can ask the Player for the map(s, pa) :: iterator

This is what the player has equipped, ready to use.

vector (string) learnedAbilities
A list of the abilities the player can equip thanks to his training.

To ensure a PlayerAbility is orphaned
1) If it exists in learnedAbilities, it isn't orphaned
2) Look through the inventory to see if any have the same ability name.

Rules->Player Interface regarding player abilities
IN STUB LAND
Rules tells player to load a PlayerAbility.

Enemy
EnemyDuringBattle

====
Show player's stats
Need graphics for stats
Health (Big heart, little heart)
Armor (Shield + Number)
Accuracy (Crosshair + Number)
Damage (Explosion + Number)
Pierce (Arrow + Number)
Evade (Jumping a Hurdle + Number)
Luck (Clover + Number)

Money
XP

Show stats
Give levels of detail to show stats with.

For now, just show all stats.

Level 1
Health display

Level 2 All battle stats
All stats, 1 per line

Level 3
All stats, 2 per line

