#include "CMain.hpp"
#include "CMap.hpp"

#ifndef CPLAYER_HPP
#define CPLAYER_HPP

#define MAX_LEVEL    11 // 10+1 position 0 doesn't count

#define NORTH		1
#define SOUTH		2
#define EAST		3
#define WEST		4

/* Types of the Equipment */
#define WEAR_HEAD       0
#define WEAR_ARM        1
#define WEAR_LEG        2
#define WEAR_RING       3
#define WEAR_WEAPON     4
#define MAX_EQUIP       5

#define TYPE_NONE       5 // special types of
#define TYPE_USABLE     6 // potions, magic items, usable during combat!


#define MAX_ITEMS       35  // How many total unique items are there in the game?

#define MAX_INV         10


void LoadGame();
void SaveGame();

class CEventCheck
{
public:
  CEventCheck();
  std::string name;
  dword x;
  dword y;
};


// Only holds the id and name, price of the equipped object!
class CEquip
{

public:
    CEquip();
    int id;
    std::string name;
    int price;
};

class CInv
{
private:

public:
       CInv();
       std::string name;
       int id;
       int type;
       int dam;
       int ac;
       bool equipped;
       int price;
};

#define MAX_ITEM_PER_SHOP               5
#define MAX_SHOP                        12
class CShop
{
public:
   //friend class CPlayer;
   CShop();
   
   BITMAP *shop_bmp;
   BITMAP *shop_selector;
   BITMAP *selector;
   BITMAP *item_type;
   BITMAP *choice_bmp;
   
   SAMPLE *coin;
   
   void Init();
   void Shop(int num, CPlayer &pc);
   int id[MAX_SHOP][MAX_ITEM_PER_SHOP]; // Holds what the shop has for sale (id's only... never sells out)
};

class CPlayer
{
      int xoff;
      int yoff;

public:
	CPlayer();
	~CPlayer();
	dword x;
	dword y;
    int moving;
    
	BITMAP *gfx;
	
	dword facing; // Holds the direction that the player is facing!
	int frame;
	
	CCam cam;
    CEquip equip[MAX_EQUIP]; // what's actually equipped
    
	CInv inv[MAX_INV];         // everything in your inv -- just holds the name and ID(which is looked up later for more info)
	void Move(CMap map, int direction);
	void MoveBlock(CMap map, int direction);
    void ViewBlock(CMap map, int direction); // used for battle system... removes p2p and p2npc collision
    void UpdateMovement();
    
    void WearObject(int id, int selected_item);
    void DropObject(int selected_item);
    void GiveObject(int selected_item);
    void PickupObject(int num);
    bool AddObject(int id);
    void RemoveObject(int item);
    
	void GetInfo();         // Gets the item info from a file
	void UpdateEquip();     // Updates the equipment id's that the player has equipped
	void UpdateInventory();

	void InitStats();
	void UpdateStats();
 
    CShop shop;

	
	CInv list[MAX_ITEMS]; // holds the list of possible items the character can get!
	
	/*Stats*/
	std::string name;
	int str;
	int wis;
	int intell;
	int con;
	int chr;
	int hp;
	int max_hp;
	int max_mana;
	int mana;
	
	
    int exp;
    int level;
    int ac;
    int base_ac;
    int dam;
    int base_dam;
	int gold;
	BITMAP *portrait;
	
	int max_battles;
	int movement_range;
	int fighting_range;
//	std::string fought_battles[max_battles]; //This holds the names of the maps where battle took place... so that people don't fight the same
                             // battle again... (hackalicious)
    std::vector<std::string> fought_battles;

    std::vector<CEventCheck> event_check;
	
};


extern int level_table[MAX_LEVEL];


/*

class CPoint
{
public:
	int x; 
	int y;
};

*/
extern CPlayer player[2];

#endif
