Skip to content

Commit

Permalink
fix: further issues with non-casting monster descriptions
Browse files Browse the repository at this point in the history
df0a5da didn't get this case right
  • Loading branch information
rawlins committed Feb 2, 2022
1 parent 139f01a commit 3f3a666
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 12 additions & 10 deletions crawl-ref/source/describe.cc
Expand Up @@ -4335,13 +4335,21 @@ static string _monster_missiles_description(const monster_info& mi)
return desc;
}

static string _monster_spells_description(const monster_info& mi)
#define SPELL_LIST_BEGIN "[SPELL_LIST_BEGIN]"
#define SPELL_LIST_END "[SPELL_LIST_END]"

static string _monster_spells_description(const monster_info& mi, bool mark_spells)
{
// Show monster spells and spell-like abilities.
if (!mi.has_spells())
return "";

formatted_string description;

// hacky, refactor so this isn't necessary
if (mark_spells)
description += SPELL_LIST_BEGIN;

describe_spellset(monster_spellset(mi), nullptr, description, &mi);
description.cprintf("\nTo read a description, press the key listed above. "
"(AdB) indicates damage (the sum of A B-sided dice), "
Expand All @@ -4350,6 +4358,8 @@ static string _monster_spells_description(const monster_info& mi)
description.cprintf(crawl_state.need_save
? "; shown in red if you are in range.\n"
: ".\n");
if (mark_spells)
description += SPELL_LIST_END;

return description.to_colour_string();
}
Expand Down Expand Up @@ -4690,9 +4700,6 @@ static string _monster_current_target_description(const monster_info &mi)
return result.str();
}

#define SPELL_LIST_BEGIN "[SPELL_LIST_BEGIN]"
#define SPELL_LIST_END "[SPELL_LIST_END]"

// Describe a monster's (intrinsic) resistances, speed and a few other
// attributes.
static string _monster_stat_description(const monster_info& mi, bool mark_spells)
Expand Down Expand Up @@ -5015,12 +5022,7 @@ static string _monster_stat_description(const monster_info& mi, bool mark_spells
result << _monster_attacks_description(mi);
result << _monster_missiles_description(mi);
result << _monster_habitat_description(mi);
// hacky, refactor so this isn't necessary
if (mark_spells)
result << SPELL_LIST_BEGIN;
result << _monster_spells_description(mi);
if (mark_spells)
result << SPELL_LIST_END;
result << _monster_spells_description(mi, mark_spells);

return result.str();
}
Expand Down
4 changes: 3 additions & 1 deletion crawl-ref/source/webserver/game_data/static/ui-layouts.js
Expand Up @@ -39,7 +39,9 @@ function ($, comm, client, ui, enums, cr, util, scroller, main, gui, player) {
function _fmt_spells_list(root, spellset, colour)
{
var $container = root.find("#spellset_placeholder");
if ($container.length == 0)
// XX this container only seems to be added if there are spells, do
// we actually need to remove it again?
if ($container.length === 0 && spellset.length !== 0)
{
root.prepend("<div class='fg4'>Buggy spellset!</div>");
return;
Expand Down

0 comments on commit 3f3a666

Please sign in to comment.