1 /** 2 * @file 3 * @brief Notetaking stuff 4 **/ 5 6 #pragma once 7 8 #include <string> 9 #include <vector> 10 #include <cstdio> 11 12 #include "player.h" 13 #include "tag-version.h" 14 15 #define MAX_NOTE_PLACE_LEN 8 16 17 class reader; 18 class writer; 19 20 enum NOTE_TYPES 21 { 22 NOTE_HP_CHANGE = 0, /* needs: new hp, max hp */ 23 NOTE_MAXHP_CHANGE, /* needs: new maxhp */ 24 NOTE_MP_CHANGE, /* needs: new mp, max mp */ 25 NOTE_MAXMP_CHANGE, /* needs: new maxmp */ 26 NOTE_XP_LEVEL_CHANGE, /* needs: new xplevel */ 27 NOTE_DUNGEON_LEVEL_CHANGE, /* needs: branch, subdepth */ 28 NOTE_LEARN_SPELL, /* needs: spell idx */ 29 NOTE_GET_GOD, /* needs: god id */ 30 NOTE_GOD_GIFT, /* needs: god id */ 31 NOTE_PIETY_RANK, /* needs: god id, rank */ 32 NOTE_GET_MUTATION, /* needs: mutation idx, reason (string) */ 33 NOTE_LOSE_MUTATION, /* needs: mutation idx, reason (string) */ 34 NOTE_ID_ITEM, /* needs: item name (string) */ 35 NOTE_GET_ITEM, /* needs: item name (string) */ 36 NOTE_GAIN_SKILL, /* needs: skill id, level */ 37 NOTE_LOSE_SKILL, /* needs: skill id, level */ 38 NOTE_SEEN_MONSTER, /* needs: monster name (string) */ 39 NOTE_DEFEAT_MONSTER, /* needs: monster name, defeat verb (strings) */ 40 NOTE_POLY_MONSTER, /* needs: monster name (string) */ 41 NOTE_USER_NOTE, /* needs: description string */ 42 NOTE_MESSAGE, /* needs: message string */ 43 NOTE_LOSE_GOD, /* needs: god id */ 44 NOTE_PENANCE, /* needs: god id */ 45 NOTE_MOLLIFY_GOD, /* needs: god id */ 46 NOTE_DEATH, /* needs: death cause */ 47 NOTE_BUY_ITEM, /* needs: item name (string), price (int) */ 48 NOTE_DONATE_MONEY, /* needs: amount of gold */ 49 NOTE_SEEN_FEAT, /* needs: feature seen (string) */ 50 NOTE_XOM_EFFECT, /* needs: description (name string) */ 51 NOTE_XOM_REVIVAL, /* needs: death cause (string) */ 52 NOTE_PARALYSIS, /* needs: paralysis source (string) */ 53 NOTE_NAMED_ALLY, /* needs: ally name (string) */ 54 NOTE_ALLY_DEATH, /* needs: ally name (string) */ 55 NOTE_FEAT_MIMIC, /* needs: mimiced feature (string) */ 56 NOTE_OFFERED_SPELL, /* needs: spell idx */ 57 NOTE_PERM_MUTATION, /* needs: mutation idx, reason (string) */ 58 NOTE_ANCESTOR_TYPE, /* needs: ancestor class (string) */ 59 #if TAG_MAJOR_VERSION == 34 60 NOTE_ANCESTOR_DEATH, /* needs: ancestor death (string) */ 61 NOTE_ANCESTOR_SPECIALIZATION, /* needs: ancestor specialization (string) */ 62 #endif 63 NOTE_FOUND_UNRAND, /* needs: item name (string) */ 64 NOTE_ACQUIRE_ITEM, 65 NOTE_NUM_TYPES 66 }; 67 68 struct Note 69 { NoteNote70 Note() {} 71 Note(NOTE_TYPES t, int f = 0, int s = 0, const string& n = "", 72 const string& d = "", 73 const string& sc = "") : typeNote74 type(t), first(f), second(s), name(n), desc(d), screen(sc) {} 75 void save(writer& outf) const; 76 void load(reader& inf); 77 string describe(bool when = true, bool where = true, bool what = true) const; 78 bool hidden() const; 79 void check_milestone() const; 80 81 NOTE_TYPES type; 82 int first, second; 83 int turn = you.num_turns; 84 level_id place = level_id::current(); 85 86 string name; 87 string desc; 88 string screen; 89 }; 90 91 extern vector<Note> note_list; 92 void activate_notes(bool active); 93 bool notes_are_active(); 94 void take_note(const Note& note, bool force = false); 95 void save_notes(writer&); 96 void load_notes(reader&); 97 void make_user_note(); 98 99 /** 100 * Disable notes in a dynamic scope. Restores the original note status when 101 * the object goes out of scope or is otherwise destroyed. 102 */ 103 struct no_notes 104 { no_notesno_notes105 no_notes() : saved(notes_are_active()) 106 { 107 activate_notes(false); 108 } ~no_notesno_notes109 ~no_notes() 110 { 111 activate_notes(saved); 112 } 113 bool saved; 114 }; 115