Adonthell  0.4
character_base.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000/2001 Kai Sterker <kai.sterker@gmail.com>
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 /**
21  * @file character_base.h
22  * @author Kai Sterker <kai.sterker@gmail.com>
23  *
24  * @brief Declares the character_base class.
25  *
26  *
27  */
28 
29 
30 
31 #ifndef CHARACTER_BASE_H_
32 #define CHARACTER_BASE_H_
33 
34 
35 /**
36  * Where dialogs are located in the data tree.
37  *
38  */
39 #define DIALOG_DIR "dialogues/"
40 
41 #include "storage.h"
42 #include "fileops.h"
43 
44 /**
45  * Race enumeration.
46  *
47  */
48 enum
49 {
50  DWARF = 0,
51  ELF = 1,
52  HALFELF = 2,
53  HUMAN = 3
54 };
55 
56 /**
57  * Gender enumeration.
58  *
59  */
60 enum
61 {
62  FEMALE = 0,
63  MALE = 1
64 };
65 
66 /**
67  * Type enumeration.
68  *
69  */
70 enum
71 {
72  NPC = 0,
73  PLAYER = 1,
74  PARTY = 2
75 };
76 
77 /**
78  * Base character class containing attributes and dialog stuff.
79  *
80  */
81 class character_base : public storage
82 {
83  public:
84  /**
85  * Default constructor.
86  *
87  */
88  character_base ();
89 
90  /**
91  * Destructor.
92  *
93  */
94  ~character_base ();
95 
96  /**
97  * Returns the name of the %character.
98  *
99  * @return the name of the %character.
100  */
101  string get_name () const { return name; }
102 
103  /**
104  * Returns an unique identifier of the %character.
105  *
106  * @return
107  * @li <b>Player</b> for the player controlled %character
108  * @li the %character's name otherwise.
109  */
110  string get_id ()
111  {
112  if (get_val ("type") == PLAYER) return "Player";
113  else return name;
114  }
115 
116  /**
117  * Sets the name of the %character.
118  *
119  * @param newname name of the %character.
120  */
121  void set_name (string newname);
122 
123  /**
124  * Returns the color representing the %character.
125  *
126  * @return the color representing the %character.
127  */
128  u_int32 get_color() const { return color; }
129 
130  /**
131  * Sets the color representing the %character.
132  *
133  * @param c new color representing the %character.
134  */
135  void set_color (int c) { color = c; }
136 
137  /**
138  * Returns the current portrait of the %character.
139  *
140  * @return the current portrait of the %character.
141  */
142  string get_portrait() const { return portrait; }
143 
144  /**
145  * Sets the current portrait of the %character.
146  *
147  * @param fname filename of the new portrait to use.
148  */
149  void set_portrait (string fname) { portrait = fname; }
150 
151  /**
152  * Return the file name of the current %character's dialog.
153  *
154  * @return file name of the dialog currently assigned to this %character.
155  */
156  string get_dialogue () const { return dialogue; }
157 
158  /**
159  * Sets the dialogue of the %character.
160  *
161  * @param dialogue new %character's dialog.
162  */
163  void set_dialogue (string dialogue);
164 
165  /**
166  * Loads the state (attributes) of the %character from an opened file.
167  *
168  * @param in file from which to read.
169  */
170 
171  void get_state (igzstream& in);
172 
173  /**
174  * Saves the state (ttributes) of the %character into an opened file.
175  *
176  * @param out file where to save.
177  */
178  void put_state (ogzstream& out);
179 
180 private:
181  string name;
182  string dialogue;
183  string portrait;
184  u_int32 color;
185 };
186 
187 #endif
Class to write data from a Gzip compressed file.
Definition: fileops.h:227
character_base()
Default constructor.
Class to read data from a Gzip compressed file.
Definition: fileops.h:135
void set_name(string newname)
Sets the name of the character.
void get_state(igzstream &in)
Loads the state (attributes) of the character from an opened file.
string get_id()
Returns an unique identifier of the character.
#define u_int32
32 bits long unsigned integer
Definition: types.h:41
void put_state(ogzstream &out)
Saves the state (ttributes) of the character into an opened file.
Base storage class.
Definition: storage.h:51
string get_portrait() const
Returns the current portrait of the character.
Base character class containing attributes and dialog stuff.
void set_color(int c)
Sets the color representing the character.
s_int32 get_val(string key)
Returns the value of a key.
Definition: storage.cc:54
Declares the storage and objects classes.
void set_dialogue(string dialogue)
Sets the dialogue of the character.
string get_name() const
Returns the name of the character.
~character_base()
Destructor.
Declares the igzstream, ogzstream and fileops classes.
void set_portrait(string fname)
Sets the current portrait of the character.
string get_dialogue() const
Return the file name of the current character&#39;s dialog.
u_int32 get_color() const
Returns the color representing the character.