Exemple #1
0
 /// <summary>
 /// Convert a string array to a RollableTable
 /// <param name="array"></param>
 /// <param name="table"></param>
 /// <returns>true if success</returns>
 /// </summary>
 public static bool TryParse(string[] array, out RollableTable table)
 {
     // generate a RollableTableRow for each array element
     table = new RollableTable();
     for (int i = 0; i < array.Length; i++)
     {
         table.Add(table.GetNewRow(ParseItem(array[i]), i + 1));
     }
     table.Dice = new DieRoll(1, array.Length, 0);
     return(table.Rows.Count > 0);
 }
Exemple #2
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);
            }
        }