forked from Shardstone/trail-into-darkness
factored the character system - not funtional yet
This commit is contained in:
23
Assets/Code/GameState/Entities/CharacterAttributesFactory.cs
Normal file
23
Assets/Code/GameState/Entities/CharacterAttributesFactory.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace Nox.Game {
|
||||
public interface ICharacterAttributesFactory {
|
||||
EntityAttributes Create(EntityAttributes attributes);
|
||||
}
|
||||
|
||||
public sealed class CharacterAttributesFactory : ICharacterAttributesFactory {
|
||||
private readonly CharacterRegistry characterRegistry;
|
||||
|
||||
public CharacterAttributesFactory(CharacterRegistry characterRegistry) {
|
||||
this.characterRegistry = characterRegistry;
|
||||
}
|
||||
|
||||
public EntityAttributes Create(EntityAttributes attributes) {
|
||||
if(attributes.might <= 0 || attributes.reflex <= 0 || attributes.knowledge <= 0 || attributes.perception <= 0) {
|
||||
throw new ArgumentOutOfRangeException( "attributes cannot be zero or negative.", new ArgumentException() );
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user