1 #pragma once 2 // Description: 3 // Skill settings. 4 // 5 // Copyright (C) 2001 Frank Becker 6 // 7 // This program is free software; you can redistribute it and/or modify it under 8 // the terms of the GNU General Public License as published by the Free Software 9 // Foundation; either version 2 of the License, or (at your option) any later 10 // version. 11 // 12 // This program is distributed in the hope that it will be useful, but WITHOUT 13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details 15 // 16 17 #include <string> 18 #include <Singleton.hpp> 19 20 const std::string SKILL_ROOKIE = "ROOKIE"; 21 const std::string SKILL_NORMAL = "NORMAL"; 22 const std::string SKILL_EXPERT = "EXPERT"; 23 const std::string SKILL_INSANE = "INSANE"; 24 const std::string SKILL_UNKNOWN = "UNKNOWN"; 25 const std::string SKILL_ERROR = "*ERROR*"; 26 27 class Skill 28 { 29 friend class Singleton<Skill>; 30 public: 31 enum SkillEnum 32 { 33 eUnknown = 0, 34 eRookie = 1, 35 eNormal = 2, 36 eExpert = 3, 37 eInsane = 4, 38 eLAST 39 }; 40 getString(SkillEnum e)41 inline static const std::string &getString( SkillEnum e) 42 { 43 switch( e) 44 { 45 case eRookie: 46 return SKILL_ROOKIE; 47 48 case eNormal: 49 return SKILL_NORMAL; 50 51 case eExpert: 52 return SKILL_EXPERT; 53 54 case eInsane: 55 return SKILL_INSANE; 56 57 case eUnknown: 58 return SKILL_UNKNOWN; 59 60 case eLAST: 61 default: 62 break; 63 } 64 return SKILL_ERROR; 65 } 66 67 static inline int getFireProbability( void); 68 static inline int getMaxBullets( void); 69 static inline int getMaxAttacking( void); 70 71 void updateSkill( const Skill::SkillEnum &skill); 72 void updateSkill( void); 73 void incrementSkill( void); 74 75 private: 76 ~Skill(); 77 Skill( void); 78 Skill( const Skill&); 79 Skill &operator=(const Skill&); 80 81 SkillEnum convertStringToSkill( const std::string &skill); 82 83 int _fireProbability; 84 int _maxBullets; 85 int _maxAttacking; 86 }; 87 88 typedef Singleton<Skill> SkillS; 89 getFireProbability(void)90int Skill::getFireProbability( void) 91 { 92 return SkillS::instance()->_fireProbability; 93 } 94 getMaxBullets(void)95int Skill::getMaxBullets( void) 96 { 97 return SkillS::instance()->_maxBullets; 98 } 99 getMaxAttacking(void)100int Skill::getMaxAttacking( void) 101 { 102 return SkillS::instance()->_maxAttacking; 103 } 104