Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

WIP 21 nov

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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           
Note: See TracChangeset for help on using the changeset viewer.