#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 = 8; 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; orxout()<<"Player "<<1<<"\'s turn. Please choose province."<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."<gameStage = ATTACK_STAGE; this->gameStage = ATTACK_STAGE; orxout()<<"Player "<Player_ID<<"\'s turn. Attack."<gameStage = MOVE_STAGE; this->gameStage = MOVE_STAGE; orxout()<<"Player "<Player_ID<<"\'s turn. Move."<is_active = false; if(this->active_player < this->players.size()){ this->active_player++; }else{ this->active_player = 1; } WagnisPlayer* next = this->players[this->active_player - 1]; orxout()<<"Player "<Player_ID<<"\'s turn. Reinforcement."<gameStage = REINFORCEMENT_STAGE; this->gameStage = REINFORCEMENT_STAGE; next->is_active = true; break; } default:{} } } //Creates and links all needed classes void Wagnis::createGame(){ orxout() << "Game creation started" << endl; if(!findGameBoard()){ orxout() << "Error: GameBoard not found" << endl; } //this->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"<