public void TacticalActTest() { //ARRAGE var tacticalActScheme = new TacticalActScheme { Stats = new TacticalActStatsSubScheme { Efficient = new Range <float>(1, 2), }, Dependency = new[] { new TacticalActDependencySubScheme(default(CombatStatType), 1) } }; var combatStatsMock = new Mock <ICombatStats>(); combatStatsMock.SetupGet(x => x.Stats) .Returns(new[] { new CombatStatItem { Stat = default(CombatStatType), Value = 10 } }); var combatStats = combatStatsMock.Object; // ACT var tacticalAct = new TacticalAct(1, tacticalActScheme, combatStats); // ASSERT tacticalAct.MinEfficient.Should().Be(1); tacticalAct.MaxEfficient.Should().Be(2); }
private float CalcEfficient(float baseEfficient, TacticalActScheme scheme, float equipmentPower, ICombatStats stats) { if (stats == null) { throw new ArgumentNullException(nameof(stats)); } var sum = 0f; foreach (var dependecyItem in scheme.Dependency) { var factStat = stats.Stats.SingleOrDefault(x => x.Stat == dependecyItem.Stat); if (factStat == null) { continue; } var factStatValue = factStat.Value / 10f; var dependencyEfficient = baseEfficient * equipmentPower * factStatValue; sum += dependencyEfficient; } return((float)Math.Ceiling(sum)); }
public TacticalAct(float equipmentPower, TacticalActScheme scheme, ICombatStats stats) { Scheme = scheme; Stats = scheme.Stats; MinEfficient = CalcEfficient(Stats.Efficient.Min, scheme, equipmentPower, stats); MaxEfficient = CalcEfficient(Stats.Efficient.Max, scheme, equipmentPower, stats); }
public void SetEquipment_SetSingleEquipment_HasActs() { // ARRANGE var slotSchemes = new[] { new PersonSlotSubScheme { Types = EquipmentSlotTypes.Hand } }; var personScheme = new PersonScheme { Slots = slotSchemes }; var defaultActScheme = new TacticalActScheme { Stats = new TacticalActStatsSubScheme { Efficient = new Range <float>(1, 1) }, Dependency = new[] { new TacticalActDependencySubScheme(CombatStatType.Melee, 1) } }; var person = new HumanPerson(personScheme, defaultActScheme, null); var propScheme = new PropScheme { Equip = new TestPropEquipSubScheme { SlotTypes = new[] { EquipmentSlotTypes.Hand } } }; var tacticalActScheme = new TacticalActScheme { Stats = new TacticalActStatsSubScheme { Efficient = new Range <float>(1, 1), }, Dependency = new[] { new TacticalActDependencySubScheme(CombatStatType.Undefined, 1) } }; var equipment = new Equipment(propScheme, new[] { tacticalActScheme }); const int expectedSlotIndex = 0; // ACT person.EquipmentCarrier.SetEquipment(equipment, expectedSlotIndex); // ARRANGE person.TacticalActCarrier.Acts[0].Stats.Should().Be(tacticalActScheme.Stats); }
/// <inheritdoc /> /// <summary> /// Конструктор. /// </summary> /// <param name="propScheme"> Схема экипировки. </param> /// <param name="acts"> Действия, которые может дать эта экипировка. </param> /// <exception cref="T:System.ArgumentException"> /// Выбрасывает, если на вход подана схема, /// не содержащая характеристики экипировки <see cref="P:Zilon.Core.Schemes.PropScheme.Equip" />. /// </exception> public Equipment(PropScheme propScheme, IEnumerable <TacticalActScheme> acts) : base(propScheme) { if (propScheme.Equip == null) { throw new ArgumentException("Не корректная схема.", nameof(propScheme)); } Power = 1; if (acts != null) { Acts = acts.ToArray(); } else { Acts = new TacticalActScheme[0]; } }
public void Equipment_SchemeWithOutEquipSubScheme_NoExceptions() { // ARRANGE var scheme = new PropScheme(); var acts = new TacticalActScheme[0]; // ACT Action act = () => { var equipment = new Equipment(scheme, acts); }; // ASSERT act.Should().Throw <ArgumentException>(); }
public void Equipment_SchemeWithOutEquipSubScheme_NoExceptions() { // ARRANGE var scheme = new TestPropScheme { Equip = null //Явно указываем, что предмет не является экипировкой. }; var acts = new TacticalActScheme[0]; // ACT Action act = () => { // ReSharper disable once UnusedVariable var equipment = new Equipment(scheme, acts); }; // ASSERT act.Should().Throw <ArgumentException>(); }
public void SetEquipment_ChangeEquipment_EventRaised() { // ARRANGE var scheme = new PropScheme { Equip = new TestPropEquipSubScheme { SlotTypes = new[] { EquipmentSlotTypes.Hand } } }; var slotSchemes = new[] { new PersonSlotSubScheme { Types = EquipmentSlotTypes.Hand } }; var tacticalActScheme = new TacticalActScheme(); var equipment = new Equipment(scheme, new[] { tacticalActScheme }); const int changedSlot = 0; var carrier = new EquipmentCarrier(slotSchemes); // ACT using (var monitor = carrier.Monitor()) { carrier.SetEquipment(equipment, changedSlot); // ASSERT monitor.Should().Raise(nameof(carrier.EquipmentChanged)); } }
public HumanPerson(PersonScheme scheme, TacticalActScheme defaultActScheme, IEvolutionData evolutionData) { Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); _defaultActScheme = defaultActScheme ?? throw new ArgumentNullException(nameof(defaultActScheme)); Name = scheme.Sid; Effects = new EffectCollection(); Effects.Added += Effects_CollectionChanged; Effects.Removed += Effects_CollectionChanged; Effects.Changed += Effects_CollectionChanged; EquipmentCarrier = new EquipmentCarrier(Scheme.Slots); EquipmentCarrier.EquipmentChanged += EquipmentCarrier_EquipmentChanged; TacticalActCarrier = new TacticalActCarrier(); EvolutionData = evolutionData; if (EvolutionData != null) { EvolutionData.PerkLeveledUp += EvolutionData_PerkLeveledUp; } CombatStats = new CombatStats(); ClearCombatStats((CombatStats)CombatStats); if (EvolutionData != null) { CalcCombatStats(CombatStats, EvolutionData, Effects); } TacticalActCarrier.Acts = CalcActs(EquipmentCarrier.Equipments, CombatStats); Survival = new SurvivalData(); Survival.StatCrossKeyValue += Survival_StatCrossKeyValue; }
public HumanPerson(PersonScheme scheme, TacticalActScheme defaultScheme, IEvolutionData evolutionData, Inventory inventory) : this(scheme, defaultScheme, evolutionData) { Inventory = inventory; }
public void HumanPerson_PerkLeveledUp_StatsRecalculated() { // ARRANGE var slotSchemes = new[] { new PersonSlotSubScheme { Types = EquipmentSlotTypes.Hand } }; var personScheme = new PersonScheme { Slots = slotSchemes }; var defaultActScheme = new TacticalActScheme { Stats = new TacticalActStatsSubScheme { Efficient = new Range <float>(1, 1) }, Dependency = new[] { new TacticalActDependencySubScheme(CombatStatType.Melee, 1) } }; var perkMock = new Mock <IPerk>(); perkMock.SetupGet(x => x.CurrentLevel).Returns(new PerkLevel(0, 0)); perkMock.SetupGet(x => x.Scheme).Returns(new PerkScheme { Levels = new[] { new PerkLevelSubScheme { Rules = new [] { new PerkRuleSubScheme { Type = PersonRuleType.Ballistic, Level = PersonRuleLevel.Normal } } } } }); var perk = perkMock.Object; var evolutionDataMock = new Mock <IEvolutionData>(); evolutionDataMock.SetupGet(x => x.Perks) .Returns(new[] { perk }); var evolutionData = evolutionDataMock.Object; // ACT var person = new HumanPerson(personScheme, defaultActScheme, evolutionData); // ASSERT var testedStat = person.CombatStats.Stats.Single(x => x.Stat == CombatStatType.Ballistic); testedStat.Value.Should().Be(11); }