From 674a9e64697629cc3266564ea4f8dc7eb2616b50 Mon Sep 17 00:00:00 2001 From: haranp Date: Tue, 13 Nov 2007 12:57:26 +0000 Subject: Better Returning description [1830132] git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2848 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/describe.cc | 65 ++++++++++++++++---------------------------- crawl-ref/source/randart.cc | 2 +- crawl-ref/source/randart.h | 2 +- 3 files changed, 25 insertions(+), 44 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index d50a4cc931..3d86f433b9 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -152,19 +152,10 @@ void print_description( const std::string &d ) } } -//--------------------------------------------------------------- -// -// randart_descrip -// -// Appends the various powers of a random artefact to the description -// string. -// -//--------------------------------------------------------------- -static void randart_descrip( std::string &description, const item_def &item ) +static std::string randart_descrip( const item_def &item ) { #define known_proprt(prop) (proprt[(prop)] && known[(prop)]) - - unsigned int old_length = description.length(); + std::string description; randart_properties_t proprt; randart_known_props_t known; @@ -343,12 +334,12 @@ static void randart_descrip( std::string &description, const item_def &item ) if (known_proprt( RAP_MUTAGENIC )) { if (proprt[ RAP_MUTAGENIC ] > 3) - description += "$It glows with mutagenic radiation."; + description += "$It glows with mutagenic radiation. "; else if (proprt[ RAP_MUTAGENIC ]) - description += "$It emits mutagenic radiation."; + description += "$It emits mutagenic radiation. "; } - if (old_length != description.length()) + if (!description.empty()) description += "$"; if (is_unrandom_artefact( item )) @@ -360,6 +351,8 @@ static void randart_descrip( std::string &description, const item_def &item ) description += "$"; } } + + return description; #undef known_proprt } @@ -1216,27 +1209,24 @@ static std::string describe_weapon( const item_def &item, bool verbose) break; case SPWPN_DISTORTION: description += "It warps and distorts space around it. " - "Merely wielding or unwielding it can be highly risky."; + "Merely wielding or unwielding it can be highly risky. "; break; case SPWPN_REACHING: description += "It can be evoked to extend its reach. "; break; case SPWPN_RETURNING: - description += "It is enchanted to return to its owner " - "when thrown."; + description += "A skilled user can throw it in such a way " + "that it will return to its owner. "; break; } } if (is_random_artefact( item )) { - unsigned int old_length = description.length(); - randart_descrip( description, item ); + description += randart_descrip( item ); - if (description.length() == old_length) - description += "$"; - else if (!item_ident( item, ISFLAG_KNOW_PROPERTIES ) - && item_type_known(item)) + if (!item_ident(item, ISFLAG_KNOW_PROPERTIES) + && item_type_known(item)) { description += "$This weapon may have some hidden properties.$"; } @@ -1254,19 +1244,16 @@ static std::string describe_weapon( const item_def &item, bool verbose) if (verbose && !is_range_weapon(item)) { -#ifdef USE_NEW_COMBAT_STATS - const int str_weight = weapon_str_weight( item.base_type, item.sub_type ); + const int str_weight = weapon_str_weight(item.base_type, item.sub_type); if (str_weight >= 8) - description += "$This weapon is best used by the strong."; + description += "$This weapon is best used by the strong.$"; else if (str_weight > 5) - description += "$This weapon is better for the strong."; + description += "$This weapon is better for the strong.$"; else if (str_weight <= 2) - description += "$This weapon is best used by the dexterous."; + description += "$This weapon is best used by the dexterous.$"; else if (str_weight < 5) - description += "$This weapon is better for the dexterous."; -#endif - description += "$"; + description += "$This weapon is better for the dexterous.$"; switch (hands_reqd(item, player_size())) { @@ -1829,12 +1816,9 @@ static std::string describe_armour( const item_def &item, bool verbose ) if (is_random_artefact( item )) { - randart_descrip( description, item ); - if (!item_ident( item, ISFLAG_KNOW_PROPERTIES ) - && item_type_known(item)) - { + description += randart_descrip( item ); + if (!item_ident(item, ISFLAG_KNOW_PROPERTIES) && item_type_known(item)) description += "$This armour may have some hidden properties.$"; - } } else { @@ -2791,11 +2775,10 @@ static std::string describe_jewellery( const item_def &item, bool verbose) // randart properties if (is_random_artefact( item )) { - randart_descrip( description, item ); - if (!item_ident( item, ISFLAG_KNOW_PROPERTIES ) - && item_type_known(item)) + description += randart_descrip(item); + if (!item_ident(item, ISFLAG_KNOW_PROPERTIES) && item_type_known(item)) { - if (item.sub_type >= AMU_RAGE) + if (jewellery_is_amulet(item)) description += "$This amulet may have hidden properties.$"; else description += "$This ring may have hidden properties.$"; @@ -2803,9 +2786,7 @@ static std::string describe_jewellery( const item_def &item, bool verbose) } if (item_known_cursed( item )) - { description += "$It has a curse placed upon it."; - } return (description); } // end describe_jewellery() diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc index 10b7e81e06..3e54be6752 100644 --- a/crawl-ref/source/randart.cc +++ b/crawl-ref/source/randart.cc @@ -2173,7 +2173,7 @@ bool make_item_unrandart( item_def &item, int unrand_index ) return (true); } // end make_item_unrandart() -const char *unrandart_descrip( char which_descrip, const item_def &item ) +const char *unrandart_descrip( int which_descrip, const item_def &item ) { /* Eventually it would be great to have randomly generated descriptions for randarts. */ diff --git a/crawl-ref/source/randart.h b/crawl-ref/source/randart.h index ecdac587ab..74d7905aed 100644 --- a/crawl-ref/source/randart.h +++ b/crawl-ref/source/randart.h @@ -50,7 +50,7 @@ std::string randart_jewellery_name( const item_def &item ); /* *********************************************************************** * called from: describe * *********************************************************************** */ -const char *unrandart_descrip( char which_descrip, const item_def &item ); +const char *unrandart_descrip( int which_descrip, const item_def &item ); bool does_unrandart_exist(int whun); -- cgit v1.2.3-54-g00ecf