summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-08-06 23:49:30 -0400
committerJesse Luehrs <doy@tozt.net>2014-08-07 00:05:14 -0400
commit5242a192e5a0ee025abbd3a9dea5eecd70b9af5a (patch)
treece68b13140d3d9fb73d3fdc4e856c8767d277c77
parent25d8ff14f39cfec20457fd3878cad716b07fe278 (diff)
downloadcrawl-ref-5242a192e5a0ee025abbd3a9dea5eecd70b9af5a.tar.gz
crawl-ref-5242a192e5a0ee025abbd3a9dea5eecd70b9af5a.zip
also set god and piety from dump
-rw-r--r--crawl-ref/source/wiz-you.cc92
1 files changed, 64 insertions, 28 deletions
diff --git a/crawl-ref/source/wiz-you.cc b/crawl-ref/source/wiz-you.cc
index a28ef23841..0f0b9b42ee 100644
--- a/crawl-ref/source/wiz-you.cc
+++ b/crawl-ref/source/wiz-you.cc
@@ -7,6 +7,9 @@
#include "wiz-you.h"
+#include <algorithm>
+#include <functional>
+
#include "abyss.h"
#include "chardump.h"
@@ -355,24 +358,8 @@ void wizard_set_hunger_state()
mpr("Ghouls can never be full or above!");
}
-void wizard_set_piety()
+static void _wizard_set_piety_to(int newpiety, bool force = false)
{
- if (you_worship(GOD_NO_GOD))
- {
- mpr("You are not religious!");
- return;
- }
-
- mprf(MSGCH_PROMPT, "Enter new piety value (current = %d, Enter for 0): ",
- you.piety);
- char buf[30];
- if (cancellable_get_line_autohist(buf, sizeof buf))
- {
- canned_msg(MSG_OK);
- return;
- }
-
- const int newpiety = atoi(buf);
if (newpiety < 0 || newpiety > MAX_PIETY)
{
mprf("Piety needs to be between 0 and %d.", MAX_PIETY);
@@ -383,16 +370,29 @@ void wizard_set_piety()
{
you.piety = newpiety;
- // For Xom, also allow setting interest.
- mprf(MSGCH_PROMPT, "Enter new interest (current = %d, Enter for 0): ",
- you.gift_timeout);
+ int newinterest;
+ if (!force)
+ {
+ char buf[30];
- if (cancellable_get_line_autohist(buf, sizeof buf))
+ // For Xom, also allow setting interest.
+ mprf(MSGCH_PROMPT,
+ "Enter new interest (current = %d, Enter for 0): ",
+ you.gift_timeout);
+
+ if (cancellable_get_line_autohist(buf, sizeof buf))
+ {
+ canned_msg(MSG_OK);
+ return;
+ }
+
+ newinterest = atoi(buf);
+ }
+ else
{
- canned_msg(MSG_OK);
- return;
+ newinterest = newpiety;
}
- const int newinterest = atoi(buf);
+
if (newinterest >= 0 && newinterest < 256)
you.gift_timeout = newinterest;
else
@@ -406,7 +406,7 @@ void wizard_set_piety()
return;
}
- if (newpiety < 1)
+ if (newpiety < 1 && !force)
{
if (yesno("Are you sure you want to be excommunicated?", false, 'n'))
{
@@ -425,6 +425,26 @@ void wizard_set_piety()
dec_penance(you.penance[you.religion]);
}
+void wizard_set_piety()
+{
+ if (you_worship(GOD_NO_GOD))
+ {
+ mpr("You are not religious!");
+ return;
+ }
+
+ mprf(MSGCH_PROMPT, "Enter new piety value (current = %d, Enter for 0): ",
+ you.piety);
+ char buf[30];
+ if (cancellable_get_line_autohist(buf, sizeof buf))
+ {
+ canned_msg(MSG_OK);
+ return;
+ }
+
+ _wizard_set_piety_to(atoi(buf));
+}
+
//---------------------------------------------------------------
//
// debug_add_skills
@@ -1058,9 +1078,10 @@ static bool _chardump_check_stats2(const vector<string> &tokens)
{
size_t size = tokens.size();
// MP 45/45 EV 13 Int 12 God: Makhleb [******]
- if (size <= 5 || tokens[0] != "MP")
+ if (size <= 8 || tokens[0] != "MP")
return false;
+ bool found = false;
for (size_t k = 1; k < size; k++)
{
if (tokens[k] == "Int")
@@ -1068,11 +1089,26 @@ static bool _chardump_check_stats2(const vector<string> &tokens)
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;
+ found = true;
+ }
+ else if (tokens[k] == "God:")
+ {
+ god_type god = find_earliest_match(lowercase_string(tokens[k+1]),
+ (god_type) 1, NUM_GODS,
+ _always_true<god_type>,
+ bind2nd(ptr_fun(god_name),
+ false));
+ join_religion(god, true);
+
+ string piety = tokens[k+2];
+ int piety_levels = std::count(piety.begin(), piety.end(), '*');
+ _wizard_set_piety_to(piety_levels > 0
+ ? piety_breakpoint(piety_levels - 1)
+ : 15);
}
}
- return false;
+ return found;
}
static bool _chardump_check_stats3(const vector<string> &tokens)