forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disease.cpp
68 lines (55 loc) · 1.6 KB
/
disease.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "disease.h"
#include "assign.h"
#include "debug.h"
#include "generic_factory.h"
#include "string_id.h"
namespace
{
generic_factory<disease_type> disease_factory( "disease_type" );
} // namespace
template<>
const disease_type &string_id<disease_type>::obj() const
{
return disease_factory.obj( *this );
}
template<>
bool string_id<disease_type>::is_valid() const
{
return disease_factory.is_valid( *this );
}
void disease_type::load_disease_type( const JsonObject &jo, const std::string &src )
{
disease_factory.load( jo, src );
}
void disease_type::reset()
{
disease_factory.reset();
}
void disease_type::load( const JsonObject &jo, const std::string & )
{
disease_type new_disease;
assign( jo, "id", id );
assign( jo, "min_duration", min_duration );
assign( jo, "max_duration", max_duration );
assign( jo, "min_intensity", min_intensity );
assign( jo, "max_intensity", max_intensity );
assign( jo, "health_threshold", health_threshold );
assign( jo, "symptoms", symptoms );
JsonArray jsr = jo.get_array( "affected_bodyparts" );
while( jsr.has_more() ) {
new_disease.affected_bodyparts.emplace( get_body_part_token( jsr.next_string() ) );
}
}
const std::vector<disease_type> &disease_type::get_all()
{
return disease_factory.get_all();
}
void disease_type::check_disease_consistency()
{
for( const disease_type &dis : get_all() ) {
const efftype_id &symp = dis.symptoms;
if( !symp.is_valid() ) {
debugmsg( "disease_type %s has invalid efftype_id %s in symptoms", dis.id.c_str(), symp.c_str() );
}
}
}