예제 #1
0
        public void SetEquipment_ChangeEquipment_EventRaised()
        {
            // ARRANGE
            var scheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme();

            var equipment = new Equipment(scheme, new[] { tacticalActScheme });

            const int changedSlot = 0;

            var carrier = new EquipmentModule(slotSchemes);

            // ACT
            using var monitor    = carrier.Monitor();
            carrier[changedSlot] = equipment;

            // ASSERT
            monitor.Should().Raise(nameof(carrier.EquipmentChanged));
        }
예제 #2
0
        public void SetEquipment_SetSingleEquipment_HasActs()
        {
            // ARRANGE
            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Slots = slotSchemes
            };

            var defaultActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource);

            var propScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] { EquipmentSlotTypes.Hand }
                }
            };

            var tacticalActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            var equipment = new Equipment(propScheme, new[] { tacticalActScheme });

            const int expectedSlotIndex = 0;



            // ACT

            person.EquipmentCarrier[expectedSlotIndex] = equipment;



            // ARRANGE
            person.TacticalActCarrier.Acts[0].Stats.Should().Be(tacticalActScheme.Stats);
        }
예제 #3
0
        public void SetEquipment_ChangePistolByOtherPistol_EquipmentChanged()
        {
            // ARRANGE
            var pistolScheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Ranged, PropTags.Equipment.Weapon },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var pistol2Scheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Ranged, PropTags.Equipment.Weapon },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[]
            {
                new PersonSlotSubScheme
                {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme();

            var pistol1 = new Equipment(pistolScheme, new[] { tacticalActScheme });
            var pistol2 = new Equipment(pistol2Scheme, new[] { tacticalActScheme });

            const int changedSlot = 0;

            var carrier = new EquipmentModule(slotSchemes);

            // ACT
            carrier[changedSlot] = pistol1;
            Action act = () =>
            {
                carrier[changedSlot] = pistol2;
            };

            // ASSERT
            act.Should().NotThrow();
        }
예제 #4
0
        public void SetEquipment_DualShortSwords_NoException()
        {
            // ARRANGE
            var scheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Weapon },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[]
            {
                new PersonSlotSubScheme
                {
                    Types = EquipmentSlotTypes.Hand
                },
                new PersonSlotSubScheme
                {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Range = new Range <int>(1, 1)
                }
            };

            var swordEquipment1 = new Equipment(scheme, new[] { tacticalActScheme });
            var swordEquipment2 = new Equipment(scheme, new[] { tacticalActScheme });

            const int swordSlot1 = 0;
            const int swordSlot2 = 1;

            var carrier = new EquipmentModule(slotSchemes);

            // ACT
            Action act = () =>
            {
                carrier[swordSlot1] = swordEquipment1;
                carrier[swordSlot2] = swordEquipment2;
            };

            // ASSERT
            act.Should().NotThrow <Exception>();
        }
예제 #5
0
        public void SetEquipment_DualPistols_ExceptionRaised()
        {
            // ARRANGE
            var scheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Ranged, PropTags.Equipment.Weapon },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[]
            {
                new PersonSlotSubScheme
                {
                    Types = EquipmentSlotTypes.Hand
                },
                new PersonSlotSubScheme
                {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Range = new Range <int>(1, 6)
                }
            };

            var pistolEquipment1 = new Equipment(scheme, new[] { tacticalActScheme });
            var pistolEquipment2 = new Equipment(scheme, new[] { tacticalActScheme });

            const int pistolSlot1 = 0;
            const int pistolSlot2 = 1;

            var carrier = new EquipmentModule(slotSchemes);

            // ACT
            Action act = () =>
            {
                carrier[pistolSlot1] = pistolEquipment1;
                carrier[pistolSlot2] = pistolEquipment2;
            };

            // ASSERT
            act.Should().Throw <Exception>();
        }
        public void SetEquipment_PistolAndShield2_NoException()
        {
            // ARRANGE
            var pistolScheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Weapon, PropTags.Equipment.Ranged },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var shieldScheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Shield },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                },
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Range = new Range <int>(1, 1)
                }
            };

            var pistolEquipment1 = new Equipment(pistolScheme, new[] { tacticalActScheme });
            var sheildEquipment2 = new Equipment(shieldScheme, new[] { tacticalActScheme });

            // Смена слотов относительно предыдузего теста
            const int swordSlot1 = 1;
            const int swordSlot2 = 0;

            var carrier = new EquipmentCarrier(slotSchemes);


            // ACT
            Action act = () =>
            {
                carrier[swordSlot1] = pistolEquipment1;
                carrier[swordSlot2] = sheildEquipment2;
            };


            // ASSERT
            act.Should().NotThrow <Exception>();
        }
