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      */
get_name()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      */
get_id()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      */
get_color()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      */
set_color(int c)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      */
get_portrait()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      */
set_portrait(string fname)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      */
get_dialogue()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
188