public quality_name(quality_squelch e, string s) { enum_val = (int)e; name = s; }
/* * Determine the squelch level of an object, which is similar to its pseudo. * * The main point is when the value is undetermined given current info, * return the maximum possible value. */ public static quality_squelch squelch_level_of(Object.Object o_ptr) { quality_squelch value = quality_squelch.SQUELCH_NONE; Bitflag f = new Bitflag(Object_Flag.SIZE); Bitflag f2 = new Bitflag(Object_Flag.SIZE); int i; o_ptr.object_flags_known(ref f); /* Deal with jewelry specially. */ if (o_ptr.is_jewelry()) { /* CC: average jewelry has at least one known positive pval */ for (i = 0; i < o_ptr.num_pvals; i++) { if ((o_ptr.this_pval_is_visible(i)) && (o_ptr.pval[i] > 0)) { return(quality_squelch.SQUELCH_AVERAGE); } } if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0)) { return(quality_squelch.SQUELCH_AVERAGE); } if ((o_ptr.attack_plusses_are_visible() && ((o_ptr.to_h < 0) || (o_ptr.to_d < 0))) || (o_ptr.defence_plusses_are_visible() && o_ptr.to_a < 0)) { return(quality_squelch.SQUELCH_BAD); } return(quality_squelch.SQUELCH_AVERAGE); } /* And lights */ if (o_ptr.tval == TVal.TV_LIGHT) { Object_Flag.create_mask(f2, true, Object_Flag.object_flag_id.WIELD); if (f.is_inter(f2)) { return(quality_squelch.SQUELCH_ALL); } if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0)) { return(quality_squelch.SQUELCH_GOOD); } if ((o_ptr.to_h < 0) || (o_ptr.to_d < 0) || (o_ptr.to_a < 0)) { return(quality_squelch.SQUELCH_BAD); } return(quality_squelch.SQUELCH_AVERAGE); } /* CC: we need to redefine "bad" with multiple pvals * At the moment we use "all pvals known and negative" */ for (i = 0; i < o_ptr.num_pvals; i++) { if (!o_ptr.this_pval_is_visible(i) || (o_ptr.pval[i] > 0)) { break; } if (i == (o_ptr.num_pvals - 1)) { return(quality_squelch.SQUELCH_BAD); } } if (o_ptr.was_sensed()) { Object.Object.obj_pseudo_t pseudo = o_ptr.pseudo(); switch (pseudo) { case Object.Object.obj_pseudo_t.INSCRIP_AVERAGE: { value = quality_squelch.SQUELCH_AVERAGE; break; } case Object.Object.obj_pseudo_t.INSCRIP_EXCELLENT: { /* have to assume splendid until you have tested it */ if (o_ptr.was_worn()) { if (o_ptr.high_resist_is_possible()) { value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL; } else { value = quality_squelch.SQUELCH_EXCELLENT_NO_HI; } } else { value = quality_squelch.SQUELCH_ALL; } break; } case Object.Object.obj_pseudo_t.INSCRIP_SPLENDID: value = quality_squelch.SQUELCH_ALL; break; case Object.Object.obj_pseudo_t.INSCRIP_null: case Object.Object.obj_pseudo_t.INSCRIP_SPECIAL: value = quality_squelch.SQUELCH_MAX; break; /* This is the interesting case */ case Object.Object.obj_pseudo_t.INSCRIP_STRANGE: case Object.Object.obj_pseudo_t.INSCRIP_MAGICAL: { value = quality_squelch.SQUELCH_GOOD; if ((o_ptr.attack_plusses_are_visible() || Random.randcalc_valid(o_ptr.kind.to_h, o_ptr.to_h) || Random.randcalc_valid(o_ptr.kind.to_d, o_ptr.to_d)) && (o_ptr.defence_plusses_are_visible() || Random.randcalc_valid(o_ptr.kind.to_a, o_ptr.to_a))) { int isgood = is_object_good(o_ptr); if (isgood > 0) { value = quality_squelch.SQUELCH_GOOD; } else if (isgood < 0) { value = quality_squelch.SQUELCH_BAD; } else { value = quality_squelch.SQUELCH_AVERAGE; } } break; } default: /* do not handle any other possible pseudo values */ Misc.assert(false); break; } } else { if (o_ptr.was_worn()) { value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL; /* object would be sensed if it were splendid */ } else if (o_ptr.is_known_not_artifact()) { value = quality_squelch.SQUELCH_ALL; } else { value = quality_squelch.SQUELCH_MAX; } } return(value); }
public quality_name(quality_squelch e, string s) { enum_val = (int) e; name = s; }