end item target mode when all items are identified

This commit is contained in:
2024-12-27 13:51:06 -06:00
committed by Celtic Minstrel
parent b174dd3fb5
commit 79bf21cb7d
3 changed files with 16 additions and 6 deletions

View File

@@ -1006,7 +1006,11 @@ void handle_item_shop_action(short item_hit) {
target.ident = true;
shopper.combine_things();
if(overall_mode == MODE_ITEM_TARGET) {
// TODO: End if there are no unidentified items left
if(all_items_identified()){
overall_mode = MODE_TOWN;
stat_screen_mode = MODE_INVEN;
ASB("Identify: All of your items are identified.");
}
}
}
break;

View File

@@ -579,11 +579,7 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) {
break;
case eSpell::IDENTIFY:{
bool all_identified = true;
for(cPlayer& pc : univ.party)
for(cItem& item : pc.items)
if (item.variety != eItemType::NO_ITEM)
all_identified = all_identified && item.ident;
bool all_identified = all_items_identified();
// Cancel without spending points if there are no unidentified items
if(!(freebie || all_identified))
@@ -2633,3 +2629,12 @@ short party_size(bool only_living) {
return num_pcs;
}
bool all_items_identified() {
bool all_identified = true;
for(cPlayer& pc : univ.party)
for(cItem& item : pc.items)
if (item.variety != eItemType::NO_ITEM)
all_identified &= item.ident;
return all_identified;
}

View File

@@ -48,6 +48,7 @@ short wilderness_lore_present(ter_num_t ter);
void print_spell_cast(eSpell spell,eSkill which);
void put_party_in_scen(std::string scen_name);
short party_size(bool only_living);
bool all_items_identified();
// This is defined in pc.editors.cpp since it is also used by the character editor
bool spend_xp(short pc_num, short mode, cDialog* parent);