Exemplo n.º 1
0
 /// <summary>
 /// Instruction to make a roll on a table
 /// </summary>
 /// <param name="table">Table to roll on</param>
 public TableRoll(RollableTable table)
 {
     Table       = table;
     Rolls       = 1;
     IgnoreBelow = 0;
     IgnoreAbove = int.MaxValue;
 }
Exemplo n.º 2
0
 public RollableTable(string tableName)
 {
     TableName = tableName;
     Dice      = RollableTable.DefaultDieRoll();
     Columns.Add(new DataColumn("LowRoll", typeof(int)));
     Columns.Add(new DataColumn("HighRoll", typeof(int)));
     Columns.Add(new DataColumn("RangeText", typeof(string)));
     Columns.Add(new DataColumn("Item", typeof(IResolver)));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Create a RollableTable and add it to MyTables
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public static RollableTable NewTable(string tableName)
        {
            Repository bits = GetCurrentRepository();

            RollableTable rt = new RollableTable(tableName);

            bits.Tables.Add(tableName, rt);
            return(rt);
        }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 private void RollableTableWriteXml(RollableTable obj)
 {
     writer.WriteStartElement("Table");
     writer.WriteAttributeString("TableName", obj.TableName);
     SaveObject(obj.Dice);
     foreach (RollableTableRow row in obj.Rows)
     {
         writer.WriteStartElement("Row");
         Utility.WriteAttribute(writer, "HighRoll", row.HighRoll, int.MaxValue);
         SaveObject(row.Item);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
Exemplo n.º 6
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);
            }
        }