Changeset 12114 for code/branches/wagnis_HS18/src
- Timestamp:
- Nov 21, 2018, 12:03:16 PM (6 years ago)
- Location:
- code/branches/wagnis_HS18/src/modules/wagnis
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
r12068 r12114 1 2 3 1 4 #include "Wagnis.h" 2 #include "WagnisGameboard.h"3 #include "WagnisProvince.h"4 5 5 6 RegisterClass(Wagnis); 7 8 void Wagnis::createGame() 9 { 10 //todo 11 void Wagnis::setPlayers() 12 { 13 //todo 14 } 15 16 void Wagnis::chooseProvinces() 17 { 18 //todo 19 } 20 } 6 7 8 namespace orxonox{ 9 10 RegisterClass(Wagnis); 11 12 Wagnis::Wagnis(Context* context) : Deathmatch(context){ 13 RegisterObject(Wagnis); 14 } 15 //Destructor 16 Wagnis::~Wagnis(){} 17 18 19 } 20 21 21 22 22 -
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h
r12072 r12114 1 2 3 4 #ifndef Wagnis_h 5 #define Wagnis_h 6 7 1 8 #include "WagnisGameboard.h" 2 9 #include "WagnisProvince.h" 10 #include "gametypes/Deathmatch.h" 11 3 12 4 13 /** Die Wagnis Klasse hat die folgenden Aufgaben: … … 18 27 **/ 19 28 29 30 20 31 namespace orxonox 21 32 { 22 class _WagnisExportWagnis : public Deathmatch33 class /**_WagnisExport**/ Wagnis : public Deathmatch 23 34 { 24 public:25 35 26 // to start the game 27 void createGame(); // creates and links provinces 28 29 30 // additional checking funtions 31 int troopCounter(int); // counts how many reinforcements player gets 32 bool attackChecker; // checks whether an attack move is valid 33 // (provinces linked, enough troops, no own province) 34 bool moveChecker; // checks whether a troop movement is valid 35 // (start and target belong to player, link existing) 36 void attackSimulator; // calculates outcome of battle 37 38 39 } 40 36 }; 41 37 } 38 #endif 39 /* Wagnis_h */ -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h
r12077 r12114 37 37 void initializeNeighbors(std::string); 38 38 39 40 private: 39 41 40 std::vector<WagnisProvince*> provs; 42 43 41 int parse_int(std::string,unsigned int); 44 42 }; -
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 -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
r12109 r12114 7 7 #define Wagnis_Player_h 8 8 9 #include "Wagnis.h" 9 10 #include "OrxonoxPrereqs.h" 10 11 #include "core/CoreIncludes.h" … … 17 18 18 19 enum MoveType { ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL }; 20 enum GameStagexyz { CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE }; 19 21 20 22 … … 22 24 namespace orxonox 23 25 { 24 class WagnisPlayer : public HumanPlayer 26 class WagnisPlayer : public HumanPlayer, public Tickable 25 27 { 26 28 public: 27 29 WagnisPlayer(Context*); 28 30 virtual ~WagnisPlayer(); 31 void tick(float); 29 32 30 33 void playerTurn(); … … 35 38 std::string toString(); 36 39 37 private: 40 41 42 GameStagexyz gamestage; 43 bool province_selection_changed; 44 bool is_active; 38 45 int Player_ID; 39 46 WagnisGameboard* gameBoard; 40 WagnisProvince* origin ;41 WagnisProvince* target ;47 WagnisProvince* origin_province; 48 WagnisProvince* target_province; 42 49 bool isNeighbour(WagnisProvince*,WagnisProvince*); 43 50 bool existPath(WagnisProvince*,WagnisProvince*); -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
r12107 r12114 1 2 1 3 #include "WagnisProvince.h" 2 4 #include "core/CoreIncludes.h" … … 32 34 WagnisProvince::~WagnisProvince(){ 33 35 34 }35 36 //Tick37 void WagnisProvince::tick(float dt){38 SUPER(WagnisProvince, tick, dt);39 40 if(this->health_ < this->maxHealth_){41 this->health_ = this->maxHealth_;42 orxout() << "Health test ok" << endl; }43 36 } 44 37 … … 107 100 neighbors.push_back(prov); 108 101 } 102 103 void WagnisProvince::setBillbardVisibility(bool b){ 104 //TODO set visibility of billboard 105 } 109 106 } -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h
r12107 r12114 22 22 WagnisProvince(Context*); 23 23 virtual ~WagnisProvince(); 24 void tick(float);25 24 26 25 … … 40 39 41 40 void addNeighbor(WagnisProvince*); 41 void setBillbardVisibility(bool); 42 43 42 44 std::vector<WagnisProvince*> neighbors; 43 44 45 45 int owner_ID; 46 46 int troops;
Note: See TracChangeset
for help on using the changeset viewer.