Skip to content

Commit

Permalink
change scope of player::has_charges
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Oct 19, 2019
1 parent 8e6d238 commit 5340d46
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
12 changes: 12 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,18 @@ class Character : public Creature, public visitable<Character>
void stop_hauling();
bool is_hauling() const;

// Has a weapon, inventory item or worn item with flag
bool has_item_with_flag( const std::string &flag, bool need_charges = false ) const;
/**
* All items that have the given flag (@ref item::has_flag).
*/
std::vector<const item *> all_items_with_flag( const std::string &flag ) const;

bool has_fire( int quantity ) const;

bool has_charges( const itype_id &it, int quantity,
const std::function<bool( const item & )> &filter = return_true<item> ) const;

/** Legacy activity assignment, should not be used where resuming is important. */
void assign_activity( const activity_id &type, int moves = calendar::INDEFINITELY_LONG,
int index = -1, int pos = INT_MIN,
Expand Down
3 changes: 2 additions & 1 deletion src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,8 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const
return cost >= 0 ? cost : it.ammo_required();
}

ret_val<bool> enzlave_actor::can_use( const Character &p, const item &, bool, const tripoint & ) const
ret_val<bool> enzlave_actor::can_use( const Character &p, const item &, bool,
const tripoint & ) const
{
/** @EFFECT_SURVIVAL >=1 allows enzlavement */

Expand Down
10 changes: 5 additions & 5 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6446,7 +6446,7 @@ bool player::use_charges_if_avail( const itype_id &it, int quantity )
return false;
}

bool player::has_fire( const int quantity ) const
bool Character::has_fire( const int quantity ) const
{
// TODO: Replace this with a "tool produces fire" flag.

Expand Down Expand Up @@ -6617,8 +6617,8 @@ int player::amount_worn( const itype_id &id ) const
return amount;
}

bool player::has_charges( const itype_id &it, int quantity,
const std::function<bool( const item & )> &filter ) const
bool Character::has_charges( const itype_id &it, int quantity,
const std::function<bool( const item & )> &filter ) const
{
if( it == "fire" || it == "apparatus" ) {
return has_fire( quantity );
Expand Down Expand Up @@ -10595,7 +10595,7 @@ float player::speed_rating() const
return ret;
}

std::vector<const item *> player::all_items_with_flag( const std::string &flag ) const
std::vector<const item *> Character::all_items_with_flag( const std::string &flag ) const
{
return items_with( [&flag]( const item & it ) {
return it.has_flag( flag );
Expand Down Expand Up @@ -10644,7 +10644,7 @@ bool player::crush_frozen_liquid( item_location loc )
return false;
}

bool player::has_item_with_flag( const std::string &flag, bool need_charges ) const
bool Character::has_item_with_flag( const std::string &flag, bool need_charges ) const
{
return has_item_with( [&flag, &need_charges]( const item & it ) {
if( it.is_tool() && need_charges ) {
Expand Down
11 changes: 0 additions & 11 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,6 @@ class player : public Character
float power_rating() const override;
float speed_rating() const override;

/**
* All items that have the given flag (@ref item::has_flag).
*/
std::vector<const item *> all_items_with_flag( const std::string &flag ) const;
void process_active_items();
/**
* Remove charges from a specific item (given by its item position).
Expand Down Expand Up @@ -1194,9 +1190,6 @@ class player : public Character
std::list<item> use_charges( const itype_id &what, int qty,
const std::function<bool( const item & )> &filter = return_true<item> );

bool has_charges( const itype_id &it, int quantity,
const std::function<bool( const item & )> &filter = return_true<item> ) const;

/** Returns the amount of item `type' that is currently worn */
int amount_worn( const itype_id &id ) const;

Expand All @@ -1212,9 +1205,6 @@ class player : public Character
*/
bool crush_frozen_liquid( item_location loc );

// Has a weapon, inventory item or worn item with flag
bool has_item_with_flag( const std::string &flag, bool need_charges = false ) const;

bool has_mission_item( int mission_id ) const; // Has item with mission_id
/**
* Check whether the player has a gun that uses the given type of ammo.
Expand Down Expand Up @@ -1623,7 +1613,6 @@ class player : public Character
// Trigger and disable mutations that can be so toggled.
void activate_mutation( const trait_id &mutation );
void deactivate_mutation( const trait_id &mut );
bool has_fire( int quantity ) const;
void use_fire( int quantity );

/** Determine player's capability of recharging their CBMs. */
Expand Down

0 comments on commit 5340d46

Please sign in to comment.