Skip to content

Commit

Permalink
Merge pull request #2474 from planetarium/bugfix/issue-2467
Browse files Browse the repository at this point in the history
Fix stat conversion debuff check
  • Loading branch information
ipdae authored Mar 21, 2024
2 parents 5f6ba9c + f4b5e7d commit 0c8ec46
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
62 changes: 62 additions & 0 deletions .Lib9c.Tests/Model/Skill/BuffFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,67 @@ public void Thorns()
Assert.NotNull(buff3.CustomField);
Assert.True(buff3.CustomField.Value.BuffValue > buff2.CustomField.Value.BuffValue);
}

[Theory]
[InlineData(204003, false)]
[InlineData(206002, true)]
public void IsDebuff(int buffId, bool hasCustom)
{
var player = new Player(
level: 1,
_tableSheets.CharacterSheet,
_tableSheets.CharacterLevelSheet,
_tableSheets.EquipmentItemSetEffectSheet);
var skillId = _tableSheets.SkillBuffSheet.Values.First(r => r.BuffIds.Contains(buffId)).SkillId;
var skillRow = _tableSheets.SkillSheet[skillId];
int power = hasCustom ? 0 : 100;
int statPower = hasCustom ? 250 : 0;
StatType referencedStat = hasCustom ? StatType.HP : StatType.NONE;
var skill = SkillFactory.Get(skillRow, power, 100, statPower, referencedStat);
var buffs = BuffFactory.GetBuffs(
player.Stats,
skill,
_tableSheets.SkillBuffSheet,
_tableSheets.StatBuffSheet,
_tableSheets.SkillActionBuffSheet,
_tableSheets.ActionBuffSheet,
hasCustom
);
var buff = Assert.IsType<StatBuff>(buffs.Single(r => r.BuffInfo.Id == buffId));
Assert.Equal(buff.CustomField is not null, hasCustom);
Assert.False(buff.IsBuff());
Assert.True(buff.IsDebuff());
}

[Theory]
[InlineData(102001, false)]
[InlineData(102003, true)]
public void IsBuff(int buffId, bool hasCustom)
{
var player = new Player(
level: 1,
_tableSheets.CharacterSheet,
_tableSheets.CharacterLevelSheet,
_tableSheets.EquipmentItemSetEffectSheet);
var skillId = _tableSheets.SkillBuffSheet.Values.First(r => r.BuffIds.Contains(buffId)).SkillId;
var skillRow = _tableSheets.SkillSheet[skillId];
int power = hasCustom ? 0 : 100;
int statPower = hasCustom ? 250 : 0;
StatType referencedStat = hasCustom ? StatType.ATK : StatType.NONE;
var skill = SkillFactory.Get(skillRow, power, 100, statPower, referencedStat);
var buffs = BuffFactory.GetBuffs(
player.Stats,
skill,
_tableSheets.SkillBuffSheet,
_tableSheets.StatBuffSheet,
_tableSheets.SkillActionBuffSheet,
_tableSheets.ActionBuffSheet,
hasCustom
);
var buff = Assert.IsType<StatBuff>(buffs.Single(r => r.BuffInfo.Id == buffId));
Assert.NotNull(buff.CustomField);
Assert.True(buff.IsBuff());
Assert.False(buff.IsDebuff());
}
}
}
4 changes: 2 additions & 2 deletions Lib9c/Model/Buff/StatBuff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public StatModifier GetModifier()

public override bool IsBuff()
{
return RowData.Value >= 0;
return !IsDebuff();
}

public override bool IsDebuff()
{
return RowData.Value < 0;
return RowData.Value < 0 || CustomField?.BuffValue < 0;
}

public override object Clone()
Expand Down

0 comments on commit 0c8ec46

Please sign in to comment.