summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-11-22 19:41:09 -0600
committertom <tom@ground-control>2015-11-22 19:41:09 -0600
commit84d63287c4d052052c9975714bbc253b18d28920 (patch)
tree5c11d0d8cbffc9d595133caf63878c3d7c3416f3
parent9f0de11816fdbd0981aeaa3a840e3942fd249eb4 (diff)
removed occupied, just used men vector
-rw-r--r--inc/Character.hpp4
-rw-r--r--inc/List.hpp2
-rw-r--r--src/Character.cpp8
-rw-r--r--src/List.cpp9
4 files changed, 8 insertions, 15 deletions
diff --git a/inc/Character.hpp b/inc/Character.hpp
index 3111154..9773762 100644
--- a/inc/Character.hpp
+++ b/inc/Character.hpp
@@ -14,8 +14,8 @@ class Character
Character(char nSymbol, int nColor, Location L);
void move(Location L){l=L;}
void draw(WINDOW * w);
- Location action(vector <Location> occupied);
- bool check(Location L, vector <Location> occupied);
+ Location action(vector <Character> men);
+ bool check(Location L, vector <Character> men);
Location getLocation(){return l;}
char getSymbol(){return symbol;}
diff --git a/inc/List.hpp b/inc/List.hpp
index 931ff8a..ce3f413 100644
--- a/inc/List.hpp
+++ b/inc/List.hpp
@@ -6,7 +6,6 @@
#include <ncurses.h>
#include <ctime>
#include <cstdlib>
-#include "Location.hpp"
using namespace std;
class List
@@ -17,7 +16,6 @@ class List
void action();
private:
vector <Character> men;
- vector <Location> occupied;
};
#endif
diff --git a/src/Character.cpp b/src/Character.cpp
index 8b4a4b5..0ab594b 100644
--- a/src/Character.cpp
+++ b/src/Character.cpp
@@ -13,7 +13,7 @@ void Character::draw(WINDOW * w)
mvwaddch(w,l.x,l.y,symbol);
}
-Location Character::action(vector <Location> occupied)
+Location Character::action(vector <Character> men)
{
if(order == "wander")
{
@@ -64,7 +64,7 @@ Location Character::action(vector <Location> occupied)
Lo = l;
}
- if(check(Lo,occupied))
+ if(check(Lo,men))
{
move(Lo);
return Lo;
@@ -74,10 +74,10 @@ Location Character::action(vector <Location> occupied)
}
}
-bool Character::check(Location L, vector <Location> occupied)
+bool Character::check(Location L, vector <Character> men)
{
for(int i = 0; i < 10; i++)
- if(L.x == occupied[i].x && L.y == occupied[i].y)
+ if(L.x == men[i].getLocation().x && L.y == men[i].getLocation().y)
return false;
return true;
diff --git a/src/List.cpp b/src/List.cpp
index ed09c5a..05a6f66 100644
--- a/src/List.cpp
+++ b/src/List.cpp
@@ -8,8 +8,7 @@ List::List()
L.x = 150;
L.y = 150+i;
Character x ('@',4,L);
- men.push_back(x);
- occupied.push_back(x.getLocation());
+ men.push_back(x);
}
}
@@ -22,9 +21,5 @@ void List::draw(WINDOW * w)
void List::action()
{
for(int i = 0; i < 10; i++)
- {
- Location L = men[i].action(occupied);
- if (L.x != 0 && L.y != 0)
- occupied[i]=L;
- }
+ men[i].action(men);
}