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

[WIP][CR] Adding vitamins and toxin levels monitor functions to Blood Analyser CBM #37582

Closed
20 changes: 18 additions & 2 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "ui.h"
#include "vehicle.h"
#include "vpart_position.h"
#include "vitamin.h"
#include "weather.h"
#include "weather_gen.h"
#include "calendar.h"
Expand Down Expand Up @@ -412,7 +413,8 @@ bool Character::activate_bionic( int b, bool eff_only )

std::vector<std::string> good;
std::vector<std::string> bad;

std::vector<std::string> vit;
;
eilaattwood marked this conversation as resolved.
Show resolved Hide resolved
if( get_rad() > 0 ) {
bad.push_back( _( "Irradiated" ) );
}
Expand All @@ -430,7 +432,16 @@ bool Character::activate_bionic( int b, bool eff_only )
}
}

const size_t win_h = std::min( static_cast<size_t>( TERMY ), bad.size() + good.size() + 2 );
const auto &vit_all = vitamin::all();
eilaattwood marked this conversation as resolved.
Show resolved Hide resolved
static const std::set<vitamin_id> trackable_vits = {vitamin_id( "iron" ), vitamin_id( "calcium" ), vitamin_id( "vitA" ), vitamin_id( "vitB" ), vitamin_id( "vitC" ), vitamin_id( "mutant_toxin" )};
eilaattwood marked this conversation as resolved.
Show resolved Hide resolved
for( const auto &v : vit_all ) {
if( trackable_vits.count( v.first ) ) {
vit.push_back( v.second.name() + _( " level is " ) + to_string( vitamin_get( v.first ) ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just printing the raw integer value here isn't helpful, because nobody knows what that means.
I'd suggest adding a vitamin::get_string_level() or something of the sort that gives you a string based on how much of the vitamin you have, and how close you are to each stage of either excess/deficiency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, that's why I asked for a comment how it should be finally represented. And what those numbers are really mean in reality.

}
}

const size_t win_h = std::min( static_cast<size_t>( TERMY ),
bad.size() + good.size() + vit.size() + 2 );
const int win_w = 46;
catacurses::window w = catacurses::newwin( win_h, win_w, point( ( TERMX - win_w ) / 2,
( TERMY - win_h ) / 2 ) );
Expand All @@ -447,6 +458,11 @@ bool Character::activate_bionic( int b, bool eff_only )
}
}
}
for( size_t line = good.size() + bad.size() + 1; line < ( win_h - 1 ) &&
line <= good.size() + bad.size() + vit.size(); ++line ) {
trim_and_print( w, point( 2, line ), win_w - 3, c_yellow,
vit[line - 1 - bad.size() - good.size()] );
}
wrefresh( w );
catacurses::refresh();
inp_mngr.wait_for_any_key();
Expand Down