/// <summary> /// Compute LowRoll and RangeText for each row based on that row and the previous row /// </summary> public void SetComputedValues() { RollableTableRow prevRow = null; foreach (RollableTableRow row in Rows) { if (prevRow != null) { row.LowRoll = prevRow.HighRoll + 1; } else { row.LowRoll = Dice.Minimum; } if (row.LowRoll == row.HighRoll) { row.RangeText = row.HighRoll.ToString(); } else { row.RangeText = row.LowRoll.ToString() + "-" + row.HighRoll.ToString(); } prevRow = row; } }
/// <summary> /// Create a new row /// </summary> /// <param name="item"></param> /// <param name="highRoll"></param> /// <returns></returns> public RollableTableRow GetNewRow(IResolver item, int highRoll) { RollableTableRow row = (RollableTableRow)NewRow(); row.LowRoll = highRoll; row.HighRoll = highRoll; row.Item = item; return(row); }
private void FillRollableTableFromXml(RollableTable tbl, XmlNode node) { tbl.TableName = node.Attributes["TableName"].Value; XmlNode diceNode = node.SelectSingleNode("DieRoll"); tbl.Dice = DieRollFromXml(diceNode); XmlNodeList rowNodes = node.SelectNodes("Row"); foreach (XmlNode rowNode in rowNodes) { RollableTableRow row = tbl.GetNewRow(); row.HighRoll = Utility.ParseAttribute(rowNode, "HighRoll", int.MaxValue); row.LowRoll = Utility.ParseAttribute(rowNode, "LowRoll", row.HighRoll); // GameObject, Instance, ItemList, TableRoll, ItemRoll row.Item = (IResolver)(LoadObject(rowNode.FirstChild)); tbl.Add(row); } }
private void InsertAt(RollableTableRow row, int pos) { Rows.InsertAt(row, pos); SetComputedValues(); }
/// <summary> /// Append a row /// </summary> /// <param name="row"></param> public void Add(RollableTableRow row) { Rows.Add(row); SetComputedValues(); }
public void Remove(RollableTableRow row) { Rows.Remove(row); SetComputedValues(); }
public RollableTableRow GetNewRow() { RollableTableRow row = (RollableTableRow)NewRow(); return(row); }