Skip to content
Snippets Groups Projects
descriptions.h 3.96 KiB
Newer Older
Jake Feddersen's avatar
Jake Feddersen committed
#ifndef DESCRIPTIONS_H
# define DESCRIPTIONS_H

# include <stdint.h>
# undef swap
# include <vector>
# include <string>
# include "dice.h"

# define SAVE_DIR ".rlg327"
Jake Feddersen's avatar
Jake Feddersen committed
# define MONSTER_DESC_FILE "monster_desc.txt"
# define OBJECT_DESC_FILE "object_desc.txt"

class dungeon;
class monster;
class item;
Jake Feddersen's avatar
Jake Feddersen committed

uint32_t parse_descriptions(dungeon &d);
uint32_t print_descriptions(dungeon &d);
uint32_t destroy_descriptions(dungeon &d);

typedef enum object_type {
  objtype_no_type,
  objtype_WEAPON,
  objtype_OFFHAND,
  objtype_RANGED,
  objtype_LIGHT,
  objtype_ARMOR,
  objtype_HELMET,
  objtype_CLOAK,
  objtype_GLOVES,
  objtype_BOOTS,
  objtype_AMULET,
  objtype_RING,
  objtype_SCROLL,
  objtype_BOOK,
  objtype_FLASK,
  objtype_GOLD,
  objtype_AMMUNITION,
  objtype_FOOD,
  objtype_WAND,
  objtype_CONTAINER
} object_type_t;

extern const char object_symbol[];

class monster_description {
Jake Feddersen's avatar
Jake Feddersen committed
  std::string name, description;
  std::vector<uint32_t> color;
	int instances;
 private:
	char symbol;
Jake Feddersen's avatar
Jake Feddersen committed
  uint32_t abilities;
  dice speed, hitpoints, damage;
  uint32_t rarity;
	bool valid;
Jake Feddersen's avatar
Jake Feddersen committed
 public:
  monster_description() : name(), description(), color(0), instances(0), symbol(0),
                          abilities(0), speed(), hitpoints(), damage(), rarity(0), valid(true)
Jake Feddersen's avatar
Jake Feddersen committed
  {
  }
  void set(const std::string &name,
           const std::string &description,
           const char symbol,
           const std::vector<uint32_t> &color,
           const dice &speed,
           const uint32_t abilities,
           const dice &hitpoints,
           const dice &damage,
           const uint32_t rarity);
  std::ostream &print(std::ostream &o);
  char get_symbol() { return symbol; }
	
	monster *make_monster(uint8_t x, uint8_t y);
	void invalidate();
Jake Feddersen's avatar
Jake Feddersen committed
};

class object_description {
 private:
  std::string name, description;
  object_type_t type;
  uint32_t color;
  dice hit, damage, dodge, defence, weight, speed, attribute, value;
  bool artifact;
  uint32_t rarity;
  bool valid;
 public:
  int instances;
Jake Feddersen's avatar
Jake Feddersen committed
 public:
  object_description() : name(),    description(), type(objtype_no_type),
                         color(0),  hit(),         damage(),
                         dodge(),   defence(),     weight(),
                         speed(),   attribute(),   value(),
                         artifact(false), rarity(0), valid(true), instances(0)
Jake Feddersen's avatar
Jake Feddersen committed
  {
  }
  void set(const std::string &name,
           const std::string &description,
           const object_type_t type,
           const uint32_t color,
           const dice &hit,
           const dice &damage,
           const dice &dodge,
           const dice &defence,
           const dice &weight,
           const dice &speed,
           const dice &attrubute,
           const dice &value,
           const bool artifact,
           const uint32_t rarity);
  std::ostream &print(std::ostream &o);
  /* Need all these accessors because otherwise there is a *
   * circular dependancy that is difficult to get around.  */
  inline const std::string &get_name() const { return name; }
  inline const std::string &get_description() const { return description; }
  inline const object_type_t get_type() const { return type; }
  inline const uint32_t get_color() const { return color; }
  inline const dice &get_hit() const { return hit; }
  inline const dice &get_damage() const { return damage; }
  inline const dice &get_dodge() const { return dodge; }
  inline const dice &get_defence() const { return defence; }
  inline const dice &get_weight() const { return weight; }
  inline const dice &get_speed() const { return speed; }
  inline const dice &get_attribute() const { return attribute; }
  inline const dice &get_value() const { return value; }
  inline const bool get_artifact() const { return artifact; }
  inline const uint32_t get_rarity() const { return rarity; }
  
  char get_symbol();
	item *make_item();
  void invalidate();
Jake Feddersen's avatar
Jake Feddersen committed
};

std::ostream &operator<<(std::ostream &o, monster_description &m);
std::ostream &operator<<(std::ostream &o, object_description &od);

#endif