source: network-game/common/Game.cpp@ 85bf1e2

Last change on this file since 85bf1e2 was f419b09, checked in by dportnoy <dmp1488@…>, 11 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
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
22bool 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
31bool 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.