Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12164 for code/branches


Ignore:
Timestamp:
Dec 6, 2018, 8:45:47 PM (6 years ago)
Author:
samuelbl
Message:

Checkmove function fixed

Location:
code/branches/wagnis_HS18/src/modules/wagnis
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc

    r12162 r12164  
    77#include <cstdlib>
    88#include <ctime>
     9
    910
    1011namespace orxonox
     
    247248        if (move_type == MOVE)
    248249        {
     250            AlreadyChecked.clear();
    249251            if (existPath(this->origin_province, this->target_province))//path exists, all belong to same player
    250252            {
     
    294296    bool WagnisPlayer::existPath(WagnisProvince* origin, WagnisProvince* target)
    295297    {
     298        AlreadyChecked.push_back(origin->getID());
     299       
    296300        if (origin->getOwner_ID() == target->getOwner_ID() && isNeighbour(origin, target))
    297301            return true;
    298302       
    299303        for (unsigned int i = 0; i < origin->neighbors.size(); ++i)
    300         {
    301             if (origin->getOwner_ID() == origin->neighbors[i]->getOwner_ID())
     304        {               
     305            if ((origin->getOwner_ID() == origin->neighbors[i]->getOwner_ID()) && (!(contains(AlreadyChecked, origin->neighbors[i]->getID()))))
    302306                return existPath(origin->neighbors[i], target);
    303307        }
    304            
     308       
    305309        return false;
    306310    }
     
    347351    }
    348352
     353    bool WagnisPlayer::contains(std::vector<int> a, int key)
     354    {
     355        if(std::count(a.begin(), a.end(), key))
     356            return true;
     357        else
     358            return false;
     359    }
     360   
    349361    void WagnisPlayer::setActive(bool b){
    350362        this->is_active = b;
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h

    r12160 r12164  
    1717#include <string>
    1818#include "infos/HumanPlayer.h"
     19#include <algorithm>
     20#include <iostream>
     21
    1922
    2023
     
    5053        WagnisProvince* target_province;
    5154        int reinforcements;
     55        std::vector<int> AlreadyChecked;
    5256        bool isNeighbour(WagnisProvince*, WagnisProvince*);
    5357        bool existPath(WagnisProvince*, WagnisProvince*);
     58        bool contains(std::vector<int>, int);
    5459        int dice();
    5560        int best3(int, int, int);
  • code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h

    r12159 r12164  
    1515#include <OgreColourValue.h>
    1616#include "tools/ToolsPrereqs.h"
    17 
    1817
    1918namespace orxonox
Note: See TracChangeset for help on using the changeset viewer.