Apply the new ground_level method.
[crawl.git] / crawl-ref / source / tutorial.cc
blobed894c01e4ffbe1e1807eaab32722294c4c72988
1 /*
2 * File: tutorial.cc
3 * Summary: Collection of tutorial related functions.
4 */
6 #include "AppHdr.h"
7 #include "tutorial.h"
9 #include "externs.h"
10 #include "hints.h"
11 #include "maps.h"
12 #include "message.h"
13 #include "mpr.h"
14 #include "player.h"
15 #include "skills.h"
16 #include "state.h"
18 mapref_vector get_tutorial_maps()
20 return find_maps_for_tag("tutorial_start");
23 // We could save this in crawl_state instead.
24 // Or choose_game() could save *ng to crawl_state
25 // entirely, though that'd be redundant with
26 // you.your_name, you.species, crawl_state.type, ...
28 static std::string _tutorial_map;
30 std::string get_tutorial_map()
32 return _tutorial_map;
35 void set_tutorial_map(const std::string& map)
37 _tutorial_map = map;
40 void set_tutorial_hunger(int hunger)
42 if (!crawl_state.game_is_tutorial())
43 return;
45 you.hunger = hunger;
48 void set_tutorial_skill(const char *skill, int level)
50 if (!crawl_state.game_is_tutorial())
51 return;
53 bool need_exercise_check = true;
54 if (strcmp(skill, "spellcasting") == 0)
55 you.skills[SK_SPELLCASTING] = level;
56 else if (strcmp(skill, "conjurations") == 0)
57 you.skills[SK_CONJURATIONS] = level;
58 else if (strcmp(skill, "invocations") == 0)
59 you.skills[SK_INVOCATIONS] = level;
60 else
61 need_exercise_check = false;
63 if (need_exercise_check)
64 reassess_starting_skills();
67 // FIXME: There's got to be a less hacky solution!
68 void tutorial_init_hint(const char* hintstr)
70 hints_event_type hint = HINT_EVENTS_NUM;
71 if (strcmp(hintstr, "HINT_NEW_LEVEL") == 0)
72 hint = HINT_NEW_LEVEL;
73 else if (strcmp(hintstr, "HINT_CHOOSE_STAT") == 0)
74 hint = HINT_CHOOSE_STAT;
75 else if (strcmp(hintstr, "HINT_YOU_CURSED") == 0)
76 hint = HINT_YOU_CURSED;
77 else if (strcmp(hintstr, "HINT_REMOVED_CURSE") == 0)
78 hint = HINT_REMOVED_CURSE;
79 else if (strcmp(hintstr, "HINT_MULTI_PICKUP") == 0)
80 hint = HINT_MULTI_PICKUP;
82 if (hint != HINT_EVENTS_NUM)
83 Hints.hints_events[hint] = true;
86 void tutorial_death_message()
88 mprnojoin("You die...");
89 mprnojoin("In Crawl, death is a sad but common occurence. "
90 "Note that there's usually something you could have done to "
91 "survive, for example by using some kind of item, running away, "
92 "resting between fights, or by avoiding combat entirely. "
93 "Keep trying, eventually you'll prevail!",
94 MSGCH_TUTORIAL);
95 more();