summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/describe.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-05 01:11:57 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-05 01:11:57 +0000
commit922342473b6af1fcf53bd1173b4e85627518479d (patch)
tree8ba5e902b0b9d386bf759281e02b3842b7e2578c /crawl-ref/source/describe.cc
parentcdab703a671fabd21a015d23a5dc8a3ed5e10b36 (diff)
downloadcrawl-ref-922342473b6af1fcf53bd1173b4e85627518479d.tar.gz
crawl-ref-922342473b6af1fcf53bd1173b4e85627518479d.zip
Randarts can now be autoinscribed from the 'v' screen.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2998 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r--crawl-ref/source/describe.cc112
1 files changed, 105 insertions, 7 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index ce0448e2cb..d0eb4c543c 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -152,9 +152,88 @@ void print_description( const std::string &d )
}
}
+#define known_proprt(prop) (proprt[(prop)] && known[(prop)])
+
+struct property_descriptors
+{
+ const char* name;
+ randart_prop_type prop;
+ int spell_out; // 0: "+3", 1: "+++", 2: value doesn't matter
+};
+
+static std::string randart_auto_inscription( const item_def& item )
+{
+ randart_properties_t proprt;
+ randart_known_props_t known;
+ randart_desc_properties( item, proprt, known );
+
+ std::vector<std::string> propnames;
+
+ const property_descriptors propdescs[] = {
+ { "AC", RAP_AC, 0 },
+ { "EV", RAP_EVASION, 0 },
+ { "Str", RAP_STRENGTH, 0 },
+ { "Dex", RAP_DEXTERITY, 0 },
+ { "Int", RAP_INTELLIGENCE, 0 },
+ { "Acc", RAP_ACCURACY, 0 },
+ { "Dam", RAP_DAMAGE, 0 },
+ { "RF", RAP_FIRE, 1 },
+ { "RC", RAP_COLD, 1 },
+ { "RE", RAP_ELECTRICITY, 1 },
+ { "RP", RAP_POISON, 1 },
+ { "RN", RAP_NEGATIVE_ENERGY, 1 },
+ { "MP", RAP_MAGICAL_POWER, 1 },
+ { "MR", RAP_MAGIC, 2 },
+ { "SInv", RAP_EYESIGHT, 2 },
+ { "Stl", RAP_STEALTH, 2 },
+
+ { "Ang", RAP_BERSERK, 2 },
+ { "Noi", RAP_NOISES, 2 },
+ { "-Spl", RAP_PREVENT_SPELLCASTING, 2 },
+ { "-Tp", RAP_PREVENT_TELEPORTATION, 2 },
+ { "+Tp", RAP_CAUSE_TELEPORTATION, 2 },
+ { "Hun", RAP_METABOLISM, 1 },
+ { "Mut", RAP_MUTAGENIC, 2 },
+
+ { "Inv", RAP_INVISIBLE, 2 },
+ { "Lev", RAP_LEVITATE, 2 },
+ { "Blk", RAP_BLINK, 2 },
+ { "?Tp", RAP_CAN_TELEPORT, 2 },
+ { "Map", RAP_MAPPING, 2 },
+ };
+
+ for ( unsigned i = 0; i < ARRAYSIZE(propdescs); ++i )
+ {
+ if (known_proprt(propdescs[i].prop))
+ {
+ const int val = proprt[propdescs[i].prop];
+ std::ostringstream work;
+ switch ( propdescs[i].spell_out )
+ {
+ case 0:
+ work << std::ios::showpos << val << ' ' << propdescs[i].name;
+ break;
+ case 1:
+ {
+ const int sval = std::min(std::abs(val), 3);
+ work << std::string(sval, (val > 0 ? '+' : '-'))
+ << propdescs[i].name;
+ break;
+ }
+ case 2:
+ work << propdescs[i].name;
+ break;
+ }
+ propnames.push_back(work.str());
+ }
+ }
+ return comma_separated_line(propnames.begin(), propnames.end(),
+ ", ", ", ");
+
+}
+
static std::string randart_descrip( const item_def &item )
{
-#define known_proprt(prop) (proprt[(prop)] && known[(prop)])
std::string description;
randart_properties_t proprt;
@@ -3515,18 +3594,37 @@ void describe_item( item_def &item, bool allow_inscribe )
&& wherey() <= get_number_of_lines() - 3)
{
gotoxy(1, wherey() + 2);
- formatted_string::parse_string(
- "<cyan>Do you wish to inscribe this item? ").display();
- if (toupper(getch()) == 'Y')
+ // OK, technically inefficient to call randart_auto_inscription
+ // when we don't need to.
+ const bool allow_autoinscribe =
+ is_random_artefact(item) &&
+ item_ident(item, ISFLAG_KNOW_PROPERTIES) &&
+ (item.inscription != randart_auto_inscription(item));
+
+ if ( allow_autoinscribe )
+ {
+ formatted_string::parse_string(
+ "<cyan>Do you wish to inscribe this item? "
+ "('a' to autoinscribe) ").display();
+ }
+ else
+ {
+ formatted_string::parse_string(
+ "<cyan>Do you wish to inscribe this item? ").display();
+ }
+
+ const int keyin = getch();
+
+ if (toupper(keyin) == 'Y')
{
char buf[79];
cprintf("\nInscribe with what? ");
if (!cancelable_get_line(buf, sizeof buf))
- {
- item.inscription = std::string(buf);
- }
+ item.inscription = buf;
}
+ else if (toupper(keyin) == 'A' && allow_autoinscribe)
+ item.inscription += randart_auto_inscription(item);
}
else if (getch() == 0)
getch();