Skip to content

Commit

Permalink
Allow 'a'pplying bottled medication.
Browse files Browse the repository at this point in the history
  • Loading branch information
OzoneH3 committed Dec 5, 2018
1 parent 762394d commit 4e14b85
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,33 +561,39 @@ class activatable_inventory_preset : public pickup_inventory_preset
activatable_inventory_preset( const player &p ) : pickup_inventory_preset( p ), p( p ) {
if( get_option<bool>( "INV_USE_ACTION_NAMES" ) ) {
append_cell( [ this ]( const item_location & loc ) {
return string_format( "<color_light_green>%s</color>", get_action_name( *loc ).c_str() );
const item &it = !( *loc ).is_container_empty() && ( *loc ).get_contained().is_medication() &&
( *loc ).get_contained().type->has_use() ? ( *loc ).get_contained() : *loc;
return string_format( "<color_light_green>%s</color>", get_action_name( it ).c_str() );
}, _( "ACTION" ) );
}
}

bool is_shown( const item_location &loc ) const override {
if( !( *loc ).is_container_empty() && ( *loc ).get_contained().is_medication() && ( *loc ).get_contained().type->has_use() ) {
return true;
}
return loc->type->has_use();
}

std::string get_denial( const item_location &loc ) const override {
const auto &uses = loc->type->use_methods;
const item &it = !( *loc ).is_container_empty() && ( *loc ).get_contained().is_medication() &&
( *loc ).get_contained().type->has_use() ? ( *loc ).get_contained() : *loc;
const auto &uses = it.type->use_methods;

if( uses.size() == 1 ) {
const auto ret = uses.begin()->second.can_call( p, *loc, false, p.pos() );
const auto ret = uses.begin()->second.can_call( p, it, false, p.pos() );
if( !ret.success() ) {
return trim_punctuation_marks( ret.str() );
}
}

if( !p.has_enough_charges( *loc, false ) ) {
if( !p.has_enough_charges( it, false ) ) {
return string_format(
ngettext( "Needs at least %d charge",
"Needs at least %d charges", loc->ammo_required() ),
loc->ammo_required() );
}

const item &it = *loc;
if( !it.has_flag( "ALLOWS_REMOTE_USE" ) ) {
return pickup_inventory_preset::get_denial( loc );
}
Expand Down

0 comments on commit 4e14b85

Please sign in to comment.