Skip to content

Commit

Permalink
Dispel blocks only debuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
U-lis committed Mar 5, 2024
1 parent 02c20d7 commit 02b74c5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
37 changes: 36 additions & 1 deletion .Lib9c.Tests/Model/Skill/CombatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void DispelOnUse(int dispelId, int[] debuffIdList)
}

[Fact]
public void DispelOnDuration()
public void DispelOnDuration_Block()
{
const int actionBuffId = 708000; // Dispel with duration
var actionBuffSheet = _tableSheets.ActionBuffSheet;
Expand Down Expand Up @@ -214,6 +214,41 @@ public void DispelOnDuration()
Assert.False(battleStatus.SkillInfos.First().Affected);
}

[Fact]
public void DispelOnDuration_Affect()
{
const int actionBuffId = 708000; // Dispel with duration
var actionBuffSheet = _tableSheets.ActionBuffSheet;

// Use Dispel first
var dispel = actionBuffSheet.Values.First(bf => bf.Id == actionBuffId);
_player.AddBuff(BuffFactory.GetActionBuff(_player.Stats, dispel));
Assert.Single(_player.Buffs);

// Use Bleed
var debuffRow =
_tableSheets.SkillSheet.Values.First(bf => bf.Id == 700007); // 700007 is Focus
var debuff = new BuffSkill(debuffRow, 100, 100, 0, StatType.NONE);
var battleStatus = debuff.Use(
_player,
0,
BuffFactory.GetBuffs(
_player.Stats,
debuff,
_tableSheets.SkillBuffSheet,
_tableSheets.StatBuffSheet,
_tableSheets.SkillActionBuffSheet,
_tableSheets.ActionBuffSheet
),
false);

// Bleed should be blocked
Assert.NotNull(battleStatus);
// Add Focus without block
Assert.Equal(2, _player.Buffs.Count);
Assert.True(battleStatus.SkillInfos.First().Affected);
}

[Theory]
// Buff
[InlineData(SkillType.Buff, true)]
Expand Down
7 changes: 6 additions & 1 deletion Lib9c/Model/Skill/Skill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ public override int GetHashCode()
IEnumerable<Buff.Buff> dispelList = null;
var dispel = target.Buffs.Values.FirstOrDefault(bf => bf is Dispel);
// Defence debuff if target has dispel
if (dispel is not null)
if (dispel is not null &&
((buff is StatBuff statBuff && statBuff.RowData.Value < 0) ||
(buff is ActionBuff actionBuff &&
actionBuff.RowData.ActionBuffType is
ActionBuffType.Bleed or ActionBuffType.Stun))
)
{
if (target.Simulator.Random.Next(0, 100) < dispel.BuffInfo.Chance)
{
Expand Down

0 comments on commit 02b74c5

Please sign in to comment.