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
|
Rev | Line | |
---|
[f419b09] | 1 | #include "Game.h"
|
---|
| 2 |
|
---|
| 3 | using namespace std;
|
---|
| 4 |
|
---|
| 5 | Game::Game() {
|
---|
| 6 | this->id = 0;
|
---|
| 7 | this->name = "";
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | Game::Game(string name) {
|
---|
| 11 | this->id = 0;
|
---|
| 12 | this->name = name;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | Game::~Game() {
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | void Game::setId(int id) {
|
---|
| 19 | this->id = id;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
[2ee386d] | 22 | int Game::getNumPlayers() {
|
---|
| 23 | return players.size();
|
---|
| 24 | }
|
---|
| 25 |
|
---|
[f419b09] | 26 | bool 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 |
|
---|
| 35 | bool 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.