/// <summary> /// Calculate drops from a specific loot table. /// </summary> /// <param name="table">The table to be evaluated.</param> /// <returns>Loot structure containing Xp/Gold/List of items to be awarded.</returns> public static Loot CalculateTable(Xml.LootTable table) { var tableLoot = new Loot(0, 0); if (table.Gold != null) { if (table.Gold.Max != 0) { tableLoot.Gold += RollBetween(table.Gold.Min, table.Gold.Max); } else { tableLoot.Gold += table.Gold.Min; } GameLog.SpawnInfo("Processing loot: added {Gold} gp", tableLoot.Gold); } if (table.Xp != null) { if (table.Xp.Max != 0) { tableLoot.Xp += RollBetween(table.Xp.Min, table.Xp.Max); } else { tableLoot.Xp += table.Xp.Min; } GameLog.SpawnInfo("Processing loot: added {Xp} xp", tableLoot.Xp); } // Handle items now if (table.Items != null) { foreach (var itemlist in table.Items) { tableLoot.Items.AddRange(CalculateItems(itemlist)); } } else { GameLog.SpawnWarning("Loot table is null!"); } return(tableLoot); }