summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-12-04 09:14:26 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-12-04 09:18:30 +0100
commit24fa1749d2dc82f57d5ce04655f8d934ea767d14 (patch)
tree053b2b82d4ef3c7bfdafd61164d6b519077ebc4e
parent83a78c65abdbfa995225122be56548a75d46f0ff (diff)
downloadcrawl-ref-24fa1749d2dc82f57d5ce04655f8d934ea767d14.tar.gz
crawl-ref-24fa1749d2dc82f57d5ce04655f8d934ea767d14.zip
De-duplicate magic res and stealth adjective choice.
-rw-r--r--crawl-ref/source/describe.cc13
-rw-r--r--crawl-ref/source/output.cc64
-rw-r--r--crawl-ref/source/output.h2
-rw-r--r--crawl-ref/source/player.cc30
4 files changed, 42 insertions, 67 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index b4ef97cf18..e77ff17982 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -33,13 +33,14 @@
#include "itemname.h"
#include "itemprop.h"
#include "items.h"
+#include "jobs.h"
#include "macro.h"
#include "menu.h"
#include "message.h"
#include "mon-stuff.h"
#include "mon-util.h"
#include "newgame.h"
-#include "jobs.h"
+#include "output.h"
#include "player.h"
#include "random.h"
#include "religion.h"
@@ -2738,15 +2739,7 @@ static std::string _monster_stat_description(const monsters& mon)
if (mr >= 10)
{
result << pronoun << make_stringf(" is %s resistant to magic.$",
- (mr < 30) ? "slightly" :
- (mr < 60) ? "somewhat" :
- (mr < 90) ? "quite" :
- (mr < 120) ? "very" :
- (mr < 150) ? "extremely" :
- (mr < 190) ? "extraordinarily" :
- (mr < 240) ? "incredibly" :
- (mr < 300) ? "uncannily"
- : "almost entirely");
+ magic_res_adjective(mr).c_str());
}
}
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 6b02f7d1e1..6513cc0b17 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -2033,6 +2033,37 @@ std::string _get_expiration_string(duration_type dur, const char* msg)
return (help);
}
+std::string stealth_desc(int stealth)
+{
+ std::string prefix =
+ (stealth < 10) ? "extremely un" :
+ (stealth < 30) ? "very un" :
+ (stealth < 60) ? "un" :
+ (stealth < 90) ? "fairly " :
+ (stealth < 120) ? "" :
+ (stealth < 160) ? "quite " :
+ (stealth < 220) ? "very " :
+ (stealth < 300) ? "extremely " :
+ (stealth < 400) ? "extraordinarily " :
+ (stealth < 520) ? "incredibly "
+ : "uncannily ";
+ return (prefix + "stealthy");
+}
+
+std::string magic_res_adjective(int mr)
+{
+ return ((mr < 10) ? "not" :
+ (mr < 30) ? "slightly" :
+ (mr < 60) ? "somewhat" :
+ (mr < 90) ? "quite" :
+ (mr < 120) ? "very" :
+ (mr < 150) ? "extremely" :
+ (mr < 190) ? "extraordinarily" :
+ (mr < 240) ? "incredibly" :
+ (mr < 300) ? "uncannily"
+ : "almost entirely");
+}
+
// Creates rows of short descriptions for current
// status, mutations and abilities.
std::string _status_mut_abilities()
@@ -2280,38 +2311,11 @@ std::string _status_mut_abilities()
if (you.attribute[ATTR_HELD])
status.push_back("held");
- const int mr = you.res_magic();
- snprintf(info, INFO_SIZE, "%s resistant to magic",
- (mr < 10) ? "not" :
- (mr < 30) ? "slightly" :
- (mr < 60) ? "somewhat" :
- (mr < 90) ? "quite" :
- (mr < 120) ? "very" :
- (mr < 150) ? "extremely" :
- (mr < 190) ? "extraordinarily" :
- (mr < 240) ? "incredibly" :
- (mr < 300) ? "uncannily"
- : "almost entirely");
-
- status.push_back(info);
+ status.push_back(magic_res_adjective(you.res_magic())
+ + " resistant to magic");
// character evaluates their ability to sneak around:
- const int ustealth = check_stealth();
-
- snprintf( info, INFO_SIZE, "%sstealthy",
- (ustealth < 10) ? "extremely un" :
- (ustealth < 30) ? "very un" :
- (ustealth < 60) ? "un" :
- (ustealth < 90) ? "fairly " :
- (ustealth < 120) ? "" :
- (ustealth < 160) ? "quite " :
- (ustealth < 220) ? "very " :
- (ustealth < 300) ? "extremely " :
- (ustealth < 400) ? "extraordinarily " :
- (ustealth < 520) ? "incredibly "
- : "uncannily ");
-
- status.push_back(info);
+ status.push_back(stealth_desc(check_stealth()));
text += comma_separated_line(status.begin(), status.end(), ", ", ", ");
diff --git a/crawl-ref/source/output.h b/crawl-ref/source/output.h
index d06e6fe18c..238754d737 100644
--- a/crawl-ref/source/output.h
+++ b/crawl-ref/source/output.h
@@ -59,5 +59,7 @@ void print_overview_screen(void);
std::string dump_overview_screen(bool full_id);
+std::string magic_res_adjective(int mr);
+std::string stealth_desc(int stealth);
#endif
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index e69dc3c94d..3f43ea3bdd 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -3792,36 +3792,12 @@ void display_char_status()
// magic resistance
const int mr = you.res_magic();
- mprf("You are %s resistant to magic.",
- (mr < 10) ? "not" :
- (mr < 30) ? "slightly" :
- (mr < 60) ? "somewhat" :
- (mr < 90) ? "quite" :
- (mr < 120) ? "very" :
- (mr < 150) ? "extremely" :
- (mr < 190) ? "extraordinarily" :
- (mr < 240) ? "incredibly" :
- (mr < 300) ? "uncannily"
- : "almost entirely");
+ mprf("You are %s resistant to magic.", magic_res_adjective(mr).c_str());
// character evaluates their ability to sneak around:
- const int ustealth = check_stealth();
-
- mprf("You feel %sstealthy.",
- (ustealth < 10) ? "extremely un" :
- (ustealth < 30) ? "very un" :
- (ustealth < 60) ? "un" :
- (ustealth < 90) ? "fairly " :
- (ustealth < 120) ? "" :
- (ustealth < 160) ? "quite " :
- (ustealth < 220) ? "very " :
- (ustealth < 300) ? "extremely " :
- (ustealth < 400) ? "extraordinarily " :
- (ustealth < 520) ? "incredibly "
- : "uncannily ");
-
+ mprf("You feel %s.", stealth_desc(check_stealth()).c_str());
#if DEBUG_DIAGNOSTICS
- mprf("stealth: %d", ustealth);
+ mprf("stealth: %d", check_stealth());
#endif
}