Moar refactoring

This commit is contained in:
Sebastian Bularca
2026-03-30 01:06:02 +02:00
parent 30f319a52d
commit e7d5acac7c
10 changed files with 134 additions and 83 deletions

View File

@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Nox.Game {
public interface ICharacterStatsFactory {
EntityStats Create(EntityAttributes attributes);
EntityStats Create(IEntityDefinition entityDefinition);
}
public sealed class CharacterStatsFactory : ICharacterStatsFactory {
@@ -13,19 +14,27 @@ namespace Nox.Game {
this.characterRegistry = characterRegistry;
}
public EntityStats Create(EntityAttributes attributes) {
if(attributes.attributes.All(a => a.value != 0)) {
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() );
}
//TODO: Create stats based on attributes
var healthModifiers = modifiers.modifiers.Where(m => m.StatType == StatType.Health);
var health = stats.GetValue(StatType.Health) + attributes.GetValue(AttributeType.Might) * ResolveModifiersValue(healthModifiers, attributes);
// int maxHealth = options.baseHealth + attributes.might * options.mightHealthBonus;
// int maxStamina = options.baseStamina +
// attributes.might * options.mightStaminaBonus +
// attributes.knowledge * options.knowledgeStaminaBonus;
return new EntityStats { };
return new EntityStats {
stats = new[] {
new Stat(StatType.Health, health)
}
};
}
private int ResolveModifiersValue(IEnumerable<ModifierDefinition> healthModifiers, EntityAttributes attributes) {
throw new NotImplementedException();
}
}
}