From 51574feaf912f911c125e2170491be7d24419f29 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 14 Mar 2024 11:49:36 +0900 Subject: [PATCH] Add test to check Dispel failes --- .Lib9c.Tests/Model/Skill/CombatTest.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.Lib9c.Tests/Model/Skill/CombatTest.cs b/.Lib9c.Tests/Model/Skill/CombatTest.cs index baca0e460c..27711d8b49 100644 --- a/.Lib9c.Tests/Model/Skill/CombatTest.cs +++ b/.Lib9c.Tests/Model/Skill/CombatTest.cs @@ -16,6 +16,7 @@ namespace Lib9c.Tests.Model.Skill public class CombatTest { private readonly TableSheets _tableSheets; + private readonly AvatarState _avatarState; private readonly Player _player; private readonly Enemy _enemy; @@ -25,7 +26,7 @@ public CombatTest() _tableSheets = new TableSheets(csv); var gameConfigState = new GameConfigState(csv[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + _avatarState = new AvatarState( default, default, 0, @@ -40,7 +41,7 @@ public CombatTest() _tableSheets.EquipmentItemSetEffectSheet); var simulator = new TestSimulator( new TestRandom(), - avatarState, + _avatarState, new List(), _tableSheets.GetSimulatorSheets()); _player.Simulator = simulator; @@ -138,16 +139,23 @@ public void Bleed() } [Theory] - [InlineData(700009, new[] { 600001 })] - [InlineData(700010, new[] { 600001, 704000 })] - public void DispelOnUse(int dispelId, int[] debuffIdList) + [InlineData(700009, 50, 1, new[] { 600001 }, new[] { 600001 })] + [InlineData(700009, 100, 0, new[] { 600001 }, new[] { 707000 })] + [InlineData(700010, 100, 0, new[] { 600001, 704000 }, new[] { 708000 })] + public void DispelOnUse(int dispelId, int chance, int seed, int[] debuffIdList, int[] expectedResult) { + var simulator = new TestSimulator( + new TestRandom(seed), + _avatarState, + new List(), + _tableSheets.GetSimulatorSheets()); var actionBuffSheet = _tableSheets.ActionBuffSheet; // Add Debuff foreach (var debuffId in debuffIdList) { - var debuff = actionBuffSheet.Values.First(bf => bf.Id == debuffId); // 600001 is bleed + var debuff = + actionBuffSheet.Values.First(bf => bf.Id == debuffId); // 600001 is bleed _player.AddBuff(BuffFactory.GetActionBuff(_player.Stats, debuff)); } @@ -160,7 +168,7 @@ public void DispelOnUse(int dispelId, int[] debuffIdList) abf => abf.SkillId == dispelId) .BuffIds.First() ); - var dispel = new BuffSkill(skillRow, 0, 100, 0, StatType.NONE); + var dispel = new BuffSkill(skillRow, 0, chance, 0, StatType.NONE); var battleStatus = dispel.Use( _player, 0, @@ -176,7 +184,7 @@ public void DispelOnUse(int dispelId, int[] debuffIdList) Assert.NotNull(battleStatus); // Remove Bleed, add Dispel Assert.Single(_player.Buffs); - Assert.Equal(dispelRow.GroupId, _player.Buffs.First().Value.BuffInfo.GroupId); + Assert.Equal(expectedResult, _player.Buffs.Values.Select(bf => bf.BuffInfo.GroupId).ToArray()); } [Fact]