using System.Collections.Generic;

namespace Nox.Game {
    public class PartyCreatorModel {
        private readonly ICharacterFactory characterFactory;
        private readonly IPartyFactory partyFactory;
        private readonly DefaultPartySettings defaultPartySettings;
        public PartyCreatorModel(ICharacterFactory characterFactory, IPartyFactory partyFactory, DefaultPartySettings defaultPartySettings) {
            this.characterFactory = characterFactory;
            this.partyFactory = partyFactory;
            this.defaultPartySettings = defaultPartySettings;
        }
        public PartyDefinition CreatePartyForNewRun(int companionCount) {
            var protagonist = characterFactory.CreateCustomProtagonist(new CustomCharacterCreationRequest {
                Name = "John Doe",
                Attributes = new EntityAttributes {
                    attributes = new[] {
                        new Attribute(AttributeType.Might, 3),
                        new Attribute(AttributeType.Reflex, 3),
                        new Attribute(AttributeType.Knowledge, 3),
                        new Attribute(AttributeType.Perception, 3)
                    }
                }
            });

            var rookAttributes = new EntityAttributes {
                attributes = new[] {
                    new Attribute(AttributeType.Might, 6),
                    new Attribute(AttributeType.Knowledge, 2),
                    new Attribute(AttributeType.Perception, 2),
                    new Attribute(AttributeType.Reflex, 4)
                }
            };

            CharacterTemplate[] companionTemplates = {
                new() {
                    Name = "Rook",
                    Attributes = rookAttributes,
                    Perks = new PerksData(){
                        perks = new List<PerkDefinition>()
                    }
                }
            };

            var companions = new List<CharacterDefinition>();
            for(var i = 0; i < companionCount && i < companionTemplates.Length; i++) {
                companions.Add(characterFactory.CreateFromTemplate(companionTemplates[i], CharacterRole.Companion));
            }

            return partyFactory.Create(protagonist, companions);
        }
    }
}
