forked from Shardstone/trail-into-darkness
Work on hooking the character system into the character creation
This commit is contained in:
@@ -1,52 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
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) {
|
||||
private readonly List<CharacterCreationRequest> characterCreationRequests;
|
||||
private readonly PartySettings partySettings;
|
||||
|
||||
public PartyCreatorModel(ICharacterFactory characterFactory,
|
||||
IPartyFactory partyFactory,
|
||||
List<CharacterCreationRequest> characterCreationRequests,
|
||||
PartySettings partySettings) {
|
||||
this.characterFactory = characterFactory;
|
||||
this.partyFactory = partyFactory;
|
||||
this.defaultPartySettings = defaultPartySettings;
|
||||
this.characterCreationRequests = characterCreationRequests;
|
||||
this.partySettings = partySettings;
|
||||
}
|
||||
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));
|
||||
public PartyDefinition CreatePartyForNewRun() {
|
||||
if(characterCreationRequests.Count > partySettings.maxPartySize) {
|
||||
throw new System.ArgumentException("Too many characters requested.");
|
||||
}
|
||||
|
||||
var protagonist = characterFactory.CreateProtagonist(characterCreationRequests.Find(r => r.Role == CharacterRole.Protagonist));
|
||||
var companions = characterCreationRequests.FindAll(r => r.Role != CharacterRole.Protagonist).Select(r => characterFactory.CreateProtagonist(r));
|
||||
return partyFactory.Create(protagonist, companions);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user