source: network-game/common/Game.cpp@ 6319311

Last change on this file since 6319311 was 6319311, checked in by Dmitry Portnoy <dportnoy@…>, 11 years ago

Some redfinition issues related to winsock2 are fixed and a few allegro rendering functions are now in GameRender

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