/src/EnemyGroupManager.h
C Header | 86 lines | 30 code | 17 blank | 39 comment | 0 complexity | d900adae9f79ca0e48183ed0d22e911f MD5 | raw file
Possible License(s): GPL-3.0
1/* 2Copyright 2011 Thane Brimhall 3 Manuel A. Fernandez Montecelo <manuel.montezelo@gmail.com> 4 5This file is part of FLARE. 6 7FLARE is free software: you can redistribute it and/or modify it under the terms 8of the GNU General Public License as published by the Free Software Foundation, 9either version 3 of the License, or (at your option) any later version. 10 11FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 15You should have received a copy of the GNU General Public License along with 16FLARE. If not, see http://www.gnu.org/licenses/ 17*/ 18 19#ifndef ENEMYGROUPMANAGER_H 20#define ENEMYGROUPMANAGER_H 21 22#include "Settings.h" 23#include "MapIso.h" 24#include "FileParser.h" 25#include "UtilsFileSystem.h" 26 27#include <fstream> 28#include <string> 29#include <map> 30#include <vector> 31#include <iostream> 32 33 34struct Enemy_Level { 35 std::string type; 36 int level; 37 std::string rarity; 38 39 Enemy_Level() : level(0), rarity("common") {} 40}; 41 42 43/** 44 * class EnemyGroupManager 45 * 46 * Loads Enemies into category lists and manages spawning randomized groups of 47 * enemies. 48 */ 49class EnemyGroupManager { 50public: 51 /** Get instance of the Singleton */ 52 static EnemyGroupManager& instance(); 53 54 /** To get a random enemy with the given characteristics 55 * 56 * @param category Enemy of the desired category 57 * @param minlevel Enemy of the desired level (minimum) 58 * @param maxlevel Enemy of the desired level (maximum) 59 * 60 * @return A random enemy 61 */ 62 Enemy_Level getRandomEnemy(const std::string& category, int minlevel, int maxlevel) const; 63 64private: 65 /** Instance of the Singleton */ 66 static EnemyGroupManager* _instance; 67 68 69 /** Container to store enemy data */ 70 std::map <std::string, std::vector<Enemy_Level> > _categories; 71 72 73 /** Constructor */ 74 EnemyGroupManager(); 75 /** Destructor */ 76 ~EnemyGroupManager(); 77 78 /** Generate the list of categories, fills the container with the enemy 79 * data */ 80 void generate(); 81 82 /** Get information stored on files and insert into container */ 83 void parseEnemyFileAndStore(const std::string& dir, const std::string& filename); 84}; 85 86#endif