Exemple #1
0
        public Character UpdateCharacter(Character character, CharacterUpdate update)
        {
            var updatedAllocations = mergeUpdate(character.Sheet.AttributeAllocations, update);
            var rules   = new CalculationRules(_attributesDb, _contributionsDb, updatedAllocations);
            var results = _calculationService.Calculate(rules);

            var characterSheet = new CharacterSheet
            {
                AttributeAllocations = updatedAllocations.ToList(),
                AttributeValues      = results.AttributeValues,
            };

            _characterSheetsDb.Add(characterSheet);

            character.Sheet = characterSheet;
            _charactersDb.Update(character);

            return(character);
        }
Exemple #2
0
        // TODO: create from archetype
        public Character CreateCharacter(string name, string description, IEnumerable <AttributeAllocation> allocations)
        {
            var rules   = new CalculationRules(_attributesDb, _contributionsDb, allocations);
            var results = _calculationService.Calculate(rules);

            var characterSheet = new CharacterSheet
            {
                AttributeAllocations = allocations.ToList(),
                AttributeValues      = results.AttributeValues,
            };

            var character = new Character
            {
                Name        = name,
                Description = description,
                Sheet       = characterSheet
            };

            _charactersDb.Add(character);

            return(character);
        }