Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

character.h

00001 /***************************************************************************
00002                           character.h  -  description
00003                              -------------------
00004     begin                : Mon Jul 7 2003
00005     copyright            : (C) 2003 by Gabor Torok
00006     email                : cctorok@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef CHARACTER_H
00019 #define CHARACTER_H
00020 
00021 #include "../constants.h"
00022 #include <map>
00023 #include <vector>
00024 #include <string>
00025 
00026 using namespace std;
00027 
00032 class Character  {
00033 private:
00034   char *name;
00035   int startingHp, startingMp, skill_bonus, level_progression;
00036   char description[3000];
00037   char *shortName;
00038   map<int, int> maxSkill;
00039   map<int, int> minSkill;
00040 
00041 public:
00042   map<int, vector<string>*> soundMap;
00043 
00044   Character(char *name, int startingHp, int startingMp, int skill_bonus, int level_progression, char *shortName);
00045   ~Character();
00046 
00047   inline char *getName() { return name; };
00048   inline char *getShortName() { return shortName; };
00049   inline int getStartingHp() { return startingHp; }  
00050   inline int getStartingMp() { return startingMp; }  
00051   inline int getSkillBonus() { return skill_bonus; }  
00052   inline int getLevelProgression() { return level_progression; }  
00053   inline char *getDescription() { return description; }
00054   inline int getMaxSkillLevel(int skill) { if(maxSkill.find(skill) == maxSkill.end()) return 100; else return maxSkill[skill]; }
00055   inline int getMinSkillLevel(int skill) { if(minSkill.find(skill) == minSkill.end()) return 0; else return minSkill[skill]; }
00056   void addSound(int type, char *file);
00057   const char *getRandomSound(int type);
00058 
00059   static map<string, Character*> character_class;
00060   static map<string, Character*> character_class_short;
00061   static map<string, int> character_index_short;
00062   static vector<Character*> character_list;
00063   static void initCharacters();
00064   static Character *getCharacterByName(char *p) { string s = p; return character_class[s]; }
00065   static Character *getCharacterByShortName(char *p) { string s = p; return character_class_short[s]; }
00066   static int getCharacterIndexByShortName(char *p) {  string s = p; return character_index_short[s]; }
00067   inline static Character *getRandomCharacter() { return character_list[(int)((float)character_list.size()*rand()/RAND_MAX)]; }
00068 
00069  protected:
00070   inline void setMinMaxSkill(int skill, int min, int max) { minSkill[skill] = min; maxSkill[skill] = max; }
00071   static void addSounds(int type, char *line, Character *c);
00072 };
00073 
00074 #endif

Generated on Thu Jun 16 21:50:42 2005 for scourge by  doxygen 1.4.0