Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2018, 12:03:16 PM (6 years ago)
Author:
stadlero
Message:

WIP 21 nov

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
    14#include "Wagnis.h"
    2 #include "WagnisGameboard.h"
    3 #include "WagnisProvince.h"
    45
    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
     8namespace orxonox{
     9
     10RegisterClass(Wagnis);
     11
     12Wagnis::Wagnis(Context* context) : Deathmatch(context){
     13    RegisterObject(Wagnis);
     14}
     15//Destructor
     16Wagnis::~Wagnis(){}
     17
     18
     19}
     20
    2121
    2222       
  • code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.h

    r12072 r12114  
     1
     2
     3
     4#ifndef Wagnis_h
     5#define Wagnis_h
     6
     7
    18#include "WagnisGameboard.h"
    29#include "WagnisProvince.h"
     10#include "gametypes/Deathmatch.h"
     11
    312
    413/** Die Wagnis Klasse hat die folgenden Aufgaben:
     
    1827 **/
    1928
     29
     30
    2031namespace orxonox
    2132{
    22     class _WagnisExport Wagnis : public Deathmatch
     33    class /**_WagnisExport**/ Wagnis : public Deathmatch
    2334    {
    24         public:
    2535
    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    };
    4137}
     38#endif
     39 /* Wagnis_h */
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisGameboard.h

    r12077 r12114  
    3737        void initializeNeighbors(std::string);
    3838
    39    
    40     private:
     39
    4140        std::vector<WagnisProvince*> provs;
    42        
    4341        int parse_int(std::string,unsigned int);
    4442    };
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc

    r12109 r12114  
    1616    WagnisPlayer::WagnisPlayer(Context* context) : HumanPlayer(context){
    1717        RegisterObject(WagnisPlayer);
    18         this->origin = nullptr;
    19         this->target = nullptr;
    2018        this->gameBoard = nullptr;
     19        this->is_active = false;
     20        this->origin_province = nullptr;
     21        this->target_province = nullptr;
     22        this->province_selection_changed = false;
    2123    }
    2224    //Destructor
     
    2426
    2527    }
     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
    2669    //Manages a Players turn
    2770    void WagnisPlayer::playerTurn(){
     
    3376        if (move_type == ATTACK)
    3477        {
    35             if (isNeighbour(this->origin, this->target))//TODO: provinces neighbours
     78            if (isNeighbour(this->origin_province, this->target_province))//TODO: provinces neighbours
    3679            {
    37                 if (this->origin->getOwner_ID() == this->Player_ID) //origin belongs to player
     80                if (this->origin_province->getOwner_ID() == this->Player_ID) //origin belongs to player
    3881                {
    39                     if (this->target->getOwner_ID() != this->Player_ID)//target belongs to enemy
     82                    if (this->target_province->getOwner_ID() != this->Player_ID)//target belongs to enemy
    4083                        return true;
    4184                }
     
    4588        if (move_type == MOVE)
    4689        {
    47             if (existPath(this->origin, this->target))//TODO: path exists, all belong to same player
     90            if (existPath(this->origin_province, this->target_province))//TODO: path exists, all belong to same player
    4891            {
    49                 if (this->origin->getOwner_ID() == this->Player_ID)//origin belongs to player
     92                if (this->origin_province->getOwner_ID() == this->Player_ID)//origin belongs to player
    5093                    return true;
    5194            }
     
    5598        if (move_type == SET_TROOPS)
    5699        {
    57             if (this->target->getOwner_ID() == this->Player_ID)//target belongs to player
     100            if (this->target_province->getOwner_ID() == this->Player_ID)//target belongs to player
    58101                return true;
    59102        }
     
    61104        if (move_type == SET_TROOPS_INITIAL)
    62105        {
    63             if (this->target->getOwner_ID() == 0)//target belongs to nobody
     106            if (this->target_province->getOwner_ID() == 0)//target belongs to nobody
    64107                return true;
    65108        }
     
    89132    bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*)
    90133    {
    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)
    92135        {
    93             if (this->target == this->origin->neighbors[i])
     136            if (this->target_province == this->origin_province->neighbors[i])
    94137                return true;
    95138        }
     
    102145    bool WagnisPlayer::existPath(WagnisProvince*,WagnisProvince*)
    103146    {
    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))
    105148            return true;
    106149       
    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)
    108151        {
    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);
    111154        }
    112155           
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h

    r12109 r12114  
    77#define Wagnis_Player_h
    88
     9#include "Wagnis.h"
    910#include "OrxonoxPrereqs.h"
    1011#include "core/CoreIncludes.h"
     
    1718
    1819enum MoveType { ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL };
     20enum GameStagexyz { CHOOSE_PROVINCE_STAGE, REINFORCEMENT_STAGE, ATTACK_STAGE, MOVE_STAGE };
    1921
    2022
     
    2224namespace orxonox
    2325{
    24     class WagnisPlayer : public HumanPlayer
     26    class WagnisPlayer : public HumanPlayer, public Tickable
    2527    {
    2628    public:
    2729        WagnisPlayer(Context*);
    2830        virtual ~WagnisPlayer();
     31        void tick(float);
    2932
    3033        void playerTurn();
     
    3538        std::string toString();
    3639
    37     private:
     40
     41
     42        GameStagexyz gamestage;
     43        bool province_selection_changed;
     44        bool is_active;
    3845        int Player_ID;
    3946        WagnisGameboard* gameBoard;
    40         WagnisProvince* origin;
    41         WagnisProvince* target;
     47        WagnisProvince* origin_province;
     48        WagnisProvince* target_province;
    4249        bool isNeighbour(WagnisProvince*,WagnisProvince*);
    4350        bool existPath(WagnisProvince*,WagnisProvince*);
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc

    r12107 r12114  
     1
     2
    13#include "WagnisProvince.h"
    24#include "core/CoreIncludes.h"
     
    3234    WagnisProvince::~WagnisProvince(){
    3335
    34     }
    35 
    36     //Tick
    37     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;        }
    4336    }
    4437
     
    107100        neighbors.push_back(prov);
    108101    }
     102
     103    void WagnisProvince::setBillbardVisibility(bool b){
     104        //TODO set visibility of billboard
     105    }
    109106}
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h

    r12107 r12114  
    2222        WagnisProvince(Context*);
    2323        virtual ~WagnisProvince();
    24         void tick(float);
    2524
    2625
     
    4039
    4140        void addNeighbor(WagnisProvince*);
     41        void setBillbardVisibility(bool);
     42
     43
    4244        std::vector<WagnisProvince*> neighbors;
    43 
    44  
    4545        int owner_ID;
    4646        int troops;
Note: See TracChangeset for help on using the changeset viewer.