From c77ffc6ae6aab4e11932300b83bc3d047cdc68c7 Mon Sep 17 00:00:00 2001 From: Matthew McConnell Date: Wed, 28 Sep 2016 16:48:55 +0100 Subject: [PATCH] Changed chance to decimal --- src/ExileLootDrop/CfgGroupItem.cs | 6 +++--- src/ExileLootDrop/Loot.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ExileLootDrop/CfgGroupItem.cs b/src/ExileLootDrop/CfgGroupItem.cs index bcd65e3..6a1689b 100644 --- a/src/ExileLootDrop/CfgGroupItem.cs +++ b/src/ExileLootDrop/CfgGroupItem.cs @@ -5,7 +5,7 @@ namespace ExileLootDrop /// /// Item chance /// - public int Chance { get; } + public decimal Chance { get; } /// /// Item/group name @@ -21,8 +21,8 @@ namespace ExileLootDrop var parts = line.Split(','); if (parts.Length != 2) throw new CfgGroupItemException($"Item line is invalid: {line}"); - int chance; - if (!int.TryParse(parts[0], out chance)) + decimal chance; + if (!decimal.TryParse(parts[0], out chance)) throw new CfgGroupItemException($"Could not parse chance: {line}"); Chance = chance; Item = parts[1].Trim(); diff --git a/src/ExileLootDrop/Loot.cs b/src/ExileLootDrop/Loot.cs index f3a79e6..ccdd87b 100644 --- a/src/ExileLootDrop/Loot.cs +++ b/src/ExileLootDrop/Loot.cs @@ -122,7 +122,7 @@ namespace ExileLootDrop var total = group.Items.Select(i => i.Chance).Sum(); foreach (var item in group.Items.OrderByDescending(a => a.Chance)) { - var chance = (decimal)item.Chance / total; + var chance = item.Chance / total; var child = _cfgGroups.Find(g => g.Name == item.Item); if (child != null) {