summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Barrett <tombarrett@siu.edu>2017-03-15 14:43:08 -0500
committerTom Barrett <tombarrett@siu.edu>2017-03-15 14:43:08 -0500
commitc86eef1db053a51748cf75a8318604b1d14b5be5 (patch)
tree2f2040c95880f384f6f448b96932b2571455cf7b
parent836f56a40fa4a2b8e68c23b2c299e50fefe0c15d (diff)
-string comparison is for losers
-rw-r--r--inc/dna.hpp2
-rw-r--r--src/dna.cpp10
-rw-r--r--src/list.cpp10
3 files changed, 11 insertions, 11 deletions
diff --git a/inc/dna.hpp b/inc/dna.hpp
index 11886e9..ff252a8 100644
--- a/inc/dna.hpp
+++ b/inc/dna.hpp
@@ -10,7 +10,7 @@ class DNA
{
public:
DNA(){};
- DNA(std::string s);
+ DNA(int type);
DNA combine(DNA D);
diff --git a/src/dna.cpp b/src/dna.cpp
index dd1d606..1c70f46 100644
--- a/src/dna.cpp
+++ b/src/dna.cpp
@@ -1,8 +1,8 @@
#include "dna.hpp"
-DNA::DNA(std::string s)
+DNA::DNA(int type)
{
- if(s == "herbavore"){
+ if(type == HERBAVORE_TYPE){
type = HERBAVORE_TYPE;
eatType = PLANT_TYPE;
maxHealth = CREATURE_MAX_HEALTH;
@@ -20,7 +20,7 @@ DNA::DNA(std::string s)
appearance.green = 1;
appearance.blue = 1;
}
- else if(s == "carnivore"){
+ else if(type == CARNIVORE_TYPE){
type = CARNIVORE_TYPE;
eatType = HERBAVORE_TYPE;
maxHealth = CREATURE_MAX_HEALTH;
@@ -38,7 +38,7 @@ DNA::DNA(std::string s)
appearance.green = 0;
appearance.blue = 1;
}
- else if(s == "plant"){
+ else if(type == PLANT_TYPE){
type = PLANT_TYPE;
maxHealth = PLANT_MAX_HEALTH;
growAmount = PLANT_GROW_AMOUNT;
@@ -46,7 +46,7 @@ DNA::DNA(std::string s)
appearance.green = 1;
appearance.blue = 0;
}
- else if(s == "corpse"){
+ else if(type == CORPSE_TYPE){
type = CORPSE_TYPE;
maxHealth = CORPSE_MAX_HEALTH;
growAmount = CORPSE_DECAY_AMOUNT;
diff --git a/src/list.cpp b/src/list.cpp
index 0719ff0..5904079 100644
--- a/src/list.cpp
+++ b/src/list.cpp
@@ -3,20 +3,20 @@
List::List()
{
int i;
- DNA d = DNA("herbavore");
+ DNA d = DNA(HERBAVORE_TYPE);
Rectangle tmp;
for(i=0;i<HERBAVORES;i++){
Organism X(tmp,d);
creatures.push_back(X);
}
- d = DNA("carnivore");
+ d = DNA(CARNIVORE_TYPE);
for(i=0;i<CARNIVORES;i++){
Organism X(tmp, d);
creatures.push_back(X);
}
- d = DNA("plant");
+ d = DNA(PLANT_TYPE);
for(i=0;i<PLANTS;i++){
Organism X(tmp, d);
resources.push_back(X);
@@ -30,7 +30,7 @@ void List::Remove()
{
for(std::list<Organism>::iterator it = creatures.begin(); it!= creatures.end(); it++)
if(it->getHealth()<=0){
- DNA d = DNA("corpse");
+ DNA d = DNA(CORPSE_TYPE);
Organism X(it->getRectangle(), d);
resources.push_back(X);
creatures.erase(it--);
@@ -64,7 +64,7 @@ void List::Place()
tree.clear();
Rectangle tmp;
- DNA d = DNA("plant");
+ DNA d = DNA(PLANT_TYPE);
while(resources.size() < MINIMUM_PLANTS){
Organism X(tmp, d);
resources.push_back(X);