예제 #7
0
        public void HumanPerson_EquipPropWithHungerResistance_DownPassOfSatietyDescreased()
        {
            // ARRANGE

            const int START_PERSON_HP   = 10;
            const int EXPECTED_DOWNPASS = 2;



            var personScheme = new TestPersonScheme
            {
                Hp    = START_PERSON_HP,
                Slots = new[] {
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Aux
                    }
                },

                SurvivalStats = new[]
                {
                    new TestPersonSurvivalStatSubScheme
                    {
                        Type       = PersonSurvivalStatType.Satiety,
                        MinValue   = -100,
                        MaxValue   = 100,
                        StartValue = 0
                    },

                    new TestPersonSurvivalStatSubScheme
                    {
                        Type       = PersonSurvivalStatType.Hydration,
                        MinValue   = -100,
                        MaxValue   = 100,
                        StartValue = 0
                    }
                }
            };

            var defaultAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Efficient = new Roll(6, 1)
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultAct, evolutionData, survivalRandomSource);

            var armorPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Rules = new[]
                    {
                        new PersonRule(EquipCommonRuleType.HungerResistance, PersonRuleLevel.Normal)
                    },
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Aux
                    }
                }
            };

            var satietyStat = person.Survival.Stats.SingleOrDefault(x => x.Type == SurvivalStatType.Satiety);

            var armorProp = new Equipment(armorPropScheme);



            // ACT
            person.EquipmentCarrier[0] = armorProp;



            // ASSERT
            satietyStat.DownPassRoll.Should().Be(EXPECTED_DOWNPASS);
        }
예제 #8
0
        public void HumanPerson_EquipPropWithHpBonusWithNoHalfHp_HpStays()
        {
            // ARRANGE

            const int START_PERSON_HP = 10;
            const int NORMAL_HP_BONUS = 3;

            const int EXPECTED_PERSON_HP     = 6;
            const int EXPECTED_PERSON_MAX_HP = START_PERSON_HP + NORMAL_HP_BONUS;

            var personScheme = new TestPersonScheme
            {
                Hp    = START_PERSON_HP,
                Slots = new[] {
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Body
                    }
                }
            };

            var defaultAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Efficient = new Roll(6, 1)
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultAct, evolutionData, survivalRandomSource);

            var armorPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Rules = new[]
                    {
                        new PersonRule(EquipCommonRuleType.Health, PersonRuleLevel.Normal)
                    },
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Body
                    }
                }
            };

            var armorProp = new Equipment(armorPropScheme, new ITacticalActScheme[0]);

            var hpStat = person.Survival.Stats.SingleOrDefault(x => x.Type == SurvivalStatType.Health);

            person.Survival.DecreaseStat(SurvivalStatType.Health, hpStat.Value / 2);



            // ACT
            person.EquipmentCarrier[0] = armorProp;



            // ASSERT
            hpStat.Range.Max.Should().Be(EXPECTED_PERSON_MAX_HP);
            hpStat.Value.Should().Be(EXPECTED_PERSON_HP);
        }
예제 #9
0
        public void HumanPerson_PerkLeveledUp_StatsRecalculated()
        {
            // ARRANGE

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Slots = slotSchemes
            };

            var defaultActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            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.Lesser
                            }
                        }
                    }
                }
            });
            var perk = perkMock.Object;

            var stats = new[] {
                new SkillStatItem {
                    Stat = SkillStatType.Ballistic, Value = 10
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();

            evolutionDataMock.SetupGet(x => x.Perks).Returns(new[] { perk });
            evolutionDataMock.SetupGet(x => x.Stats).Returns(stats);
            var evolutionData = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;



            // ACT
            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource);



            // ASSERT
            var testedStat = person.EvolutionData.Stats.Single(x => x.Stat == SkillStatType.Ballistic);

            testedStat.Value.Should().Be(11);
        }
