Skip to content
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

feat: allow installing non-sterile CBM when Infection Immune #2671

Merged
merged 4 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,7 @@
"id": "INFRESIST",
"name": { "str": "Infection Immune" },
"points": 1,
"description": "Your immune system is particularly good at resisting infections. Your wounds will no longer become infected, altough existing infections are still dangerous.",
"description": "Your immune system is particularly good at resisting infections. Your wounds will no longer become infected, altough existing infections are still dangerous. You will also be able to install non-sterile CBMs.",
"starting_trait": true,
"category": [ "TROGLOBITE", "RAT", "MEDICAL" ]
},
Expand Down
22 changes: 10 additions & 12 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <functional>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <set>
#include <string>
Expand Down Expand Up @@ -78,6 +79,7 @@ static const trait_id trait_DEBUG_BIONICS( "DEBUG_BIONICS" );
static const trait_id trait_NOPAIN( "NOPAIN" );
static const trait_id trait_SAPROPHAGE( "SAPROPHAGE" );
static const trait_id trait_SAPROVORE( "SAPROVORE" );
static const trait_id trait_INFRESIST( "INFRESIST" );

static const std::string flag_ALLOWS_REMOTE_USE( "ALLOWS_REMOTE_USE" );
static const std::string flag_FILTHY( "FILTHY" );
Expand Down Expand Up @@ -1791,7 +1793,6 @@ static item_location autodoc_internal( player &u, player &patient,
{
inventory_pick_selector inv_s( u, preset );
std::string hint;
int drug_count = 0;

if( !surgeon ) {//surgeon use their own anesthetic, player just need money
if( patient.has_trait( trait_NOPAIN ) ) {
Expand All @@ -1803,11 +1804,10 @@ static item_location autodoc_internal( player &u, player &patient,
std::vector<const item *> a_filter = crafting_inv.items_with( []( const item & it ) {
return it.has_quality( qual_ANESTHESIA );
} );
for( const item *anesthesia_item : a_filter ) {
if( anesthesia_item->ammo_remaining() >= 1 ) {
drug_count += anesthesia_item->ammo_remaining();
}
}
const int drug_count = std::accumulate( a_filter.begin(), a_filter.end(), 0,
[]( int sum, const item * it ) {
return sum + it->ammo_remaining();
} );
hint = string_format( _( "<color_yellow>Available anesthetic: %i mL</color>" ), drug_count );
}
}
Expand All @@ -1820,11 +1820,9 @@ static item_location autodoc_internal( player &u, player &patient,
_( "\n<color_light_green>Found bionic installation data. Affected CBMs are marked with an asterisk.</color>" ) );
}

if( uninstall ) {
inv_s.set_title( string_format( _( "Bionic removal patient: %s" ), patient.get_name() ) );
} else {
inv_s.set_title( string_format( _( "Bionic installation patient: %s" ), patient.get_name() ) );
}
const auto title = uninstall
? _( "Bionic removal patient: %s" ) : _( "Bionic installation patient: %s" );
inv_s.set_title( string_format( title, patient.get_name() ) );

inv_s.set_hint( hint );
inv_s.set_display_stats( false );
Expand Down Expand Up @@ -1881,7 +1879,7 @@ class bionic_install_preset: public inventory_selector_preset
const itype *itemtype = it->type;
const bionic_id &bid = itemtype->bionic->id;

if( it->has_fault( fault_bionic_nonsterile ) ) {
if( it->has_fault( fault_bionic_nonsterile ) && !p.has_trait( trait_INFRESIST ) ) {
// NOLINTNEXTLINE(cata-text-style): single space after the period for symmetry
return _( "/!\\ CBM is not sterile. /!\\ Please use autoclave or other methods to sterilize." );
} else if( pa.has_bionic( bid ) ) {
Expand Down