-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertebrateChecker.cpp
More file actions
30 lines (24 loc) · 957 Bytes
/
VertebrateChecker.cpp
File metadata and controls
30 lines (24 loc) · 957 Bytes
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
#include "headerFiles/VertebrateChecker.h"
#include "headerFiles/SeaCreature.h"
#include "headerFiles/db.h"
#include <climits>
#include <utility>
std::pair<bool, const Creature*> VertebrateChecker::canKeep(SeaCreature* creature){
const Creature* creatureRules = nullptr;
for (const auto& c : data.vertebrates){
if (c.specie == creature->specie){
creatureRules = &c;
break;
}
}
if (creatureRules){
if(creatureRules->bag_limit == 0) return {false, creatureRules};
if(creatureRules->size_limit_cm.size() == 0) return {true, 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){
return {true, creatureRules};
}
}
return {false, creatureRules};
}