public static int Compare(StructFlag<StatsProperty> props, StatsEffect self, StatsEffect other) { var result = 0m; foreach (var property in props.Values) { result += other.Effect.GetValueOrDefault(property) - self.Effect.GetValueOrDefault(property); } return Math.Sign(result); }
public Stats Apply(StatsEffect effect) { switch (effect.ChangeType) { case ChangeType.Add: return(new Stats(DefaultStats .ToDictionary(kv => kv.Key, kv => GetStat(kv.Key) + effect.Effect.GetValueOrDefault(kv.Key)) )); case ChangeType.Set: return(new Stats(DefaultStats .ToDictionary(kv => kv.Key, kv => effect.Effect.GetValueOrDefault(kv.Key, GetStat(kv.Key))) )); case ChangeType.Multiply: return(new Stats(DefaultStats .ToDictionary(kv => kv.Key, kv => GetStat(kv.Key) * effect.Effect.GetValueOrDefault(kv.Key, 1)) )); default: throw new ArgumentOutOfRangeException(); } }