- Timestamp:
- Sep 26, 2013, 8:29:14 PM (11 years ago)
- Branches:
- master
- Children:
- f41a7f9
- Parents:
- 321fbbc
- Location:
- common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Game.cpp
r321fbbc rb92e6a7 6 6 this->id = 0; 7 7 this->name = ""; 8 this->blueScore = 0; 9 this->redScore = 0; 10 this->worldMap = NULL; 8 11 } 9 12 … … 11 14 this->id = 0; 12 15 this->name = name; 16 this->blueScore = 0; 17 this->redScore = 0; 18 this->worldMap = WorldMap::loadMapFromFile("../data/map.txt"); 13 19 } 14 20 15 21 Game::~Game() { 16 } 17 18 void Game::setId(int id) { 19 this->id = id; 22 delete this->worldMap; 20 23 } 21 24 22 25 int Game::getNumPlayers() { 23 return players.size(); 26 return this->players.size(); 27 } 28 29 map<unsigned int, Player*>& Game::getPlayers() { 30 return this->players; 31 } 32 33 int Game::getRedScore() { 34 return this->redScore; 35 } 36 37 int Game::getBlueScore() { 38 return this->blueScore; 39 } 40 41 WorldMap* Game::getMap() { 42 return this->worldMap; 43 } 44 45 void Game::setId(unsigned int id) { 46 this->id = id; 24 47 } 25 48 … … 33 56 } 34 57 35 bool Game::removePlayer( int id) {58 bool Game::removePlayer(unsigned int id) { 36 59 if (players.erase(id) == 1) 37 60 return true; … … 39 62 return false; 40 63 } 64 65 void Game::setRedScore(int score) { 66 this->redScore = score; 67 } 68 69 void Game::setBlueScore(int score) { 70 this->blueScore = score; 71 } -
common/Game.h
r321fbbc rb92e6a7 15 15 16 16 #include "Player.h" 17 #include "WorldMap.h" 17 18 18 19 using namespace std; … … 20 21 class Game { 21 22 private: 22 int id;23 unsigned int id; 23 24 string name; 24 map<int, Player*> players; 25 map<unsigned int, Player*> players; 26 WorldMap* worldMap; 27 int blueScore; 28 int redScore; 25 29 26 30 public: … … 31 35 32 36 int getNumPlayers(); 37 map<unsigned int, Player*>& getPlayers(); 38 int getBlueScore(); 39 int getRedScore(); 40 WorldMap* getMap(); 33 41 34 void setId( int id);42 void setId(unsigned int id); 35 43 bool addPlayer(Player* p); 36 bool removePlayer(int id); 44 bool removePlayer(unsigned int id); 45 void setBlueScore(int score); 46 void setRedScore(int score); 37 47 }; 38 48 -
common/WorldMap.cpp
r321fbbc rb92e6a7 194 194 WorldMap* WorldMap::loadMapFromFile(string filename) 195 195 { 196 196 WorldMap* m = NULL; 197 197 198 198 ifstream file(filename.c_str());
Note:
See TracChangeset
for help on using the changeset viewer.