#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; this->players.push_back(nullptr); for(int i = 1;i <= n;i++){ WagnisPlayer* p = new WagnisPlayer(context); p->gameBoard = this->gameBoard; p->Player_ID = i; p->master = this; //p->finishedStageCallback = &Wagnis::playerFinishedStage; this->players.push_back(p); } } //Destructor Wagnis::~Wagnis(){} //Runs the game void Wagnis::start(){ Deathmatch::start(); if(this->gameStage == NOT_READY){ this->createGame(); } //this->gameStage = CHOOSE_PROVINCE_STAGE; //this->players[1]->gameStage = this->gameStage; //this->players[1]->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::playerFinishedStage(WagnisPlayer* player){ /////////////////TEST//////////// orxout()<<"juhuuuuuuuuuuuuuuuuuuu"<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+1 < this->players.size()){ this->active_player++; this->players[this->active_player]->gameStage = CHOOSE_PROVINCE_STAGE; this->players[this->active_player]->is_active = true; }else{ this->active_player = 1; this->players[this->active_player]->gameStage = REINFORCEMENT_STAGE; this->players[this->active_player]->is_active = true; } break; } case REINFORCEMENT_STAGE:{ } case ATTACK_STAGE:{ } case MOVE_STAGE:{ } } } //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"<