static int obj_desc_combat(Object o_ptr, ref string buf, int max, int end, bool spoil) { Bitflag flags = new Bitflag(Object_Flag.SIZE); Bitflag flags_known = new Bitflag(Object_Flag.SIZE); o_ptr.object_flags(ref flags); o_ptr.object_flags_known(ref flags_known); if (flags.has(Object_Flag.SHOW_DICE.value)) { /* Only display the real damage dice if the combat stats are known */ if (spoil || o_ptr.attack_plusses_are_visible()) { buf = buf + " (" + o_ptr.dd + "d" + o_ptr.ds + ")"; } else { buf = buf + " (" + o_ptr.kind.dd + "d" + o_ptr.kind.ds + ")"; } } if (flags.has(Object_Flag.SHOW_MULT.value)) { /* Display shooting power as part of the multiplier */ if (flags.has(Object_Flag.MIGHT.value) && (spoil || o_ptr.object_flag_is_known(Object_Flag.MIGHT.value))) { buf = buf + " (x" + (o_ptr.sval % 10) + o_ptr.pval[o_ptr.which_pval(Object_Flag.MIGHT.value)] + ")"; } else { buf = buf + " (x" + o_ptr.sval % 10 + ")"; } } /* Show weapon bonuses */ if (spoil || o_ptr.attack_plusses_are_visible()) { if (flags.has(Object_Flag.SHOW_MODS.value) || o_ptr.to_d != 0 || o_ptr.to_h != 0) { /* Make an exception for body armor with only a to-hit penalty */ if (o_ptr.to_h < 0 && o_ptr.to_d == 0 && (o_ptr.tval == TVal.TV_SOFT_ARMOR || o_ptr.tval == TVal.TV_HARD_ARMOR || o_ptr.tval == TVal.TV_DRAG_ARMOR)) { buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + ")"; } /* Otherwise, always use the full tuple */ else { buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + "," + (o_ptr.to_d > 0 ? "+" : "-") + o_ptr.to_d + ")"; } } } /* Show armor bonuses */ if (spoil || o_ptr.defence_plusses_are_visible()) { if (obj_desc_show_armor(o_ptr)) { buf = buf + " [" + o_ptr.ac + "," + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]"; } else if (o_ptr.to_a != 0) { buf = buf + " [" + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]"; } } else if (obj_desc_show_armor(o_ptr)) { buf = buf + " [" + (o_ptr.was_sensed() ? o_ptr.ac : o_ptr.kind.ac) + "]"; } return(end); }
/* * Special display, part 2c * * How to print out the modifications and sustains. * Positive mods with no sustain will be light green. * Positive mods with a sustain will be dark green. * Sustains (with no modification) will be a dark green 's'. * Negative mods (from a curse) will be red. * Huge mods (>9), like from MICoMorgoth, will be a '*' * No mod, no sustain, will be a slate '.' */ static void display_player_sust_info() { int j, stat; Player.Player p_ptr = Player.Player.instance; Bitflag f = new Bitflag(Object_Flag.SIZE); Object_Flag[] stat_flags = new Object_Flag[(int)Stat.Max]; Object_Flag[] sustain_flags = new Object_Flag[(int)Stat.Max]; ConsoleColor a; char c; /* Row */ int row = 2; /* Column */ int col = 26; /* Build the stat flags tables */ stat_flags[(int)Stat.Str] = Object_Flag.STR; stat_flags[(int)Stat.Int] = Object_Flag.INT; stat_flags[(int)Stat.Wis] = Object_Flag.WIS; stat_flags[(int)Stat.Dex] = Object_Flag.DEX; stat_flags[(int)Stat.Con] = Object_Flag.CON; stat_flags[(int)Stat.Chr] = Object_Flag.CHR; sustain_flags[(int)Stat.Str] = Object_Flag.SUST_STR; sustain_flags[(int)Stat.Int] = Object_Flag.SUST_INT; sustain_flags[(int)Stat.Wis] = Object_Flag.SUST_WIS; sustain_flags[(int)Stat.Dex] = Object_Flag.SUST_DEX; sustain_flags[(int)Stat.Con] = Object_Flag.SUST_CON; sustain_flags[(int)Stat.Chr] = Object_Flag.SUST_CHR; /* Header */ Utilities.c_put_str(ConsoleColor.White, "abcdefghijkl@", row - 1, col); /* Process equipment */ for (int i = Misc.INVEN_WIELD; i < Misc.INVEN_TOTAL; ++i) { /* Get the object */ Object.Object o_ptr = p_ptr.inventory[i]; if (o_ptr.kind == null) { col++; continue; } /* Get the "known" flags */ o_ptr.object_flags_known(ref f); /* Initialize color based of sign of pval. */ for (stat = 0; stat < (int)Stat.Max; stat++) { /* Default */ a = ConsoleColor.Gray; c = '.'; /* Boost */ if (f.has(stat_flags[stat].value)) { /* Default */ c = '*'; /* Work out which pval we're talking about */ j = o_ptr.which_pval(stat_flags[stat].value); /* Good */ if (o_ptr.pval[j] > 0) { /* Good */ a = ConsoleColor.Green; /* Label boost */ if (o_ptr.pval[j] < 10) { c = (char)Basic.I2D((char)o_ptr.pval[j]); } } /* Bad */ if (o_ptr.pval[j] < 0) { /* Bad */ a = ConsoleColor.Red; /* Label boost */ if (o_ptr.pval[j] > -10) { c = (char)Basic.I2D((char)-(o_ptr.pval[j])); } } } /* Sustain */ if (f.has(sustain_flags[stat].value)) { /* Dark green */ a = ConsoleColor.DarkGreen; /* Convert '.' to 's' */ if (c == '.') { c = 's'; } } if ((c == '.') && o_ptr.kind != null && !o_ptr.object_flag_is_known(sustain_flags[stat].value)) { c = '?'; } /* Dump proper character */ Term.putch(col, row + stat, a, c); } /* Advance */ col++; } /* Player flags */ Player.Player.player_flags(ref f); /* Check stats */ for (stat = 0; stat < (int)Stat.Max; ++stat) { /* Default */ a = ConsoleColor.Gray; c = '.'; /* Sustain */ if (f.has(sustain_flags[stat].value)) { /* Dark green "s" */ a = ConsoleColor.DarkGreen; c = 's'; } /* Dump */ Term.putch(col, row + stat, a, c); } /* Column */ col = 26; /* Footer */ Utilities.c_put_str(ConsoleColor.White, "abcdefghijkl@", row + 6, col); /* Equippy */ display_player_equippy(row + 7, col); }
static int obj_desc_combat(Object o_ptr, ref string buf, int max, int end, bool spoil) { Bitflag flags = new Bitflag(Object_Flag.SIZE); Bitflag flags_known = new Bitflag(Object_Flag.SIZE); o_ptr.object_flags(ref flags); o_ptr.object_flags_known(ref flags_known); if (flags.has(Object_Flag.SHOW_DICE.value)) { /* Only display the real damage dice if the combat stats are known */ if(spoil || o_ptr.attack_plusses_are_visible()) buf = buf + " (" + o_ptr.dd + "d" + o_ptr.ds + ")"; else buf = buf + " (" + o_ptr.kind.dd + "d" + o_ptr.kind.ds + ")"; } if (flags.has(Object_Flag.SHOW_MULT.value)) { /* Display shooting power as part of the multiplier */ if (flags.has(Object_Flag.MIGHT.value) && (spoil || o_ptr.object_flag_is_known(Object_Flag.MIGHT.value))) buf = buf + " (x" + (o_ptr.sval % 10) + o_ptr.pval[o_ptr.which_pval(Object_Flag.MIGHT.value)] + ")"; else buf = buf + " (x" + o_ptr.sval % 10 + ")"; } /* Show weapon bonuses */ if (spoil || o_ptr.attack_plusses_are_visible()) { if (flags.has(Object_Flag.SHOW_MODS.value) || o_ptr.to_d != 0 || o_ptr.to_h != 0) { /* Make an exception for body armor with only a to-hit penalty */ if(o_ptr.to_h < 0 && o_ptr.to_d == 0 && (o_ptr.tval == TVal.TV_SOFT_ARMOR || o_ptr.tval == TVal.TV_HARD_ARMOR || o_ptr.tval == TVal.TV_DRAG_ARMOR)) buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + ")"; /* Otherwise, always use the full tuple */ else buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + "," + (o_ptr.to_d > 0 ? "+" : "-") + o_ptr.to_d + ")"; } } /* Show armor bonuses */ if (spoil || o_ptr.defence_plusses_are_visible()) { if (obj_desc_show_armor(o_ptr)) buf = buf + " [" + o_ptr.ac + "," + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]"; else if (o_ptr.to_a != 0) buf = buf + " [" + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]"; } else if (obj_desc_show_armor(o_ptr)) { buf = buf + " [" + (o_ptr.was_sensed() ? o_ptr.ac : o_ptr.kind.ac) + "]"; } return end; }
static void display_resistance_panel(player_flag_record[] resists, int size, Region bounds) { Player.Player p_ptr = Player.Player.instance; int col = bounds.col; int row = bounds.row; Term.putstr(col, row++, RES_COLS, ConsoleColor.White, " abcdefghijkl@"); for (int i = 0; i < size - 3; i++, row++) { ConsoleColor name_attr = ConsoleColor.White; Term.gotoxy(col + 6, row); /* repeated extraction of flags is inefficient but more natural */ for (int j = Misc.INVEN_WIELD; j <= Misc.INVEN_TOTAL; j++) { Object.Object o_ptr = p_ptr.inventory[j]; Bitflag f = new Bitflag(Object_Flag.SIZE); ConsoleColor[] alternatingcols = new ConsoleColor[] { ConsoleColor.Gray, ConsoleColor.DarkGray }; ConsoleColor attr = alternatingcols[j % 2]; /* alternating columns */ char sym = '.'; bool res, imm, vuln; /* Wipe flagset */ f.wipe(); if (j < Misc.INVEN_TOTAL && o_ptr.kind != null) { o_ptr.object_flags_known(ref f); } else if (j == Misc.INVEN_TOTAL) { Player.Player.player_flags(ref f); /* If the race has innate infravision/digging, force the corresponding flag * here. If we set it in player_flags(), then all callers of that * function will think the infravision is caused by equipment. */ if (p_ptr.Race.infra > 0) { f.on(Object_Flag.INFRA.value); } if (p_ptr.Race.r_skills[(int)Skill.DIGGING] > 0) { f.on(Object_Flag.TUNNEL.value); } } res = f.has(resists[i].res_flag.value); imm = f.has(resists[i].im_flag.value); vuln = f.has(resists[i].vuln_flag.value); if (imm) { name_attr = ConsoleColor.DarkGreen; } else if (res && name_attr == ConsoleColor.White) { name_attr = ConsoleColor.Cyan; } if (vuln) { sym = '-'; } else if (imm) { sym = '*'; } else if (res) { sym = '+'; } else if ((j < Misc.INVEN_TOTAL) && o_ptr.kind != null && !o_ptr.object_flag_is_known(resists[i].res_flag.value)) { sym = '?'; } Term.addch(attr, sym); } Term.putstr(col, row, 6, name_attr, resists[i].name.ToString()); } Term.putstr(col, row++, RES_COLS, ConsoleColor.White, " abcdefghijkl@"); /* Equippy */ display_player_equippy(row++, col + 6); }