git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5429 c06c8d41-db1a-0410-9941-cceddc491573
LTFWXACXWTSFJNSVDFCMC4IJBHUERV6DNCKIECIMRXG2M2U3TYJAC /* ************************************************************************ called from: debug* *********************************************************************** */void randart_set_properties( item_def &item,randart_properties_t &proprt );void randart_set_property( item_def &item,randart_prop_type prop,int val );
}void randart_set_properties( item_def &item,randart_properties_t &proprt ){ASSERT( is_random_artefact( item ) );ASSERT( !is_unrandom_artefact ( item ) );ASSERT( item.props.exists( RANDART_PROPS_KEY ) );CrawlVector &rap_vec = item.props[RANDART_PROPS_KEY].get_vector();ASSERT( rap_vec.get_type() == SV_SHORT );ASSERT( rap_vec.size() == RA_PROPERTIES);ASSERT( rap_vec.get_max_size() == RA_PROPERTIES);for (vec_size i = 0; i < RA_PROPERTIES; i++)rap_vec[i].get_short() = proprt[i];}void randart_set_property( item_def &item,randart_prop_type prop,int val ){ASSERT( is_random_artefact( item ) );ASSERT( !is_unrandom_artefact ( item ) );ASSERT( item.props.exists( RANDART_PROPS_KEY ) );CrawlVector &rap_vec = item.props[RANDART_PROPS_KEY].get_vector();ASSERT( rap_vec.get_type() == SV_SHORT );ASSERT( rap_vec.size() == RA_PROPERTIES);ASSERT( rap_vec.get_max_size() == RA_PROPERTIES);rap_vec[prop].get_short() = val;
const char* _prop_name[RAP_NUM_PROPERTIES] = {"Brand","AC","EV","Str","Int","Dex","Fire","Cold","Elec","Pois","Neg","Mag","SInv","Inv","Lev","Blnk","Tele","Bers","Map","Nois","NoSpl","RndTl","NoTel","Anger","Metab","Mut","Acc","Dam","Curse","Stlth","MP"};#define RAP_VAL_BOOL 0#define RAP_VAL_POS 1#define RAP_VAL_ANY 2char _prop_type[RAP_NUM_PROPERTIES] = {RAP_VAL_POS, //BRANDRAP_VAL_ANY, //ACRAP_VAL_ANY, //EVASIONRAP_VAL_ANY, //STRENGTHRAP_VAL_ANY, //INTELLIGENCERAP_VAL_ANY, //DEXTERITYRAP_VAL_ANY, //FIRERAP_VAL_ANY, //COLDRAP_VAL_BOOL, //ELECTRICITYRAP_VAL_BOOL, //POISONRAP_VAL_BOOL, //NEGATIVE_ENERGYRAP_VAL_POS, //MAGICRAP_VAL_BOOL, //EYESIGHTRAP_VAL_BOOL, //INVISIBLERAP_VAL_BOOL, //LEVITATERAP_VAL_BOOL, //BLINKRAP_VAL_BOOL, //CAN_TELEPORTRAP_VAL_BOOL, //BERSERKRAP_VAL_BOOL, //MAPPINGRAP_VAL_POS, //NOISESRAP_VAL_BOOL, //PREVENT_SPELLCASTINGRAP_VAL_BOOL, //CAUSE_TELEPORTATIONRAP_VAL_BOOL, //PREVENT_TELEPORTATIONRAP_VAL_POS, //ANGRYRAP_VAL_POS, //METABOLISMRAP_VAL_POS, //MUTAGENICRAP_VAL_ANY, //ACCURACYRAP_VAL_ANY, //DAMAGERAP_VAL_POS, //CURSEDRAP_VAL_ANY, //STEALTHRAP_VAL_ANY //MAGICAL_POWER};static void _tweak_randart(item_def &item){if (item_is_equipped(item)){mpr("You can't tweak the randart properties of an equipped item.",MSGCH_PROMPT);return;}randart_properties_t props;randart_wpn_properties(item, props);std::string prompt = "";for (int i = 0; i < RAP_NUM_PROPERTIES; i++){if (i % 8 == 0 && i != 0)prompt += "\n";char choice;char buf[80];if (i < 26)choice = 'A' + i;elsechoice = '1' + i - 26;if (props[i])sprintf(buf, "%c) <w>%-5s</w> ", choice, _prop_name[i]);elsesprintf(buf, "%c) %-5s ", choice, _prop_name[i]);prompt += buf;}formatted_message_history(prompt, MSGCH_PROMPT, 0, 80);mpr( "Change which field? ", MSGCH_PROMPT );char keyin = tolower( get_ch() );int choice;if (isalpha(keyin))choice = keyin - 'a';else if (isdigit(keyin) && keyin != '0')choice = keyin - '1' + 26;elsereturn;int val;switch(_prop_type[choice]){case RAP_VAL_BOOL:mprf(MSGCH_PROMPT, "Toggling %s to %s.", _prop_name[choice],props[choice] ? "off" : "on");randart_set_property(item, static_cast<randart_prop_type>(choice),!props[choice]);break;case RAP_VAL_POS:mprf(MSGCH_PROMPT, "%s was %d.", _prop_name[choice], props[choice]);val = _debug_prompt_for_int("New value? ", true);if (val < 0){mprf(MSGCH_PROMPT, "Value for %s must be non-negative",_prop_name[choice]);return;}randart_set_property(item, static_cast<randart_prop_type>(choice),val);break;case RAP_VAL_ANY:mprf(MSGCH_PROMPT, "%s was %d.", _prop_name[choice], props[choice]);val = _debug_prompt_for_int("New value? ", false);randart_set_property(item, static_cast<randart_prop_type>(choice),val);break;}}
mpr( "a - plus b - plus2 c - special d - quantity e - flags ESC - exit",MSGCH_PROMPT );
if (is_art)mpr( "a - plus b - plus2 c - art props d - quantity ""e - flags ESC - exit", MSGCH_PROMPT );elsempr( "a - plus b - plus2 c - special d - quantity ""e - flags ESC - exit", MSGCH_PROMPT );