-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disease infrastructure #35843
Merged
Merged
Disease infrastructure #35843
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2628ca1
disease_type infrastructure
50f9693
more infrastructure
725d634
affected_bodyparts
b77c502
expose_to_disease()
f4d0a74
foodborne diseases
fe677ef
Merge branch 'master' of https://github.com/CleverRaven/Cataclysm-DDA…
6d5d778
get it to compile
864d773
doc first part
35bff87
fixes
0f65153
doc and json
b981fc6
fix merge error
cf5fbb4
array to object
54ffcf4
Update doc/JSON_INFO.md
Fris0uman c934169
Merge branch 'master' into disease
Fris0uman 150377a
Merge branch 'master' into disease
Fris0uman b73b2e0
include fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to include this here, it needs to be in character.cpp and consumption.cpp