Skip to content

Commit

Permalink
Add test to check Dispel failes
Browse files Browse the repository at this point in the history
  • Loading branch information
U-lis committed Mar 14, 2024
1 parent 508a177 commit 51574fe
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .Lib9c.Tests/Model/Skill/CombatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand All @@ -40,7 +41,7 @@ public CombatTest()
_tableSheets.EquipmentItemSetEffectSheet);
var simulator = new TestSimulator(
new TestRandom(),
avatarState,
_avatarState,
new List<System.Guid>(),
_tableSheets.GetSimulatorSheets());
_player.Simulator = simulator;
Expand Down Expand Up @@ -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<System.Guid>(),
_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));
}

Expand All @@ -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,
Expand All @@ -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]
Expand Down

0 comments on commit 51574fe

Please sign in to comment.