Changeset 12109 for code/branches/wagnis_HS18
- Timestamp:
- Nov 21, 2018, 10:19:21 AM (6 years ago)
- Location:
- code/branches/wagnis_HS18/src/modules/wagnis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt
r12100 r12109 2 2 WagnisProvince.cc 3 3 WagnisGameboard.cc 4 WagnisPlayer.cc 4 5 ) 5 6 -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
r12105 r12109 14 14 15 15 //Constructor 16 WagnisPlayer::WagnisPlayer(Context* context ,WagnisGameboard* gb) : Baseclass(context){16 WagnisPlayer::WagnisPlayer(Context* context) : HumanPlayer(context){ 17 17 RegisterObject(WagnisPlayer); 18 18 this->origin = nullptr; 19 19 this->target = nullptr; 20 this->gameBoard = gb;20 this->gameBoard = nullptr; 21 21 } 22 22 //Destructor … … 29 29 } 30 30 //checks if a move is valid, possible MoveTypes: ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL 31 bool WagnisPlayer::checkMove(WagnisProvince*,WagnisProvince*,MoveType )31 bool WagnisPlayer::checkMove(WagnisProvince*,WagnisProvince*,MoveType move_type) 32 32 { 33 if ( MoveType == ATTACK)33 if (move_type == ATTACK) 34 34 { 35 35 if (isNeighbour(this->origin, this->target))//TODO: provinces neighbours … … 43 43 } 44 44 45 if ( MoveType == MOVE)45 if (move_type == MOVE) 46 46 { 47 47 if (existPath(this->origin, this->target))//TODO: path exists, all belong to same player … … 53 53 } 54 54 55 if ( MoveType == SET_Troops)55 if (move_type == SET_TROOPS) 56 56 { 57 57 if (this->target->getOwner_ID() == this->Player_ID)//target belongs to player … … 59 59 } 60 60 61 if ( MoveType == SET_TROOPS_INITIAL)61 if (move_type == SET_TROOPS_INITIAL) 62 62 { 63 63 if (this->target->getOwner_ID() == 0)//target belongs to nobody … … 81 81 std::string WagnisPlayer::toString(){ 82 82 std::string str = "Player "; 83 str.append(std::to_string(Player_ID) ;83 str.append(std::to_string(Player_ID)); 84 84 return str; 85 85 } … … 89 89 bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*) 90 90 { 91 for ( int i = 0; i < this->origin->neighbors.size(); ++i)91 for (unsigned int i = 0; i < this->origin->neighbors.size(); ++i) 92 92 { 93 if (this->target == this->origin->neighbors (i))93 if (this->target == this->origin->neighbors[i]) 94 94 return true; 95 95 } … … 105 105 return true; 106 106 107 for ( int i = 0; i < this->origin->neighbors.size(); ++i)107 for (unsigned int i = 0; i < this->origin->neighbors.size(); ++i) 108 108 { 109 if (this->origin->getOwner_ID() == this->origin->neighbors (i)->getOwner_ID())110 return existPath(this->origin->neighbors (i), this->target);109 if (this->origin->getOwner_ID() == this->origin->neighbors[i]->getOwner_ID()) 110 return existPath(this->origin->neighbors[i], this->target); 111 111 } 112 112 -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
r12105 r12109 14 14 #include <vector> 15 15 #include <string> 16 #include "infos/HumanPlayer.h" 16 17 17 18 enum MoveType { ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL }; … … 21 22 namespace orxonox 22 23 { 23 class WagnisPlayer : public BaseClass24 class WagnisPlayer : public HumanPlayer 24 25 { 25 26 public: 26 WagnisPlayer(Context* ,WagnisGameboard*);27 WagnisPlayer(Context*); 27 28 virtual ~WagnisPlayer(); 28 29
Note: See TracChangeset
for help on using the changeset viewer.