Skip to content

Commit

Permalink
feat(UI): always show book's skill cap even if the PC has passed it (#…
Browse files Browse the repository at this point in the history
…5791)

* Adjusted item::book_info() so that it shows a book's skill cap even if you've already surpassed it.

* refactor: remove unused `space`

* feat: show whether the skill can be trained

* refactor: don't mutate string

---------

Co-authored-by: scarf <[email protected]>
  • Loading branch information
karxi and scarf005 authored Dec 5, 2024
1 parent e5f4696 commit 8bdd237
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2235,7 +2235,6 @@ auto nname( const itype_id &id ) -> std::string
void item::gun_info( const item *mod, std::vector<iteminfo> &info, const iteminfo_query *parts,
int /* batch */, bool /* debug */ ) const
{
const std::string space = " ";
const islot_gun &gun = *mod->type->gun;
const Skill &skill = *mod->gun_skill();
avatar &viewer = get_avatar();
Expand Down Expand Up @@ -3023,14 +3022,15 @@ void item::book_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
}
if( book.skill ) {
const SkillLevel &skill = you.get_skill_level_object( book.skill );
if( skill.can_train() && parts->test( iteminfo_parts::BOOK_SKILLRANGE_MAX ) ) {
if( parts->test( iteminfo_parts::BOOK_SKILLRANGE_MAX ) ) {
const std::string skill_name = book.skill->name();
std::string fmt = string_format( _( "Can bring your <info>%s skill to</info> "
"<num>." ), skill_name );
info.emplace_back( "BOOK", "", fmt, iteminfo::no_flags, book.level );
fmt = string_format( _( "Your current <stat>%s skill</stat> is <num>." ),
skill_name );
info.emplace_back( "BOOK", "", fmt, iteminfo::no_flags, skill.level() );
const std::string fmt = string_format( _( "Can bring <info>%s skill to</info> "
"<num>." ), skill_name );
info.emplace_back( "BOOK", "", skill.can_train() ? fmt : colorize( fmt, c_brown ),
iteminfo::no_flags, book.level );
info.emplace_back( "BOOK", "",
string_format( _( "Your current <stat>%s skill</stat> is <num>." ), skill_name ),
iteminfo::no_flags, skill.level() );
}

if( book.req != 0 && parts->test( iteminfo_parts::BOOK_SKILLRANGE_MIN ) ) {
Expand Down

0 comments on commit 8bdd237

Please sign in to comment.