-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvertebrateChecker.cpp
More file actions
39 lines (34 loc) · 1.31 KB
/
InvertebrateChecker.cpp
File metadata and controls
39 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "headerFiles/InvertebrateChecker.h"
#include "headerFiles/SeaCreature.h"
#include "headerFiles/db.h"
#include <utility>
std::pair<bool, const Creature*> InvertebrateChecker::canKeep(SeaCreature* creature){
const Creature* creatureRules = nullptr;
for (const auto& c : data.invertebrates){
if (c.specie == creature->specie){
creatureRules = &c;
break;
}
}
if (creatureRules){
if(creatureRules->bag_limit == 0) return {false, creatureRules};
bool canCarryEggs = !creatureRules->must_return_if_carrying_eggs;
if(creatureRules->size_limit_cm.size() == 0){
if(canCarryEggs || (!canCarryEggs && !creature->hasEggs)){
return {true, creatureRules};
}else{
return {false, creatureRules};
}
}
int maxLength = creatureRules->size_limit_cm[1] == -1 ? INT_MAX : creatureRules->size_limit_cm[1];
int minLength = creatureRules->size_limit_cm[0];
if(creature->length >= minLength && creature->length <= maxLength){
if(canCarryEggs || (!canCarryEggs && !creature->hasEggs)){
return {true, creatureRules};
}else{
return {false, creatureRules};
}
}
}
return {false, creatureRules};
}