예제 #10
0
        public void HumanPerson_MultipleDifferentArmor_AllArmorsInStats()
        {
            // ARRANGE

            var personScheme = new TestPersonScheme
            {
                Slots = new[] {
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Head
                    },
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Body
                    }
                }
            };

            var defaultAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Efficient = new Roll(6, 1)
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultAct, evolutionData, survivalRandomSource);

            var armorHeadPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Armors = new IPropArmorItemSubScheme[]
                    {
                        new TestPropArmorItemSubScheme {
                            Impact          = ImpactType.Kinetic,
                            ArmorRank       = 1,
                            AbsorbtionLevel = PersonRuleLevel.Lesser
                        },
                        new TestPropArmorItemSubScheme {
                            Impact          = ImpactType.Psy,
                            ArmorRank       = 10,
                            AbsorbtionLevel = PersonRuleLevel.Normal
                        }
                    },
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Head
                    }
                }
            };

            var armorBodyPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Armors = new IPropArmorItemSubScheme[]
                    {
                        new TestPropArmorItemSubScheme {
                            Impact          = ImpactType.Kinetic,
                            ArmorRank       = 18,
                            AbsorbtionLevel = PersonRuleLevel.Normal
                        }
                    },
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Body
                    }
                }
            };

            var armorHeadProp = new Equipment(armorHeadPropScheme, new ITacticalActScheme[0]);
            var armorBodyProp = new Equipment(armorBodyPropScheme, new ITacticalActScheme[0]);



            // ACT
            person.EquipmentCarrier[0] = armorHeadProp;
            person.EquipmentCarrier[1] = armorBodyProp;



            // ASSERT
            person.CombatStats.DefenceStats.Armors[0].Impact.Should().Be(ImpactType.Kinetic);
            person.CombatStats.DefenceStats.Armors[0].ArmorRank.Should().Be(1 + 9 + 6);
            person.CombatStats.DefenceStats.Armors[0].AbsorbtionLevel.Should().Be(PersonRuleLevel.Lesser);

            person.CombatStats.DefenceStats.Armors[1].Impact.Should().Be(ImpactType.Psy);
            person.CombatStats.DefenceStats.Armors[1].ArmorRank.Should().Be(10);
            person.CombatStats.DefenceStats.Armors[1].AbsorbtionLevel.Should().Be(PersonRuleLevel.Normal);
        }
예제 #11
0
        public void HumanPerson_SwordSkillsPerk_DamageOfActIsIncreased()
        {
            // ARRANGE

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Hp    = 10,
                Slots = slotSchemes
            };

            var defaultActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            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.Damage,
                                Level  = PersonRuleLevel.Absolute,
                                Params = "{\"WeaponTags\":[\"sword\"]}"
                            }
                        }
                    }
                }
            });
            var perk = perkMock.Object;

            var stats = new SkillStatItem[0];

            var evolutionDataMock = new Mock <IEvolutionData>();

            evolutionDataMock.SetupGet(x => x.Perks).Returns(new[] { perk });
            evolutionDataMock.SetupGet(x => x.Stats).Returns(stats);
            var evolutionData = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var swordScheme = new TestPropScheme
            {
                Tags  = new[] { "sword" },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] { EquipmentSlotTypes.Hand }
                }
            };

            var swordAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Effect    = TacticalActEffectType.Damage,
                    Efficient = new Roll(1, 1)
                }
            };

            var equipment = new Equipment(swordScheme, new ITacticalActScheme[] { swordAct });



            // ACT
            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource);

            person.EquipmentCarrier[0] = equipment;



            // ASSERT
            var testedAct = person.TacticalActCarrier.Acts[0];

            testedAct.Efficient.Modifiers.ResultBuff.Should().Be(10);
        }