#ifndef ITEM_H
#define ITEM_H

#include <stdint.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>

#include "PlayerAbility.h"

#include <string>
using namespace std;

#include "PlayerDefines.h"

//Item. 
//All items have
//-A Name
//-A Price
//-Quantity.

//Items come in multiple flavors:

//Equipment: These items must be equipped and transfer stat bonuses to the Player. A Player can equip up to 3 pieces of equipment at a time.
//Equipment has:
//-Stat Boost for Accuracy, Damage, Health, Pierce, Armor, Luck, Evade, and Recharge Bonus.
//-Level requirements for each character class.

//Consumable: These items have limited quantity, but recharge immediately and can be purchased.
//Consumables have:
//-A PlayerAbility name they are emulating.

class Item {
  //common to all Items
 public:
  Item ();
  ~Item ();

  bool loadItem (const string &);
  bool loadItemHelper (xmlDocPtr doc, xmlXPathContextPtr xpathCtx, const string & xpath);

  void clear();
  
  //setters and getters for fields common to all items
  int getPrice ();
  void setPrice (int x);
  
  const string & getName();
  void setName(const string &);
  
  int getQuantity ();
  void setQuantity (int x);
  void addQuantity (int x);
  
  int getItemType ();

 private:
  string itemName;
  int price, quantity;
  int itemType;
  void setItemType (int);
  //Equipment-specific stuff
 public:
  void clearEquipment();

  int getAccuracyBoost ();
  int getDamageBoost ();
  int getHealthBoost ();
  int getPierceBoost ();
  int getArmorBoost ();
  int getLuckBoost ();
  int getEvadeBoost ();
  int getRechargeBoost ();

  void setAccuracyBoost (int x);
  void setDamageBoost (int x);
  void setHealthBoost (int x);
  void setPierceBoost (int x);
  void setArmorBoost (int x);
  void setLuckBoost (int x);
  void setEvadeBoost (int x);
  void setRechargeBoost (int x);

  int getLevelRequirement (int classID);
  void setLevelRequirement (int x, int classID);

  int getNumberEquipped ();
  bool equip ();
  bool unequip ();

 private:
  vector <int> levelRequirements;
  int accuracyBoost;
  int damageBoost;
  int hpBoost;
  int pierceBoost;
  int armorBoost;
  int luckBoost;
  int evadeBoost;
  int rechargeBoost;

  int numberEquipped;

  bool loadEquipment (xmlDocPtr doc, xmlXPathContextPtr xpathCtx, const string & xpath);
  //Consumable-specific stuff
 public:
  void clearConsumbale();

  const string & getConsumableAbility();
  void setConsumableAbility(const string &);  

 private:
  bool loadConsumable (xmlDocPtr doc, xmlXPathContextPtr xpathCtx, const string & xpath);  
  
  string consumableAbility;
};

#endif
