Changeset 1d96513 in network-game


Ignore:
Timestamp:
Dec 22, 2013, 2:57:04 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
45734ff
Parents:
483a2cb
Message:

Game class includes projectile list

Location:
common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • common/Game.cpp

    r483a2cb r1d96513  
    3737}
    3838
     39map<unsigned int, Projectile>& Game::getProjectiles() {
     40   return this->projectiles;
     41}
     42
    3943int Game::getRedScore() {
    4044   return this->redScore;
     
    5155void Game::setId(unsigned int id) {
    5256   this->id = id;
     57}
     58
     59void Game::setRedScore(int score) {
     60   this->redScore = score;
     61}
     62
     63void Game::setBlueScore(int score) {
     64   this->blueScore = score;
    5365}
    5466
     
    147159}
    148160
    149 void Game::setRedScore(int score) {
    150    this->redScore = score;
     161bool Game::addProjectile(Projectile p) {
     162   if (projectiles.find(p.id) == projectiles.end()) {
     163      projectiles[p.id] = p;
     164      return true;
     165   }
     166   else
     167      return false;
    151168}
    152169
    153 void Game::setBlueScore(int score) {
    154    this->blueScore = score;
     170bool Game::removeProjectile(unsigned int id) {
     171   if (projectiles.erase(id) == 1)
     172      return true;
     173   else
     174      return false;
    155175}
  • common/Game.h

    r483a2cb r1d96513  
    1313#include "Player.h"
    1414#include "WorldMap.h"
     15#include "Projectile.h"
    1516
    1617using namespace std;
     
    2122   string name;
    2223   map<unsigned int, Player*> players;
     24   map<unsigned int, Projectile> projectiles;
    2325   WorldMap* worldMap;
    2426   int blueScore;
     
    3436   int getNumPlayers();
    3537   map<unsigned int, Player*>& getPlayers();
     38   map<unsigned int, Projectile>& getProjectiles();
    3639   int getBlueScore();
    3740   int getRedScore();
     
    3942
    4043   void setId(unsigned int id);
     44   void setBlueScore(int score);
     45   void setRedScore(int score);
     46
    4147   bool addPlayer(Player* p);
    4248   bool removePlayer(unsigned int id);
     
    4551   int processFlagPickupRequest(Player* p);
    4652
    47    void setBlueScore(int score);
    48    void setRedScore(int score);
     53   bool addProjectile(Projectile p);
     54   bool removeProjectile(unsigned int id);
    4955};
    5056
Note: See TracChangeset for help on using the changeset viewer.