Skip to content

Commit

Permalink
add unit test about vampiric
Browse files Browse the repository at this point in the history
  • Loading branch information
sonohoshi committed Dec 5, 2023
1 parent 98ed94d commit 67bcb89
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .Lib9c.Tests/Model/PlayerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,90 @@ public void GiveStun()
Assert.Contains(logList, e => e is RemoveBuffs);
Assert.Contains(logList, e => e is Nekoyume.Model.BattleStatus.NormalAttack);
}

[Fact]
public void Vampiric()
{
var defaultAttack = SkillFactory.GetV1(
_tableSheets.SkillSheet.Values.First(r => r.Id == GameConfig.DefaultAttackId),
100,
100
);

var simulator = new StageSimulator(
_random,
_avatarState,
new List<Guid>(),
null,
new List<Nekoyume.Model.Skill.Skill>(),
1,
1,
_tableSheets.StageSheet[1],
_tableSheets.StageWaveSheet[1],
false,
20,
_tableSheets.GetSimulatorSheets(),
_tableSheets.EnemySkillSheet,
_tableSheets.CostumeStatSheet,
StageSimulator.GetWaveRewards(
_random,
_tableSheets.StageSheet[1],
_tableSheets.MaterialItemSheet)
);
var player = simulator.Player;
var enemy = new Enemy(player, _tableSheets.CharacterSheet.Values.First(), 1);
player.Targets.Add(enemy);
simulator.Characters = new SimplePriorityQueue<CharacterBase, decimal>();
simulator.Characters.Enqueue(enemy, 0);
player.InitAI();
player.OverrideSkill(defaultAttack);

var actionBuffSheet = _tableSheets.ActionBuffSheet;
// force add buff 'Vampiric'
// 801000 is ActionBuff id of Vampiric
var vampiric = (Vampiric)BuffFactory.GetCustomActionBuff(
new SkillCustomField { BuffDuration = 1, BuffValue = 1 }, actionBuffSheet[801000]);
player.AddBuff(vampiric);
var row = actionBuffSheet.Values.First();
var bleed = BuffFactory.GetActionBuff(enemy.Stats, row);
player.AddBuff(bleed);
player.Tick();
player.Tick();
Assert.NotEmpty(simulator.Log);
var log = simulator.Log;
var logCount = log.Count;
var logList = log.ToList();
for (int i = 0; i < logCount; i++)
{
var currLog = logList[i];
if (currLog is Nekoyume.Model.BattleStatus.NormalAttack)
{
var nextLog = logList[i + 1];

Assert.True(nextLog is TickDamage);
}
else if (currLog is TickDamage)
{
var nextLog = logList[i + 1];
Assert.True(currLog.Character.CurrentHP > nextLog.Character.CurrentHP);
}
else if (currLog is Nekoyume.Model.BattleStatus.HealSkill healSkill)
{
Assert.Equal(vampiric.RowData.Id, healSkill.SkillId);
var healInfo = healSkill.SkillInfos.First();
var prevAttack = logList.Take(i).OfType<Nekoyume.Model.BattleStatus.NormalAttack>()
.Last();
Assert.Equal(
(int)(prevAttack.SkillInfos.First().Effect * vampiric.Percentage / 100m),
healInfo.Effect);
}
}

Assert.True(logList.Count > 0);
Assert.Contains(logList, e => e is Nekoyume.Model.BattleStatus.NormalAttack);
Assert.Contains(logList, e => e is TickDamage);
Assert.Contains(logList, e => e is RemoveBuffs);
Assert.Contains(logList, e => e is Nekoyume.Model.BattleStatus.HealSkill);
}
}
}

0 comments on commit 67bcb89

Please sign in to comment.