forked from Shardstone/trail-into-darkness
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Nox.Game {
|
|
public interface ICharacterStatsFactory {
|
|
EntityStats Create(IEntityDefinition entityDefinition);
|
|
}
|
|
|
|
public sealed class CharacterStatsFactory : ICharacterStatsFactory {
|
|
private readonly CharacterRegistry characterRegistry;
|
|
|
|
public CharacterStatsFactory(CharacterRegistry characterRegistry) {
|
|
this.characterRegistry = characterRegistry;
|
|
}
|
|
|
|
public EntityStats Create(IEntityDefinition entityDefinition) {
|
|
var attributes = entityDefinition.Attributes;
|
|
var stats = entityDefinition.Stats;
|
|
var perks = entityDefinition.Perks;
|
|
var modifiers = entityDefinition.Modifiers;
|
|
|
|
if(attributes.attributes.Any(a => a.value <= 0)) {
|
|
throw new ArgumentOutOfRangeException( "attributes cannot be zero or negative.", new ArgumentException() );
|
|
}
|
|
|
|
var healthModifiers = modifiers.modifiers.Where(m => m.StatType == StatType.Health);
|
|
var health = stats.GetValue(StatType.Health) + attributes.GetValue(AttributeType.Might) * ResolveModifiersValue(healthModifiers, attributes);
|
|
|
|
return new EntityStats {
|
|
stats = new[] {
|
|
new Stat(StatType.Health, health)
|
|
}
|
|
};
|
|
}
|
|
private int ResolveModifiersValue(IEnumerable<ModifierDefinition> healthModifiers, EntityAttributes attributes) {
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|