/** * A modifier string, put where '#' goes in the basename below. The weird * games played with book names are to allow the non-essential part of the * name to be abbreviated when there is not much room to display. */ static const char *obj_desc_get_modstr(const struct object_kind *kind) { if (tval_can_have_flavor_k(kind)) return kind->flavor ? kind->flavor->text : ""; if (tval_is_book_k(kind)) return kind->name; return ""; }
/** * Describe stat modifications. */ static bool describe_stats(textblock *tb, const struct object *obj, oinfo_detail_t mode) { size_t count = 0, i; bool detail = false; /* Don't give exact plusses for faked ego items as each real one will * be different */ bool suppress_details = mode & OINFO_EGO ? true : false; /* Fact of but not size of mods is known for egos and flavoured items * the player is aware of */ bool known_effect = false; if (object_ego_is_visible(obj)) known_effect = true; if (tval_can_have_flavor_k(obj->kind) && object_flavor_is_aware(obj)) known_effect = true; /* See what we've got */ for (i = 0; i < N_ELEMENTS(mod_flags); i++) if (obj->modifiers[mod_flags[i].flag] != 0 && mod_flags[i].name[0]) { count++; /* Either all mods are visible, or none are */ if (object_this_mod_is_visible(obj, mod_flags[i].flag)) detail = true; } if (!count) return false; for (i = 0; i < N_ELEMENTS(mod_flags); i++) { const char *desc = mod_flags[i].name; int val = obj->modifiers[mod_flags[i].flag]; if (!val) continue; if (!mod_flags[i].name[0]) continue; if (detail && !suppress_details) { int attr = (val > 0) ? COLOUR_L_GREEN : COLOUR_RED; textblock_append_c(tb, attr, "%+i %s.\n", val, desc); } else if (known_effect) textblock_append(tb, "Affects your %s\n", desc); } return true; }
/** * Describe stat modifications. */ static bool describe_stats(textblock *tb, const struct object *obj, oinfo_detail_t mode) { size_t count = 0, i; bool detail = false; /* Don't give exact plusses for faked ego items as each real one will * be different */ bool suppress_details = mode & (OINFO_EGO | OINFO_FAKE) ? true : false; /* Fact of but not size of mods is known for egos and flavoured items * the player is aware of */ bool known_effect = false; if (obj->known->ego) known_effect = true; if (tval_can_have_flavor_k(obj->kind) && object_flavor_is_aware(obj)) known_effect = true; /* See what we've got */ for (i = 0; i < OBJ_MOD_MAX; i++) if (obj->known->modifiers[i]) { count++; detail = true; } if (!count) return false; for (i = 0; i < OBJ_MOD_MAX; i++) { const char *desc = lookup_obj_property(OBJ_PROPERTY_MOD, i)->name; int val = obj->known->modifiers[i]; if (!val) continue; /* Actual object */ if (detail && !suppress_details) { int attr = (val > 0) ? COLOUR_L_GREEN : COLOUR_RED; textblock_append_c(tb, attr, "%+i %s.\n", val, desc); } else if (known_effect) /* Ego type or jewellery description */ textblock_append(tb, "Affects your %s\n", desc); } return true; }