source: network-game/common/Game.cpp@ 321fbbc

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

Client only stores the game name and number of players of each game

  • Property mode set to 100644
File size: 553 bytes
Line 
1#include "Game.h"
2
3using namespace std;
4
5Game::Game() {
6 this->id = 0;
7 this->name = "";
8}
9
10Game::Game(string name) {
11 this->id = 0;
12 this->name = name;
13}
14
15Game::~Game() {
16}
17
18void Game::setId(int id) {
19 this->id = id;
20}
21
22int Game::getNumPlayers() {
23 return players.size();
24}
25
26bool Game::addPlayer(Player* p) {
27 if (players.count(p->id) == 0) {
28 players[p->id] = p;
29 return true;
30 }
31 else
32 return false;
33}
34
35bool Game::removePlayer(int id) {
36 if (players.erase(id) == 1)
37 return true;
38 else
39 return false;
40}
Note: See TracBrowser for help on using the repository browser.