Skip to content

Commit

Permalink
adjust mana panel code (#32168)
Browse files Browse the repository at this point in the history
mana panel now only shows up if the players knows any spell.
  • Loading branch information
ZhilkinSerg authored Jul 6, 2019
2 parents 69aa8e1 + 9c8ba98 commit a44b11a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,11 @@ bool known_magic::knows_spell( const spell_id &sp ) const
return spellbook.count( sp ) == 1;
}

bool known_magic::knows_spell() const
{
return !spellbook.empty();
}

void known_magic::learn_spell( const std::string &sp, player &p, bool force )
{
learn_spell( spell_id( sp ), p, force );
Expand Down
2 changes: 2 additions & 0 deletions src/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ class known_magic
bool can_learn_spell( const player &p, const spell_id &sp ) const;
bool knows_spell( const std::string &sp ) const;
bool knows_spell( const spell_id &sp ) const;
// does the player know a spell?
bool knows_spell() const;
// spells known by player
std::vector<spell_id> spells() const;
// gets the spell associated with the spell_id to be edited
Expand Down
2 changes: 1 addition & 1 deletion src/panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ static void draw_mana( const player &u, const catacurses::window &w )

static bool spell_panel()
{
return !spell_type::get_all().empty();
return g->u.magic.knows_spell();
}

bool default_render()
Expand Down

0 comments on commit a44b11a

Please sign in to comment.