Character.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "Maths.h" // Needed for coords.
  2. #include "Game.h"
  3. #ifndef _CHARACTER_HEADER_
  4. #define _CHARACTER_HEADER_
  5. static const int max_alertness = 8;
  6. static const int max_fatigue = 8;
  7. static const int max_health = 8;
  8. // Map attribute names to attribute fields.
  9. #define ALERT 'A'
  10. #define ALERTNESS 'a'
  11. #define FATIGUE 'F'
  12. #define EXHAUSTED 'E'
  13. #define HEALTH 'H'
  14. #define ISPC 'p'
  15. #define WIN 'w'
  16. #define REP 'R'
  17. #define ID 'I'
  18. #define POS_X 'X'
  19. #define POS_Y 'Y'
  20. #define BAD_KEY -1
  21. typedef struct { char* str; int val; } attr;
  22. static attr Attrs[] = {
  23. { "id", ID },
  24. { "ispc", ISPC },
  25. { "x", POS_X },
  26. { "y", POS_Y },
  27. { "rep", REP },
  28. { "alert", ALERT },
  29. { "alertness", ALERTNESS },
  30. { "fatigue", FATIGUE },
  31. { "exhausted", EXHAUSTED },
  32. { "win", WIN },
  33. { "health", HEALTH }
  34. };
  35. int AttrHash( char* a );
  36. static int nattrs = sizeof(Attrs)/sizeof(attr);
  37. typedef struct character {
  38. game context;
  39. coords pos;
  40. char rep;
  41. int id;
  42. int ispc;
  43. int alert;
  44. int alertness;
  45. int fatigue;
  46. int exhausted;
  47. int win;
  48. int health;
  49. } character;
  50. //typedef character* chr;
  51. chr CreateCharacter(struct Game* g);
  52. void PurgeCharacter( chr c ); // Release all memory used within character.
  53. void ResetCharacter( chr c ); // Reset all character attributes to defaults.
  54. void CopyCharacter( chr sink, chr source );
  55. void SetStat( chr c, char* stat, int newval );
  56. int GetStat( chr c, char* stat );
  57. void init_pc( chr c );
  58. void init_npc( chr c );
  59. void FilePrint( chr c );
  60. void CursesPrint( chr c );
  61. #endif