#include "Wagnis.h" namespace orxonox{ RegisterClass(Wagnis); //Constructor Wagnis::Wagnis(Context* context) : Deathmatch(context){ RegisterObject(Wagnis); this->gameBoard = nullptr; this->gameStage = NOT_READY; this->active_player = 1; int n = 3; for(int i = 0;i < n;i++){ WagnisPlayer* p = new WagnisPlayer(context); p->Player_ID = i+1; p->master = this; this->players.push_back(p); } } //Destructor Wagnis::~Wagnis(){} //Runs the game void Wagnis::start(){ Deathmatch::start(); if(this->gameStage == NOT_READY){ this->createGame(); for(WagnisPlayer* ptr: this->players){ ptr->gameBoard = this->gameBoard; } } this->gameStage = CHOOSE_PROVINCE_STAGE; this->players.at(0)->gameStage = this->gameStage; this->players.at(0)->is_active = true; } //Tick void Wagnis::tick(float dt){ SUPER(Wagnis,tick,dt); } /** * Callback function for Player classes. Needs to be called for the game to go on. * arg: player: pointer to the player which finished his stage. * (used to deactivate player after finishing) * enum GameStage { NOT_READY, CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE }; **/ void Wagnis::playerFinishedStageCallback(WagnisPlayer* player){ if(this->active_player != player->Player_ID){ orxout()<<"shit happend. This player should not be activ. Wagnis::playerFinishedStage was called from wrong player"<gameStage){ case CHOOSE_PROVINCE_STAGE:{ player->is_active = false; if(this->active_player < this->players.size()){ this->active_player++; WagnisPlayer* next = this->players[this->active_player-1]; next->gameStage = CHOOSE_PROVINCE_STAGE; next->is_active = true; orxout()<<"Player "<Player_ID<<"\'s turn. Please choose province"<active_player = 1; WagnisPlayer* next = this->players[this->active_player-1]; next->gameStage = REINFORCEMENT_STAGE; this->gameStage = REINFORCEMENT_STAGE; next->is_active = true; orxout()<<"Player "<Player_ID<<"\'s turn. Reinforcement"<gameBoard->initializeNeighbors(); //for(WagnisPlayer* p: this->players){ //this->playerEntered(p); //} orxout() << "Game creation finished" << endl; } //Finds the pointer to the gameBoard bool Wagnis::findGameBoard(){ for (WagnisGameboard* gb : ObjectList()){ this->gameBoard = gb; orxout()<<"Gameboard pointer found and added"<