-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* affected_bodyparts * expose_to_disease() * foodborne diseases
- Loading branch information
Showing
12 changed files
with
187 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
{ | ||
"type": "disease_type", | ||
"id": "bad_food", | ||
"min_duration": "6 m", | ||
"max_duration": "1 h", | ||
"min_intensity": 1, | ||
"max_intensity": 1, | ||
"health_threshold": 100, | ||
"symptoms": "foodpoison" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "disease.h" | ||
|
||
#include "assign.h" | ||
#include "generic_factory.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::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() ); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#ifndef DISEASE_H | ||
#define DISEASE_H | ||
|
||
#include "bodypart.h" | ||
#include "effect.h" | ||
#include "type_id.h" | ||
#include "json.h" | ||
|
||
class disease_type | ||
{ | ||
public: | ||
static void load_disease_type( const JsonObject &jo, const std::string &src ); | ||
void load( const JsonObject &jo, const std::string & ); | ||
static const std::vector<disease_type> &get_all(); | ||
static void check_disease_consistency(); | ||
bool was_loaded; | ||
|
||
diseasetype_id id; | ||
time_duration min_duration = 1_turns; | ||
time_duration max_duration = 1_turns; | ||
int min_intensity = 1; | ||
int max_intensity = 1; | ||
/**Affected body parts*/ | ||
std::set<body_part> affected_bodyparts; | ||
/**If not empty this sets the health threshold above which you're immune to the disease*/ | ||
cata::optional<int> health_threshold; | ||
/**effect applied by this disease*/ | ||
efftype_id symptoms; | ||
|
||
}; | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters