// Give the proper name to a potion, stick, or ring void nameit(THING obj, string type, string which, obj_info op, Func <THING, string> prfunc) { if (op.oi_know || !string.IsNullOrEmpty(op.oi_guess)) { if (obj.o_count == 1) { prbuf = string.Format("A {0} ", type); } else { prbuf = string.Format("{0} {1}s ", obj.o_count, type); } if (op.oi_know) { prbuf += string.Format("of {0}{1}({2})", op.oi_name, prfunc(obj), which); } else if (!string.IsNullOrEmpty(op.oi_guess)) { prbuf += string.Format("called {0}{1}({2})", op.oi_guess, prfunc(obj), which); } } else if (obj.o_count == 1) { prbuf = string.Format("A{0} {1} {2}", vowelstr(which), which, type); } else { prbuf = string.Format("{0} {1} {2}s", obj.o_count, which, type); } }
// Set things up when we really know what a thing is void set_know(THING obj, obj_info[] info) { string guess; info[obj.o_which].oi_know = true; obj.o_flags |= ISKNOW; guess = info[obj.o_which].oi_guess; if (!string.IsNullOrEmpty(guess)) { info[obj.o_which].oi_guess = null; } }
// Call an object something after use. void call_it(obj_info info) { if (info.oi_know) { if (!string.IsNullOrEmpty(info.oi_guess)) { info.oi_guess = null; } } else if (string.IsNullOrEmpty(info.oi_guess)) { msg(terse ? "call it: " : "what do you want to call it? "); string buf; if (get_str(out buf, stdscr) == NORM) { if (info.oi_guess != null) info.oi_guess = buf; } } }
// Call an object something after use. void call_it(obj_info info) { if (info.oi_know) { if (!string.IsNullOrEmpty(info.oi_guess)) { info.oi_guess = null; } } else if (string.IsNullOrEmpty(info.oi_guess)) { msg(terse ? "call it: " : "what do you want to call it? "); string buf; if (get_str(out buf, stdscr) == NORM) { if (info.oi_guess != null) { info.oi_guess = buf; } } } }
// Sum up the probabilities for items appearing void sumprobs(obj_info[] info, int bound) { for (int i = 1; i < info.Length; ++i ) info[i].oi_prob += info[i - 1].oi_prob; }
// Allow a user to call a potion, scroll, or ring something void call() { THING obj; obj_info op = null; string guess, elsewise = null; bool know; bool isitem = false; obj = get_item("call", CALLABLE); /* * Make certain that it is somethings that we want to wear */ if (obj == null) { return; } switch (obj.o_type) { case RING: op = ring_info[obj.o_which]; elsewise = r_stones[obj.o_which]; goto norm; case POTION: op = pot_info[obj.o_which]; elsewise = p_colors[obj.o_which]; goto norm; case SCROLL: op = scr_info[obj.o_which]; elsewise = s_names[obj.o_which]; goto norm; case STICK: op = ws_info[obj.o_which]; elsewise = ws_made[obj.o_which]; norm: isitem = true; know = op.oi_know; guess = op.oi_guess; if (!string.IsNullOrEmpty(guess)) { elsewise = guess; } break; case FOOD: msg("you can't call that anything"); return; default: guess = obj.o_label; know = false; elsewise = obj.o_label; break; } if (know) { msg("that has already been identified"); return; } if (!string.IsNullOrEmpty(elsewise) && elsewise == guess) { if (!terse) { addmsg("Was "); } msg("called \"{0}\"", elsewise); } if (terse) { msg("call it: "); } else { msg("what do you want to call it? "); } if (string.IsNullOrEmpty(elsewise)) { prbuf = ""; } else { prbuf = elsewise; } string buf; if (get_str(out buf, stdscr) == NORM) { if (isitem) { op.oi_guess = buf; } else { obj.o_label = buf; } } }
// Pick an item out of a list of nitems possible objects int pick_one(obj_info[] info, int nitems) { int i; i = rnd(100); int j = 0; foreach (var item in info) { if (i < item.oi_prob) return j; j++; } return 0; }
// Give the proper name to a potion, stick, or ring void nameit(THING obj, string type, string which, obj_info op, Func<THING, string> prfunc) { if (op.oi_know || !string.IsNullOrEmpty(op.oi_guess)) { if (obj.o_count == 1) prbuf = string.Format("A {0} ", type); else prbuf = string.Format("{0} {1}s ", obj.o_count, type); if (op.oi_know) prbuf += string.Format("of {0}{1}({2})", op.oi_name, prfunc(obj), which); else if (!string.IsNullOrEmpty(op.oi_guess)) prbuf += string.Format("called {0}{1}({2})", op.oi_guess, prfunc(obj), which); } else if (obj.o_count == 1) prbuf = string.Format("A{0} {1} {2}", vowelstr(which), which, type); else prbuf = string.Format("{0} {1} {2}s", obj.o_count, which, type); }