[#14] rozbudowa stats + dodanie modyfikatorów
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RPGCore.Core.Objects;
|
||||
|
||||
namespace RPGCore.Stats.ObjectModules.StatsObjectModule
|
||||
{
|
||||
public class StatModifierContext
|
||||
{
|
||||
private readonly List<StatModifier> _modifiers = new();
|
||||
|
||||
public int add => _modifiers.Where(m => m.type is StatModifierType.Add).Sum(m => m.value);
|
||||
public int multiply => _modifiers.Where(m => m.type is StatModifierType.Multiply).Sum(m => m.value);
|
||||
public int @override => _modifiers.Where(m => m.type is StatModifierType.Override).Max(m => m.value);
|
||||
|
||||
public void Add(StatModifier modifier)
|
||||
{
|
||||
_modifiers.Add(modifier);
|
||||
}
|
||||
|
||||
public void Remove(StatModifier modifier)
|
||||
{
|
||||
_modifiers.Remove(modifier);
|
||||
}
|
||||
|
||||
public void RemoveBySource(BaseObject source)
|
||||
{
|
||||
_modifiers.RemoveAll(m => m.source == source);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user