Exemple #1
0
        public void UpdateSurvivalEffect_HasLesserEffectAndValueMoreThatKetValue_HasNoEffect()
        {
            //ARRANGE

            var currentEffects = new EffectCollection();

            var testedEffect = new SurvivalStatHazardEffect(SurvivalStatType.Satiety, SurvivalStatHazardLevel.Lesser);

            currentEffects.Add(testedEffect);

            var stat = new SurvivalStat(1)
            {
                Type      = SurvivalStatType.Satiety,
                KeyPoints = new[] {
                    new SurvivalStatKeyPoint {
                        Level = SurvivalStatHazardLevel.Lesser,
                        Value = 0
                    }
                }
            };



            // ACT
            PersonEffectHelper.UpdateSurvivalEffect(currentEffects, stat, stat.KeyPoints[0]);



            // ASSERT
            var factEffect = currentEffects.Items.OfType <SurvivalStatHazardEffect>()
                             .SingleOrDefault(x => x.Type == SurvivalStatType.Satiety);

            factEffect.Should().BeNull();
        }
        public void UpdateSurvivalEffect_HasMaxEffectAndValueMoreThatKeyValue_HasStrongEffect()
        {
            //ARRANGE

            const SurvivalStatType expectedSurvivalHazardType = SurvivalStatType.Satiety;

            var survivalRandomSource = CreateMaxRollsRandomSource();

            var currentEffects = new EffectCollection();

            var testedEffect = new SurvivalStatHazardEffect(expectedSurvivalHazardType,
                                                            SurvivalStatHazardLevel.Strong,
                                                            survivalRandomSource);

            currentEffects.Add(testedEffect);

            var stat = new SurvivalStat(-5, -10, 10)
            {
                Type      = expectedSurvivalHazardType,
                KeyPoints = new[] {
                    new SurvivalStatKeyPoint(SurvivalStatHazardLevel.Lesser, 5),
                    new SurvivalStatKeyPoint(SurvivalStatHazardLevel.Strong, 0),
                    new SurvivalStatKeyPoint(SurvivalStatHazardLevel.Max, -10)
                }
            };



            // ACT
            PersonEffectHelper.UpdateSurvivalEffect(currentEffects,
                                                    stat,
                                                    new[] { stat.KeyPoints[2] },
                                                    survivalRandomSource);



            // ASSERT
            var factEffect = currentEffects.Items
                             .OfType <SurvivalStatHazardEffect>()
                             .Single(x => x.Type == expectedSurvivalHazardType);

            factEffect.Level.Should().Be(SurvivalStatHazardLevel.Strong);
        }
Exemple #3
0
        public void UpdateSurvivalEffect_HasStrongEffectAndValueMoreThatKetValue_HasLesserEffect()
        {
            //ARRANGE

            const SurvivalStatType expectedSurvivalHazardType = SurvivalStatType.Satiety;

            var currentEffects = new EffectCollection();

            var testedEffect = new SurvivalStatHazardEffect(expectedSurvivalHazardType, SurvivalStatHazardLevel.Lesser);

            currentEffects.Add(testedEffect);

            var stat = new SurvivalStat(-5)
            {
                Type      = expectedSurvivalHazardType,
                KeyPoints = new[] {
                    new SurvivalStatKeyPoint {
                        Level = SurvivalStatHazardLevel.Lesser,
                        Value = 0
                    },
                    new SurvivalStatKeyPoint {
                        Level = SurvivalStatHazardLevel.Strong,
                        Value = -10
                    }
                }
            };



            // ACT
            PersonEffectHelper.UpdateSurvivalEffect(currentEffects, stat, stat.KeyPoints[1]);



            // ASSERT
            var factEffect = currentEffects.Items
                             .OfType <SurvivalStatHazardEffect>()
                             .Single(x => x.Type == expectedSurvivalHazardType);

            factEffect.Level.Should().Be(SurvivalStatHazardLevel.Lesser);
        }
        private void Stat_Changed(object sender, EventArgs e)
        {
            var stat = (SurvivalStat)sender;

            if (stat.KeySegments is null)
            {
                return;
            }

            if (_effectsModule != null)
            {
                PersonEffectHelper.UpdateSurvivalEffect(
                    _effectsModule,
                    stat,
                    stat.KeySegments,
                    _randomSource,
                    PlayerEventLogService);
            }

            DoStatChanged((SurvivalStat)sender);
        }
Exemple #5
0
 private void Survival_StatCrossKeyValue(object sender, SurvivalStatChangedEventArgs e)
 {
     PersonEffectHelper.UpdateSurvivalEffect(Effects, e.Stat, e.KeyPoints, _survivalRandomSource);
 }