From 54a8ee37c5d6bee4ed77eef17bad080c0f81b175 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Sat, 29 Nov 2008 06:09:05 +0000 Subject: Changed player attribute type from unsigned char to unsigned long. Breaks savefile compatibility. Keep track of how much gold the player has collected, spent at shops, donated, and otherwise used (like at ziggurats) and include that info in the misc section of the character dump file. Place-holder for chaos spawn monster. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7683 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/chardump.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'crawl-ref/source/chardump.cc') diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index c02ecac128..155168a3db 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -65,6 +65,7 @@ static void _sdump_burden(dump_params &); static void _sdump_hunger(dump_params &); static void _sdump_transform(dump_params &); static void _sdump_visits(dump_params &); +static void _sdump_gold(dump_params &); static void _sdump_misc(dump_params &); static void _sdump_turns_by_place(dump_params &); static void _sdump_notes(dump_params &); @@ -118,6 +119,7 @@ static dump_section_handler dump_handlers[] = { { "hunger", _sdump_hunger }, { "transform", _sdump_transform }, { "visits", _sdump_visits }, + { "gold", _sdump_gold }, { "misc", _sdump_misc }, { "turns_by_place", _sdump_turns_by_place}, { "notes", _sdump_notes }, @@ -329,6 +331,49 @@ static void _sdump_visits(dump_params &par) text += "\n"; } +static void _sdump_gold(dump_params &par) +{ + std::string &text(par.text); + + int lines = 0; + + const char* have = "have "; + if (par.se) // you died -> past tense + have = ""; + + if (you.attribute[ATTR_GOLD_FOUND] > 0) + { + lines++; + text += make_stringf("You %scollected %d gold pieces.\n", have, + you.attribute[ATTR_GOLD_FOUND]); + } + + if (you.attribute[ATTR_PURCHASES] > 0) + { + lines++; + text += make_stringf("You %sspent %d gold pieces at shops.\n", have, + you.attribute[ATTR_PURCHASES]); + } + + if (you.attribute[ATTR_DONATIONS] > 0) + { + lines++; + text += make_stringf("You %sdonated %d gold pices.\n", have, + you.attribute[ATTR_DONATIONS]); + } + + if (you.attribute[ATTR_MISC_SPENDING] > 0) + { + lines++; + text += make_stringf("You %sused %d gold pieces for miscellaneous " + "purposes.\n", have, + you.attribute[ATTR_MISC_SPENDING]); + } + + if (lines > 0) + text += "\n"; +} + static void _sdump_misc(dump_params &par) { _sdump_location(par); @@ -337,6 +382,7 @@ static void _sdump_misc(dump_params &par) _sdump_hunger(par); _sdump_transform(par); _sdump_visits(par); + _sdump_gold(par); } #define TO_PERCENT(x, y) (100.0f * ((float) (x)) / ((float) (y))) -- cgit v1.2.3-54-g00ecf