|
Last change
on this file since 31b347a was 373089e, checked in by dportnoy <dmp1488@…>, 12 years ago |
|
The server compiles
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | #include "Game.h"
|
|---|
| 2 |
|
|---|
| 3 | using namespace std;
|
|---|
| 4 |
|
|---|
| 5 | Game::Game() {
|
|---|
| 6 | this->id = 0;
|
|---|
| 7 | this->name = "";
|
|---|
| 8 | this->blueScore = 0;
|
|---|
| 9 | this->redScore = 0;
|
|---|
| 10 | this->worldMap = NULL;
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | Game::Game(string name, string filepath) {
|
|---|
| 14 | this->id = 0;
|
|---|
| 15 | this->name = name;
|
|---|
| 16 | this->blueScore = 0;
|
|---|
| 17 | this->redScore = 0;
|
|---|
| 18 | this->worldMap = WorldMap::loadMapFromFile(filepath);
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | Game::~Game() {
|
|---|
| 22 | delete this->worldMap;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | string Game::getName() {
|
|---|
| 26 | return this->name;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | int Game::getNumPlayers() {
|
|---|
| 30 | return this->players.size();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | map<unsigned int, Player*>& Game::getPlayers() {
|
|---|
| 34 | return this->players;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | int Game::getRedScore() {
|
|---|
| 38 | return this->redScore;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | int Game::getBlueScore() {
|
|---|
| 42 | return this->blueScore;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | WorldMap* Game::getMap() {
|
|---|
| 46 | return this->worldMap;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | void Game::setId(unsigned int id) {
|
|---|
| 50 | this->id = id;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | bool Game::addPlayer(Player* p) {
|
|---|
| 54 | if (players.find(p->id) == players.end()) {
|
|---|
| 55 | players[p->id] = p;
|
|---|
| 56 | return true;
|
|---|
| 57 | }
|
|---|
| 58 | else
|
|---|
| 59 | return false;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | bool Game::removePlayer(unsigned int id) {
|
|---|
| 63 | if (players.erase(id) == 1)
|
|---|
| 64 | return true;
|
|---|
| 65 | else
|
|---|
| 66 | return false;
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | void Game::setRedScore(int score) {
|
|---|
| 70 | this->redScore = score;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | void Game::setBlueScore(int score) {
|
|---|
| 74 | this->blueScore = score;
|
|---|
| 75 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.