1 /** 2 * @file 3 * @brief Place related functions. 4 **/ 5 6 #include "AppHdr.h" 7 8 #include "place.h" 9 10 #include "branch.h" 11 #include "libutil.h" 12 #include "player.h" 13 14 // Prepositional form of branch level name. For example, "in the 15 // Vestibule of Hell" or "on level 3 of the Dungeon". prep_branch_level_name(level_id id)16string prep_branch_level_name(level_id id) 17 { 18 string place = id.describe(true, true); 19 if (!place.empty() && place != "Pandemonium") 20 place[0] = tolower_safe(place[0]); 21 return place.find("level") == 0 ? "on " + place 22 : "in " + place; 23 } 24 single_level_branch(branch_type branch)25bool single_level_branch(branch_type branch) 26 { 27 return branch >= 0 && branch < NUM_BRANCHES 28 && brdepth[branch] == 1; 29 } 30 absdungeon_depth(branch_type branch,int subdepth)31int absdungeon_depth(branch_type branch, int subdepth) 32 { 33 return branches[branch].absdepth + subdepth - 1; 34 } 35 branch_allows_followers(branch_type branch)36bool branch_allows_followers(branch_type branch) 37 { 38 return is_connected_branch(branch) || branch == BRANCH_PANDEMONIUM; 39 } 40 all_dungeon_ids()41vector<level_id> all_dungeon_ids() 42 { 43 vector<level_id> out; 44 for (branch_iterator it; it; ++it) 45 { 46 for (int depth = 1; depth <= brdepth[it->id]; depth++) 47 out.emplace_back(it->id, depth); 48 } 49 return out; 50 } 51 is_level_on_stack(level_id lev)52bool is_level_on_stack(level_id lev) 53 { 54 for (int i = you.level_stack.size() - 1; i >= 0; i--) 55 if (you.level_stack[i].id == lev) 56 return true; 57 58 return false; 59 } 60