#ifndef RULES_H
#define RULES_H

#include <stdint.h>

#include "../util/Session.h"
#include "../util/SlotStorage.h"
#include "../state/StateDefines.h"

#include "AttackPath.h"
#include "DefenseArray.h"
#include "PlayerAbility.h"
#include "Player.h"

#include <vector>
#include <string>
#include <map>
#include <sstream>
using namespace std;

class Session;

//Rules contain lots of logic for the game.
class Rules {
 public:
  Rules ();
  ~Rules ();

  void startState (int state);

  void clear();
  void clearPlayerAttacksRound();
  void clearPlayerDefenseRound();

  //player's abilities.
  bool getPlayerAbility(map<string, PlayerAbility>::iterator & ans, int slot);
  void addPlayerAbility(const string &, int slot = -1);

  //makes an attack path
  bool getAttackPath(map<string, AttackPath>::iterator & ans);
  bool addAttackPath(const string &);

  void updatePowerPreviewText (vector<FormattedText>& attackPreviewText);

  //makes a defense array
  void addDefenseArray(const string & name);
  DefenseArray & getDefenseArray();
  void prepareAndAddDefensePoint(const string & name);
  int getNumberOfDefensePoints();

  //when the user clicks on a path, check to see if it should halt all points.
  bool checkForCriticalDefense (vector<int>& indx);
  //During a defense round, a point escaped. Remove it from the current player's battle armor.
  bool defensePointEscaped(int);
  //Returns true if the player's battle armor is negative.
  bool playerFailedDefense();

  //session
  void setSession (Session *);
  Session * getSession ();

  //AttackPattern
  vector<HitBox*> & getAttackPatternPoints();
  vector<int> & getAttackPatternSegments();
  vector<int> & getAttackPatternPointer();

  void getButtonIcons (vector<string> & str);  

  //Player Access
  Player * getPlayer();

 private:
  Session * session;
  Player player1;
  map <string, AttackPath> playerAttackPaths;
  DefenseArray playerDefenseArray;

  //Player Attack Pattern
  vector<HitBox*> attackPatternPoints;
  vector<int> attackPatternSegments;
  vector<int> attackPatternPointer;
};

#endif
