Town details suggest number of hostiles for thrash number

This commit is contained in:
2025-05-18 19:46:02 -05:00
parent f791848897
commit a77e009780
4 changed files with 14 additions and 0 deletions

View File

@@ -22,6 +22,9 @@
(When this many monsters are killed, the dungeon will be abandoned)
</text>
<field name='population' top='219' left='294' width='54' height='16'/>
<text name='population-hint' relative='pos neg' rel-anchor='prev' top='4' left='4' width='90'>
This town has {{num}} hostile creatures.
</text>
<text top='262' left='50' width='235' height='53'>
Town difficulty (0-10):

View File

@@ -177,6 +177,15 @@ bool cTown::cWandering::isNull() const {
return true;
}
size_t cTown::count_hostiles() const {
size_t count = 0;
static std::set<eAttitude> hostile_attitudes = { eAttitude::HOSTILE_A, eAttitude::HOSTILE_B };
for(const cTownperson& creature : creatures){
count += hostile_attitudes.count(creature.start_attitude);
}
return count;
}
bool cTown::is_cleaned_out() const {
if(max_num_monst < 0) return false;
return m_killed >= max_num_monst;

View File

@@ -84,6 +84,7 @@ public:
rectangle in_town_rect;
std::vector<cItem> preset_items;
std::vector<cTownperson> creatures;
size_t count_hostiles() const;
long max_num_monst;
std::vector<cField> preset_fields;
short spec_on_entry,spec_on_entry_if_dead;

View File

@@ -694,6 +694,7 @@ static void put_town_details_in_dlog(cDialog& me) {
me["chop"].setTextToNum(town->town_chop_time);
me["key"].setTextToNum(town->town_chop_key);
me["population"].setTextToNum(town->max_num_monst);
me["population-hint"].replaceText("{{num}}", std::to_string(town->count_hostiles()));
me["difficulty"].setTextToNum(town->difficulty);
cLedGroup& lighting = dynamic_cast<cLedGroup&>(me["lighting"]);
switch(town->lighting_type) {