示例#1
0
        /// <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;
            }
        }
示例#2
0
        /// <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);
        }
示例#3
0
        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);
            }
        }
示例#4
0
 private void InsertAt(RollableTableRow row, int pos)
 {
     Rows.InsertAt(row, pos);
     SetComputedValues();
 }
示例#5
0
 /// <summary>
 /// Append a row
 /// </summary>
 /// <param name="row"></param>
 public void Add(RollableTableRow row)
 {
     Rows.Add(row);
     SetComputedValues();
 }
示例#6
0
 public void Remove(RollableTableRow row)
 {
     Rows.Remove(row);
     SetComputedValues();
 }
示例#7
0
        public RollableTableRow GetNewRow()
        {
            RollableTableRow row = (RollableTableRow)NewRow();

            return(row);
        }