Skip to content

Commit

Permalink
BP Status Widget: Restore bool defs for status conditions
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Pierce <[email protected]>
  • Loading branch information
dseguin and wapcaplet committed Jan 18, 2022
1 parent d32810b commit 9e53ca0
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,34 +1020,44 @@ std::pair<std::string, nc_color> display::vehicle_fuel_percent_text_color( const
static std::map<bodypart_status, nc_color> bodypart_status_colors( const Character &u,
const bodypart_id &bp )
{
// List of active statuses and associated colors
std::map<bodypart_status, nc_color> ret;

// Empty if no bodypart given
if( bp == bodypart_str_id::NULL_ID() ) {
return ret;
}

const int bleed_intensity = u.get_effect_int( effect_bleed, bp );
const bool bleeding = bleed_intensity > 0;
const bool bitten = u.has_effect( effect_bite, bp.id() );
const bool infected = u.has_effect( effect_infected, bp.id() );
const bool broken = u.is_limb_broken( bp ) && bp->is_limb;
const bool splinted = u.worn_with_flag( json_flag_SPLINT, bp );
const bool bandaged = u.has_effect( effect_bandaged, bp.id() );
const bool disinfected = u.has_effect( effect_disinfected, bp.id() );

// Ailments
if( u.has_effect( effect_bite, bp ) ) {
ret[bodypart_status::BITEN] = c_yellow;
if( broken ) {
ret[bodypart_status::BROKEN] = c_magenta;
}
if( u.has_effect( effect_infected, bp ) ) {
ret[bodypart_status::INFECTED] = c_pink;
if( bitten ) {
ret[bodypart_status::BITEN] = c_yellow;
}
if( u.is_limb_broken( bp ) ) {
ret[bodypart_status::BROKEN] = c_magenta;
if( bleeding ) {
ret[bodypart_status::BLEEDING] = colorize_bleeding_intensity( bleed_intensity );
}
if( const int bleed = u.get_effect_int( effect_bleed, bp ) > 0 ) {
ret[bodypart_status::BLEEDING] = colorize_bleeding_intensity( bleed );
if( infected ) {
ret[bodypart_status::INFECTED] = c_pink;
}
// Treatments
if( u.worn_with_flag( json_flag_SPLINT, bp ) ) {
if( splinted ) {
ret[bodypart_status::SPLINTED] = c_light_gray;
}
if( u.has_effect( effect_bandaged, bp ) ) {
if( bandaged ) {
ret[bodypart_status::BANDAGED] = c_white;
}
if( u.has_effect( effect_disinfected, bp ) ) {
if( disinfected ) {
ret[bodypart_status::DISINFECTED] = c_light_green;
}

Expand Down

0 comments on commit 9e53ca0

Please sign in to comment.