|
Last change
on this file since 1785314 was f419b09, checked in by dportnoy <dmp1488@…>, 12 years ago |
|
Added a Game class and new messages types for creating, joining, and leaving games
|
-
Property mode
set to
100644
|
|
File size:
496 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 |
|
|---|
| 22 | bool Game::addPlayer(Player* p) {
|
|---|
| 23 | if (players.count(p->id) == 0) {
|
|---|
| 24 | players[p->id] = p;
|
|---|
| 25 | return true;
|
|---|
| 26 | }
|
|---|
| 27 | else
|
|---|
| 28 | return false;
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | bool Game::removePlayer(int id) {
|
|---|
| 32 | if (players.erase(id) == 1)
|
|---|
| 33 | return true;
|
|---|
| 34 | else
|
|---|
| 35 | return false;
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.