/* * Get the racial history, and social class, using the "history charts". */ public string get_history(out Int16 sc) { int roll, social_class; History_Entry entry; string res = ""; social_class = (int)Random.randint1(4); History_Chart chart = this; while (chart != null) { roll = (int)Random.randint1(100); for (entry = chart.entries; ; entry = entry.next) { if (roll <= entry.roll) { break; } } Misc.assert(entry != null); res += entry.text; social_class += entry.bonus - 50; chart = entry.succ; } if (social_class > 75) { social_class = 75; } else if (social_class < 1) { social_class = 1; } sc = (short)social_class; return(res); }
static History_Chart findchart(History_Chart hs, uint idx) { for (; hs != null; hs = hs.next) if (hs.idx == idx) break; return hs; }
/* Parsing functions for p_hist.txt */ public static Parser.Error parse_h_n(Parser p) { History_Chart oc = p.priv as History_Chart; History_Chart c; History_Entry e = new History_Entry(); uint idx = p.getuint("chart"); if ((c = findchart(oc, idx)) == null) { c = new History_Chart(); c.next = oc; c.idx = idx; p.priv = c; } e.isucc = p.getint("next"); e.roll = p.getint("roll"); e.bonus = p.getint("bonus"); e.next = c.entries; c.entries = e; return Parser.Error.NONE; }