This may be unnecessary, but I find it conceptually desirable.
notify-local-tty.cc
objects.cc
objects.hh
+player.hh
pmon2.cc
pmon_comp
pobj_comp
permons.cc pmon_id.hh: default.permons $(srcdir)/pmon_comp
$(srcdir)/pmon_comp $<
## Dependencies for the build
-combat.o: combat.cc combat.hh victrix-abyssi.hh monsters.hh objects.hh notify.hh pobj_id.hh pmon_id.hh
+combat.o: combat.cc combat.hh victrix-abyssi.hh monsters.hh objects.hh notify.hh pobj_id.hh pmon_id.hh player.hh
-display-nc.o: display-nc.cc victrix-abyssi.hh display.hh pobj_id.hh pmon_id.hh
+display-nc.o: display-nc.cc victrix-abyssi.hh display.hh pobj_id.hh pmon_id.hh player.hh
-main.o: main.cc combat.hh victrix-abyssi.hh monsters.hh notify.hh pobj_id.hh pmon_id.hh
+main.o: main.cc combat.hh victrix-abyssi.hh monsters.hh notify.hh pobj_id.hh pmon_id.hh player.hh
-map.o: map.cc victrix-abyssi.hh notify.hh objects.hh pobj_id.hh pmon_id.hh
+map.o: map.cc victrix-abyssi.hh notify.hh objects.hh pobj_id.hh pmon_id.hh player.hh
-monsters.o: monsters.cc victrix-abyssi.hh monsters.hh notify.hh objects.hh pobj_id.hh pmon_id.hh
+monsters.o: monsters.cc victrix-abyssi.hh monsters.hh notify.hh objects.hh pobj_id.hh pmon_id.hh player.hh
-mon2.o: mon2.cc victrix-abyssi.hh sorcery.hh monsters.hh notify.hh objects.hh pobj_id.hh pmon_id.hh
+mon2.o: mon2.cc victrix-abyssi.hh sorcery.hh monsters.hh notify.hh objects.hh pobj_id.hh pmon_id.hh player.hh
-notify-local-tty.o: notify-local-tty.cc victrix-abyssi.hh combat.hh monsters.hh notify.hh objects.hh sorcery.hh pobj_id.hh pmon_id.hh
+notify-local-tty.o: notify-local-tty.cc victrix-abyssi.hh combat.hh monsters.hh notify.hh objects.hh sorcery.hh pobj_id.hh pmon_id.hh player.hh
# NOTICE: permobj.cc does not depend on pobj_id.hh because they are both
# generated from the same input file and should not be hand-edited. If you
permons.o: permons.cc victrix-abyssi.hh monsters.hh pobj_id.hh pmon_id.hh
-pmon2.o: pmon2.cc victrix-abyssi.hh notify.hh monsters.hh pobj_id.hh pmon_id.hh
+pmon2.o: pmon2.cc victrix-abyssi.hh notify.hh monsters.hh pobj_id.hh pmon_id.hh player.hh
-objects.o: objects.cc victrix-abyssi.hh notify.hh objects.hh monsters.hh pobj_id.hh pmon_id.hh
+objects.o: objects.cc victrix-abyssi.hh notify.hh objects.hh monsters.hh pobj_id.hh pmon_id.hh player.hh
-sorcery.o: sorcery.cc victrix-abyssi.hh notify.hh sorcery.hh objects.hh monsters.hh pobj_id.hh pmon_id.hh
+sorcery.o: sorcery.cc victrix-abyssi.hh notify.hh sorcery.hh objects.hh monsters.hh pobj_id.hh pmon_id.hh player.hh
-u.o: u.cc combat.hh victrix-abyssi.hh notify.hh monsters.hh objects.hh pobj_id.hh pmon_id.hh
+u.o: u.cc combat.hh victrix-abyssi.hh notify.hh monsters.hh objects.hh pobj_id.hh pmon_id.hh player.hh
util.o: util.c util.h
--- /dev/null
+/*! \file player.hh
+ * \brief Player character header for Victrix Abyssi
+ */
+
+/* Copyright 2014 Martin Read
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PLAYER_HH
+#define PLAYER_HH
+
+#include "victrix-abyssi.hh"
+
+/*! \brief Internal representation of the player character
+ */
+class Player {
+public:
+ char name[17]; //!< Allows 16 actual characters, plus 0 terminator
+ Coord pos; //!< Position within current dungeon level.
+ int body; //!< Combined stamina and strength stat.
+ int bdam; //!< Current level of temporary Body drain
+ int agility; //!< Combined accuracy and avoidance stat.
+ int adam; //!< Current level of temporary agility drain.
+ int hpmax; //!< Max hit points.
+ int hpcur; //!< Current hit points.
+ int food; //!< Current level of satiation; < 0 is hungry.
+ int experience; //!< Experience points accumulated.
+ int defence; //!< To-hit target number for monsters.
+ int protection; //!< Temporary protection from cursing.
+ int leadfoot; //!< Feet-of-lead curse.
+ int withering; //!< Vile withering curse.
+ int armourmelt; //!< Armour-like-dust curse.
+ int speed; //!< Controls how often you act.
+ uint32_t resistances[DT_COUNT]; //!< Resistance masks per damage type
+ int level; //!< Current experience level.
+ int inventory[19]; //!< Object handles of currently carried items.
+ int weapon; //!< Object handle of currently equipped weapon.
+ int armour; //!< Object handle of currently equipped armour.
+ int ring; //!< Object handle of currently equipped ring.
+ int sympathy[TOTAL_FELL_POWERS]; //!< Level of alignment with fell powers
+ bool resists(Damtyp dtype) const; //!< Does player resist this Damtyp?
+ bool martial(void) const //!< Is player significantly influenced by iron?
+ { return sympathy[FePo_iron] > 10; }
+ bool rotten(void) const //!< Is player significantly influenced by decay?
+ { return sympathy[FePo_decay] > 10; }
+ bool thanatoic(void) const //!< Is player significantly influenced by bone?
+ { return sympathy[FePo_bone] > 10; }
+ bool sybaritic(void) const //!< Is player significantly influenced by flesh?
+ { return sympathy[FePo_flesh] > 10; }
+ bool corrupt(void) const //!< Is player significantly influenced by any?
+ { return martial() || rotten() || thanatoic() || sybaritic(); }
+};
+
+/* XXX u.c data and funcs */
+extern void u_init(char const *name);
+extern void write_char_dump(void);
+extern int do_death(Death d, char const *what);
+extern void heal_u(int amount, int boost, int loud);
+extern int damage_u(int amount, Death d, char const *what);
+extern int gain_body(int amount);
+extern int gain_agility(int amount);
+extern int drain_body(int amount, char const *what, int permanent);
+extern int drain_agility(int amount, char const *what, int permanent);
+extern void gain_experience(int amount);
+extern int lev_threshold(int level);
+extern Action_cost move_player(Offset delta);
+extern void reloc_player(Coord c);
+extern void recalc_defence(void);
+extern Pass_fail teleport_u(void);
+extern void update_player(void);
+
+extern Player u;
+
+#endif
+
+/* player.hh */
+// vim:cindent:ts=8:sw=4:expandtab
#define RESIST_ARMOUR 0x00020000u
/* XXX STRUCTURES XXX */
-/* XXX struct player */
-class Player {
-public:
- char name[17]; /* including '\0' the fencepost. */
- Coord pos;
- int body; /* determines mace to-hit, melee damage, max 99 */
- int bdam; /* current level of temporary body drain. */
- int agility; /* determines sword, dagger, missile to-hit, max 99 */
- int adam; /* current level of temporary agility drain. */
- int hpmax; /* Max hit points; max of 999. */
- int hpcur; /* Current hit points; <= 0 is dead. */
- int food; /* Current nutrition in body; < 0 is hungry. */
- int experience; /* Experience points earned. */
- int defence; /* To-hit target number for monsters */
- int protection; /* Temporary protection from cursing */
- int leadfoot; /* Feet-of-lead curse */
- int withering; /* Vile withering curse */
- int armourmelt; /* Armour-like-dust curse */
- int speed;
- uint32_t resistances[DT_COUNT]; /* Resistances to damage types. */
- int level; /* Each level gets you +1 body, +1 agility, +1 random
- point, and +(10+body/10) hit points */
- int inventory[19]; /* 19 inventory slots, leaving room for a prompt */
- int weapon; /* For now, you can only wield one weapon. */
- int armour; /* For now, you can only wear one item of armour. */
- int ring; /* For now, you can only wear one magic ring. */
- // TODO make these meters mean something - cosmetically for starters
- int sympathy[TOTAL_FELL_POWERS];
- bool resists(Damtyp dtype) const;
- bool martial(void) const { return sympathy[FePo_iron] > 10; }
- bool rotten(void) const { return sympathy[FePo_decay] > 10; }
- bool thanatoic(void) const { return sympathy[FePo_bone] > 10; }
- bool sybaritic(void) const { return sympathy[FePo_flesh] > 10; }
- bool corrupt(void) const { return martial() || rotten() || thanatoic() || sybaritic(); }
-};
+#ifndef PLAYER_HH
+#include "player.hh"
+#endif
/*! \brief Represent an in-game action in more detail than Game_cmd
*/
extern bool game_finished;
extern int game_tick;
extern bool wizard_mode;
-extern void wrapped_system(char const *cmd);
-extern void wrapped_fread(void *buf, size_t size, size_t nmemb, FILE *stream);
extern void new_game(char const *name);
-extern int load_game(void);
/* XXX misc.c data and funcs */
extern char const *damtype_names[DT_COUNT];
/* XXX log.cc */
extern void log_death(Death d, char const *what);
extern void load_config(void);
-/* XXX u.c data and funcs */
-extern void u_init(char const *name);
-extern void write_char_dump(void);
-extern int do_death(Death d, char const *what);
-extern void heal_u(int amount, int boost, int loud);
-extern int damage_u(int amount, Death d, char const *what);
-extern int gain_body(int amount);
-extern int gain_agility(int amount);
-extern int drain_body(int amount, char const *what, int permanent);
-extern int drain_agility(int amount, char const *what, int permanent);
-extern void gain_experience(int amount);
-extern int lev_threshold(int level);
-extern Action_cost move_player(Offset delta);
-extern void reloc_player(Coord c);
-extern void recalc_defence(void);
-extern Pass_fail teleport_u(void);
-extern void update_player(void);
-
-extern struct Player u;
+extern void wrapped_system(char const *cmd);
+extern void wrapped_fread(void *buf, size_t size, size_t nmemb, FILE *stream);
+extern int load_game(void);
#endif