Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public delegate U CombineCompositeStat<T, U>(Dictionary<string, T> stats, List<U> add, List<float> multiply)
- where T : IStatContainer<U>;
- public class CompositeStat<T, U> : IStatContainer<U>
- where T : NumericStat, IStatContainer<U>
- {
- public U Value { get { return CombineFunc(Stats, AdditionFactors, MultiplicationFactors); } }
- public CombineCompositeStat<T, U> CombineFunc { get; protected set; }
- public static U DefaultCompositeCombine(Dictionary<string, T> stats, List<U> add, List<float> multiply)
- {
- T baseStat = stats.FirstOrDefault(x => x.Key.Contains("BASE")).Value;
- T EV = stats.FirstOrDefault(x => x.Key.Contains("EV")).Value;
- T IV = stats.FirstOrDefault(x => x.Key.Contains("IV")).Value;
- //U result = (baseStat.Value + IV.Value) * EV.Value;
- return (U)typeof(U).GetDefaultValue();
- }
- public Dictionary<string, T> Stats { get; protected set; }
- public List<U> AdditionFactors { get; protected set; }
- public List<float> MultiplicationFactors { get; protected set; }
- public CompositeStat() : this(new List<T>(), DefaultCompositeCombine) { }
- public CompositeStat(params T[] stats) : this(stats, DefaultCompositeCombine) { }
- public CompositeStat(IEnumerable<T> stats, CombineCompositeStat<T, U> func, IEnumerable<U> adders=null, IEnumerable<float> multipliers=null)
- {
- CombineFunc = func;
- Stats = new Dictionary<string, T>();
- foreach (var stat in stats)
- Stats.Add(stat.Name, stat);
- AdditionFactors = new List<U>();
- AdditionFactors.AddRange(adders ?? new List<U>());
- MultiplicationFactors = new List<float>();
- MultiplicationFactors.AddRange(multipliers ?? new List<float>());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment