- Timestamp:
- Nov 21, 2018, 12:03:16 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
r12109 r12114 16 16 WagnisPlayer::WagnisPlayer(Context* context) : HumanPlayer(context){ 17 17 RegisterObject(WagnisPlayer); 18 this->origin = nullptr;19 this->target = nullptr;20 18 this->gameBoard = nullptr; 19 this->is_active = false; 20 this->origin_province = nullptr; 21 this->target_province = nullptr; 22 this->province_selection_changed = false; 21 23 } 22 24 //Destructor … … 24 26 25 27 } 28 //Tick 29 void WagnisPlayer::tick(float dt){ 30 SUPER(WagnisPlayer, tick, dt); 31 32 if(this->is_active){ 33 for(WagnisProvince* prov:this->gameBoard->provs){ 34 if(prov->getHealth() < prov->getMaxHealth()){ 35 if(prov->getHealth() <= prov->getMaxHealth()-1000.0f){ 36 this->target_province = prov; 37 this->province_selection_changed = true; 38 }else{ 39 this->origin_province = prov; 40 this->province_selection_changed = true; 41 } 42 } 43 } 44 45 if(this->province_selection_changed && this->origin_province != nullptr && this->target_province != nullptr){ 46 this->province_selection_changed = false; 47 switch(gamestage){ 48 case CHOOSE_PROVINCE_STAGE: 49 { 50 break; 51 } 52 case REINFORCEMENT_STAGE: 53 { 54 break; 55 } 56 case ATTACK_STAGE:{ 57 break; 58 } 59 case MOVE_STAGE:{ 60 break; 61 } 62 } 63 } 64 } 65 } 66 67 68 26 69 //Manages a Players turn 27 70 void WagnisPlayer::playerTurn(){ … … 33 76 if (move_type == ATTACK) 34 77 { 35 if (isNeighbour(this->origin , this->target))//TODO: provinces neighbours78 if (isNeighbour(this->origin_province, this->target_province))//TODO: provinces neighbours 36 79 { 37 if (this->origin ->getOwner_ID() == this->Player_ID) //origin belongs to player80 if (this->origin_province->getOwner_ID() == this->Player_ID) //origin belongs to player 38 81 { 39 if (this->target ->getOwner_ID() != this->Player_ID)//target belongs to enemy82 if (this->target_province->getOwner_ID() != this->Player_ID)//target belongs to enemy 40 83 return true; 41 84 } … … 45 88 if (move_type == MOVE) 46 89 { 47 if (existPath(this->origin , this->target))//TODO: path exists, all belong to same player90 if (existPath(this->origin_province, this->target_province))//TODO: path exists, all belong to same player 48 91 { 49 if (this->origin ->getOwner_ID() == this->Player_ID)//origin belongs to player92 if (this->origin_province->getOwner_ID() == this->Player_ID)//origin belongs to player 50 93 return true; 51 94 } … … 55 98 if (move_type == SET_TROOPS) 56 99 { 57 if (this->target ->getOwner_ID() == this->Player_ID)//target belongs to player100 if (this->target_province->getOwner_ID() == this->Player_ID)//target belongs to player 58 101 return true; 59 102 } … … 61 104 if (move_type == SET_TROOPS_INITIAL) 62 105 { 63 if (this->target ->getOwner_ID() == 0)//target belongs to nobody106 if (this->target_province->getOwner_ID() == 0)//target belongs to nobody 64 107 return true; 65 108 } … … 89 132 bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*) 90 133 { 91 for (unsigned int i = 0; i < this->origin ->neighbors.size(); ++i)134 for (unsigned int i = 0; i < this->origin_province->neighbors.size(); ++i) 92 135 { 93 if (this->target == this->origin->neighbors[i])136 if (this->target_province == this->origin_province->neighbors[i]) 94 137 return true; 95 138 } … … 102 145 bool WagnisPlayer::existPath(WagnisProvince*,WagnisProvince*) 103 146 { 104 if (this->origin ->getOwner_ID() == this->target->getOwner_ID() && isNeighbour(this->origin, this->target))147 if (this->origin_province->getOwner_ID() == this->target_province->getOwner_ID() && isNeighbour(this->origin_province, this->target_province)) 105 148 return true; 106 149 107 for (unsigned int i = 0; i < this->origin ->neighbors.size(); ++i)150 for (unsigned int i = 0; i < this->origin_province->neighbors.size(); ++i) 108 151 { 109 if (this->origin ->getOwner_ID() == this->origin->neighbors[i]->getOwner_ID())110 return existPath(this->origin ->neighbors[i], this->target);152 if (this->origin_province->getOwner_ID() == this->origin_province->neighbors[i]->getOwner_ID()) 153 return existPath(this->origin_province->neighbors[i], this->target_province); 111 154 } 112 155
Note: See TracChangeset
for help on using the changeset viewer.