00001
00002
00003
00004
00005
00006
00007
00008 #ifndef HISCORES_H
00009 #define HISCORES_H
00010
00011 class scorefile_entry;
00012
00013 void hiscores_new_entry(const scorefile_entry &se);
00014
00015 void logfile_new_entry(const scorefile_entry &se);
00016
00017 void hiscores_print_list(int display_count = -1, int format = SCORE_TERSE);
00018 void hiscores_print_all(int display_count = -1, int format = SCORE_TERSE);
00019
00020 std::string hiscores_format_single(const scorefile_entry &se);
00021 std::string hiscores_format_single_long(const scorefile_entry &se,
00022 bool verbose = false);
00023
00024 void mark_milestone(const std::string &type, const std::string &milestone,
00025 bool report_origin_level = false, time_t t = 0);
00026
00027 #ifdef DGL_WHEREIS
00028 std::string xlog_status_line();
00029 #endif
00030
00031 std::string xlog_unescape(const std::string &);
00032 std::string xlog_escape(const std::string &);
00033
00034 std::vector<std::string> xlog_split_fields(const std::string &s);
00035
00036 class xlog_fields
00037 {
00038 public:
00039 xlog_fields();
00040 xlog_fields(const std::string &line);
00041
00042 void init(const std::string &line);
00043 std::string xlog_line() const;
00044
00045 void add_field(const std::string &key,
00046 const char *format, ...);
00047
00048 std::string str_field(const std::string &) const;
00049 int int_field(const std::string &) const;
00050 long long_field(const std::string &) const;
00051
00052 private:
00053 void map_fields() const;
00054
00055 private:
00056 typedef std::vector< std::pair<std::string, std::string> > xl_fields;
00057 typedef std::map<std::string, std::string> xl_map;
00058
00059 xl_fields fields;
00060 mutable xl_map fieldmap;
00061 };
00062
00063 class scorefile_entry
00064 {
00065 private:
00066 std::string raw_line;
00067
00068 std::string version;
00069 int points;
00070 std::string name;
00071 species_type race;
00072 int job;
00073 std::string race_class_name;
00074 uint8_t lvl;
00075 skill_type best_skill;
00076 uint8_t best_skill_lvl;
00077 int death_type;
00078 int death_source;
00079 std::string death_source_name;
00080 std::string auxkilldata;
00081 std::string indirectkiller;
00082 std::string killerpath;
00083 uint8_t dlvl;
00084 short absdepth;
00085 level_area_type level_type;
00086 branch_type branch;
00087 std::string map;
00088 std::string mapdesc;
00089 int final_hp;
00090 int final_max_hp;
00091 int final_max_max_hp;
00092 int damage;
00093 int source_damage;
00094 int turn_damage;
00095 int str;
00096 int intel;
00097 int dex;
00098 god_type god;
00099 int piety;
00100 int penance;
00101 uint8_t wiz_mode;
00102 time_t birth_time;
00103 time_t death_time;
00104 time_t real_time;
00105 int num_turns;
00106 int num_diff_runes;
00107 int num_runes;
00108 int kills;
00109 std::string maxed_skills;
00110
00111 std::string status_effects;
00112 int gold;
00113 int gold_found;
00114 int gold_spent;
00115
00116 uint32_t fruit_found_mask;
00117
00118 mutable std::auto_ptr<xlog_fields> fields;
00119
00120 public:
00121 scorefile_entry();
00122 scorefile_entry(int damage, int death_source, int death_type,
00123 const char *aux, bool death_cause_only = false,
00124 const char *death_source_name = NULL,
00125 time_t death_time = 0);
00126 scorefile_entry(const scorefile_entry &se);
00127
00128 scorefile_entry &operator = (const scorefile_entry &other);
00129
00130 void init_death_cause(int damage, int death_source, int death_type,
00131 const char *aux, const char *death_source_name);
00132 void init(time_t death_time = 0);
00133 void reset();
00134
00135 enum death_desc_verbosity {
00136 DDV_TERSE,
00137 DDV_ONELINE,
00138 DDV_NORMAL,
00139 DDV_VERBOSE,
00140 DDV_LOGVERBOSE
00141 };
00142
00143 std::string raw_string() const;
00144 bool parse(const std::string &line);
00145
00146 std::string hiscore_line(death_desc_verbosity verbosity) const;
00147
00148 std::string character_description(death_desc_verbosity) const;
00149
00150 std::string death_description(death_desc_verbosity) const;
00151 std::string death_place(death_desc_verbosity) const;
00152 std::string game_time(death_desc_verbosity) const;
00153
00154 int get_score() const { return points; }
00155 int get_death_type() const { return death_type; }
00156 time_t get_death_time() const { return death_time; }
00157 xlog_fields get_fields() const;
00158
00159 void set_base_xlog_fields() const;
00160
00161 private:
00162 std::string single_cdesc() const;
00163 std::string strip_article_a(const std::string &s) const;
00164 std::string terse_missile_cause() const;
00165 std::string terse_missile_name() const;
00166 std::string terse_beam_cause() const;
00167 std::string terse_wild_magic() const;
00168 const char *damage_verb() const;
00169 std::string death_source_desc() const;
00170 std::string damage_string(bool terse = false) const;
00171
00172 bool parse_scoreline(const std::string &line);
00173
00174 void init_with_fields();
00175 void add_auxkill_field() const;
00176 void set_score_fields() const;
00177 void fixup_char_name();
00178
00179 std::string short_kill_message() const;
00180 std::string long_kill_message() const;
00181 std::string make_oneline(const std::string &s) const;
00182
00183 void init_from(const scorefile_entry &other);
00184 };
00185
00186 #endif // HISCORES_H