summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-08-06 22:21:17 -0400
committerJesse Luehrs <doy@tozt.net>2014-08-07 00:05:14 -0400
commit2c0e24d1afde8600f91803c555afa8b4a37efa00 (patch)
tree9326b7f066c412992127b2f76f721496d87baeb1
parent86f53c52ac119e0880163a82c18f660a230f31cb (diff)
downloadcrawl-ref-2c0e24d1afde8600f91803c555afa8b4a37efa00.tar.gz
crawl-ref-2c0e24d1afde8600f91803c555afa8b4a37efa00.zip
refactor dumpfile loading
-rw-r--r--crawl-ref/source/wiz-you.cc126
1 files changed, 79 insertions, 47 deletions
diff --git a/crawl-ref/source/wiz-you.cc b/crawl-ref/source/wiz-you.cc
index 92ac5dfc0a..cc78dba0ce 100644
--- a/crawl-ref/source/wiz-you.cc
+++ b/crawl-ref/source/wiz-you.cc
@@ -1005,71 +1005,103 @@ void wizard_transform()
mpr("Transformation failed.");
}
-static void _wizard_modify_character(string inputdata)
-// for now this just sets skill levels and str dex int
-// (this should be enough to debug with)
+static bool _chardump_check_skill(const vector<string> &tokens)
{
- vector<string> tokens = split_string(" ", inputdata);
- int size = tokens.size();
- if (size > 3 && tokens[1] == "Level") // + Level 4.0 Fighting
- {
- skill_type skill = skill_from_name(lowercase_string(tokens[3]).c_str());
- double amount = atof(tokens[2].c_str());
- set_skill_level(skill, amount);
- if (tokens[0] == "+")
- you.train[skill] = 1;
- else if (tokens[0] == "*")
- you.train[skill] = 2;
- else
- you.train[skill] = 0;
+ size_t size = tokens.size();
+ // * Level 25.0(24.4) Dodging
+ if (size <= 3 || tokens[1] != "Level")
+ return false;
- redraw_skill(skill);
+ skill_type skill = skill_from_name(lowercase_string(tokens[3]).c_str());
+ double amount = atof(tokens[2].c_str());
+ set_skill_level(skill, amount);
+ if (tokens[0] == "+")
+ you.train[skill] = 1;
+ else if (tokens[0] == "*")
+ you.train[skill] = 2;
+ else
+ you.train[skill] = 0;
- return;
- }
+ redraw_skill(skill);
- if (size > 5 && tokens[0] == "HP") // HP 23/23 AC 3 Str 21 XL: 1 Next: 0%
+ return true;
+}
+
+static bool _chardump_check_str(const vector<string> &tokens)
+{
+ size_t size = tokens.size();
+ // HP 121/199 AC 75 Str 35 XL: 27
+ if (size <= 5 || tokens[0] != "HP")
+ return false;
+
+ for (size_t k = 1; k < size; k++)
{
- for (int k = 1; k < size; k++)
+ if (tokens[k] == "Str")
{
- if (tokens[k] == "Str")
- {
- you.base_stats[STAT_STR] = debug_cap_stat(atoi(tokens[k+1].c_str()));
- you.redraw_stats.init(true);
- you.redraw_evasion = true;
- return;
- }
+ you.base_stats[STAT_STR] = debug_cap_stat(atoi(tokens[k+1].c_str()));
+ you.redraw_stats.init(true);
+ you.redraw_evasion = true;
+ return true;
}
}
- if (size > 5 && tokens[0] == "MP")
+ return false;
+}
+
+static bool _chardump_check_int(const vector<string> &tokens)
+{
+ size_t size = tokens.size();
+ // MP 45/45 EV 13 Int 12 God: Makhleb [******]
+ if (size <= 5 || tokens[0] != "MP")
+ return false;
+
+ for (size_t k = 1; k < size; k++)
{
- for (int k = 1; k < size; k++)
+ if (tokens[k] == "Int")
{
- if (tokens[k] == "Int")
- {
- you.base_stats[STAT_INT] = debug_cap_stat(atoi(tokens[k+1].c_str()));
- you.redraw_stats.init(true);
- you.redraw_evasion = true;
- return;
- }
+ you.base_stats[STAT_INT] = debug_cap_stat(atoi(tokens[k+1].c_str()));
+ you.redraw_stats.init(true);
+ you.redraw_evasion = true;
+ return true;
}
}
- if (size > 5 && tokens[0] == "Gold")
+
+ return false;
+}
+
+static bool _chardump_check_dex(const vector<string> &tokens)
+{
+ size_t size = tokens.size();
+ // Gold 15872 SH 59 Dex 9 Spells: 0 memorised, 26 levels left
+ if (size <= 5 || tokens[0] != "Gold")
+ return false;
+
+ for (size_t k = 1; k < size; k++)
{
- for (int k = 1; k < size; k++)
+ if (tokens[k] == "Dex")
{
- if (tokens[k] == "Dex")
- {
- you.base_stats[STAT_DEX] = debug_cap_stat(atoi(tokens[k+1].c_str()));
- you.redraw_stats.init(true);
- you.redraw_evasion = true;
- return;
- }
+ you.base_stats[STAT_DEX] = debug_cap_stat(atoi(tokens[k+1].c_str()));
+ you.redraw_stats.init(true);
+ you.redraw_evasion = true;
+ return true;
}
}
- return;
+ return false;
+}
+
+static void _wizard_modify_character(string inputdata)
+{
+ vector<string> tokens = split_string(" ", inputdata);
+
+ if (_chardump_check_skill(tokens))
+ return;
+ if (_chardump_check_str(tokens))
+ return;
+ if (_chardump_check_int(tokens))
+ return;
+ if (_chardump_check_dex(tokens))
+ return;
}
/**