forked from Shardstone/trail-into-darkness
Added a bunch of utilities and modfief the character data structue
This commit is contained in:
@@ -1,31 +1,25 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Nox.Game {
|
||||
public interface ICharacterStatsFactory {
|
||||
EntityStats Create(EntityAttributes attributes);
|
||||
}
|
||||
|
||||
public sealed class CharacterStatsFactoryOptions {
|
||||
public EntityStats entityStats = new EntityStats() {
|
||||
health = 10,
|
||||
stamina = 10,
|
||||
level = 1,
|
||||
experience = 0
|
||||
};
|
||||
}
|
||||
|
||||
public sealed class CharacterStatsFactory : ICharacterStatsFactory {
|
||||
private readonly CharacterStatsFactoryOptions options;
|
||||
private readonly CharacterRegistry characterRegistry;
|
||||
|
||||
public CharacterStatsFactory(CharacterStatsFactoryOptions options = null) {
|
||||
this.options = options ?? new CharacterStatsFactoryOptions();
|
||||
public CharacterStatsFactory(CharacterRegistry characterRegistry) {
|
||||
this.characterRegistry = characterRegistry;
|
||||
}
|
||||
|
||||
public EntityStats Create(EntityAttributes attributes) {
|
||||
if(attributes == null) {
|
||||
throw new ArgumentNullException(nameof(attributes));
|
||||
if(attributes.attributes.All(a => a.value != 0)) {
|
||||
throw new ArgumentOutOfRangeException( "attributes cannot be zero or negative.", new ArgumentException() );
|
||||
}
|
||||
|
||||
//TODO: Create stats based on attributes
|
||||
|
||||
// int maxHealth = options.baseHealth + attributes.might * options.mightHealthBonus;
|
||||
// int maxStamina = options.baseStamina +
|
||||
// attributes.might * options.mightStaminaBonus +
|
||||
|
||||
Reference in New Issue
Block a user