public IPerson Create(string personSchemeSid, IFraction fraction) { var personScheme = _schemeService.GetScheme <IPersonScheme>(personSchemeSid); var person = new HumanPerson(personScheme, fraction); var attributes = new[] { new PersonAttribute(PersonAttributeType.PhysicalStrength, 10), new PersonAttribute(PersonAttributeType.Dexterity, 10), new PersonAttribute(PersonAttributeType.Perception, 10), new PersonAttribute(PersonAttributeType.Constitution, 10) }; var attributesModule = new AttributesModule(attributes); person.AddModule(attributesModule); var inventoryModule = new InventoryModule(); person.AddModule(inventoryModule); var equipmentModule = new EquipmentModule(personScheme.Slots); person.AddModule(equipmentModule); var сonditionModule = new ConditionsModule(); person.AddModule(сonditionModule); var evolutionModule = new EvolutionModule(_schemeService); person.AddModule(evolutionModule); var survivalModule = new HumanSurvivalModule(personScheme, _survivalRandomSource, attributesModule, сonditionModule, evolutionModule, equipmentModule); person.AddModule(survivalModule); var defaultActScheme = _schemeService.GetScheme <ITacticalActScheme>(person.Scheme.DefaultActs.First()); var defaultActSchemes = new[] { defaultActScheme }; var combatActModule = new CombatActModule( defaultActSchemes, equipmentModule, сonditionModule, evolutionModule); person.AddModule(combatActModule); var combatStatsModule = new CombatStatsModule(evolutionModule, equipmentModule); person.AddModule(combatStatsModule); var diseaseModule = new DiseaseModule(сonditionModule); person.AddModule(diseaseModule); return(person); }
public IPerson Create(string personSchemeSid) { var personScheme = _schemeService.GetScheme <IPersonScheme>(personSchemeSid); var person = new HumanPerson(personScheme); var attributeModule = RollAndAddPersonAttributesToPerson(person); var movingModule = new MovingModule(attributeModule); person.AddModule(movingModule); var inventoryModule = new InventoryModule(); person.AddModule(inventoryModule); var equipmentModule = new EquipmentModule(personScheme.Slots); person.AddModule(equipmentModule); var effectsModule = new EffectsModule(); person.AddModule(effectsModule); var evolutionModule = new EvolutionModule(_schemeService); person.AddModule(evolutionModule); RollTraitPerks(evolutionModule); var survivalModule = new HumanSurvivalModule(personScheme, _survivalRandomSource, attributeModule, effectsModule, evolutionModule, equipmentModule) { PlayerEventLogService = PlayerEventLogService }; person.AddModule(survivalModule); RollStartEquipment(inventoryModule, person); var defaultActScheme = _schemeService.GetScheme <ITacticalActScheme>(person.Scheme.DefaultAct); var combatActModule = new CombatActModule(defaultActScheme, equipmentModule, effectsModule, evolutionModule); person.AddModule(combatActModule); var combatStatsModule = new CombatStatsModule(evolutionModule, equipmentModule); person.AddModule(combatStatsModule); var diseaseModule = new DiseaseModule(); person.AddModule(diseaseModule); person.PlayerEventLogService = PlayerEventLogService; return(person); }
public void Update_AllProcess_EffectAddedAndRemoved(DiseaseSymptom[] symptoms) { if (symptoms is null) { throw new ArgumentNullException(nameof(symptoms)); } // ARRANGE var effectList = new List <IPersonEffect>(); var effectModuleMock = new Mock <IEffectsModule>(); effectModuleMock.Setup(x => x.Add(It.IsAny <IPersonEffect>())) .Callback <IPersonEffect>(x => effectList.Add(x)); effectModuleMock.Setup(x => x.Remove(It.IsAny <IPersonEffect>())) .Callback <IPersonEffect>(x => effectList.Remove(x)); effectModuleMock.SetupGet(x => x.Items).Returns(effectList); var effectModule = effectModuleMock.Object; var diseaseMock = new Mock <IDisease>(); diseaseMock.Setup(x => x.GetSymptoms()) .Returns(symptoms); diseaseMock.SetupGet(x => x.ProgressSpeed) .Returns(1f / GlobeMetrics.OneIterationLength); var disease = diseaseMock.Object; var diseaseData = new DiseaseModule(effectModule); diseaseData.Infect(disease); // ACT for (var i = 0; i < GlobeMetrics.OneIterationLength; i++) { diseaseData.Update(); } // ARRANGE var exceptedTimes = symptoms.Length; effectModuleMock.Verify(x => x.Add(It.Is <IPersonEffect>(effect => IsDeaseSymptom(effect))), Times.Exactly(exceptedTimes)); effectModuleMock.Verify(x => x.Remove(It.Is <IPersonEffect>(effect => IsDeaseSymptom(effect))), Times.Exactly(exceptedTimes)); }
public IPerson Create(string personSchemeSid, IFraction fraction) { var personScheme = SchemeService.GetScheme <IPersonScheme>(personSchemeSid); var person = new HumanPerson(personScheme, fraction); var attributeModule = RollAndAddPersonAttributesToPerson(person); var movingModule = new MovingModule(attributeModule); person.AddModule(movingModule); var inventoryModule = new InventoryModule(); person.AddModule(inventoryModule); var notNullSlots = personScheme.Slots.Select(x => x !).ToArray(); var equipmentModule = new EquipmentModule(notNullSlots); person.AddModule(equipmentModule); var effectsModule = new ConditionsModule(); person.AddModule(effectsModule); var evolutionModule = new EvolutionModule(SchemeService); person.AddModule(evolutionModule); RollTraitPerks(evolutionModule); var survivalModule = new HumanSurvivalModule(personScheme, _survivalRandomSource, attributeModule, effectsModule, evolutionModule, equipmentModule) { PlayerEventLogService = PlayerEventLogService }; person.AddModule(survivalModule); RollStartEquipment(inventoryModule, person); if (person.Scheme.DefaultActs is null) { throw new InvalidOperationException(); } var defaultActSchemes = person.Scheme.DefaultActs.Select(x => SchemeService.GetScheme <ITacticalActScheme>(x)); var combatActModule = new CombatActModule( defaultActSchemes, equipmentModule, effectsModule, evolutionModule); person.AddModule(combatActModule); var combatStatsModule = new CombatStatsModule(evolutionModule, equipmentModule); person.AddModule(combatStatsModule); var diseaseModule = new DiseaseModule(effectsModule); person.AddModule(diseaseModule); var fowModule = new FowData(); person.AddModule(fowModule); person.PlayerEventLogService = PlayerEventLogService; return(person); }