Skip to content

Commit

Permalink
Merge pull request #2450 from planetarium/feature/world-8
Browse files Browse the repository at this point in the history
Feature/world 8
  • Loading branch information
jonny-jeahyunchoi authored Mar 12, 2024
2 parents b9a271d + 5d00f8d commit c5e4eb3
Show file tree
Hide file tree
Showing 72 changed files with 2,617 additions and 316 deletions.
4 changes: 4 additions & 0 deletions .Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public UnlockEquipmentRecipeTest()
}

[Theory]
// Recipe 5 unlocks at stage 99
// Recipe 6 unlocks at stage 27
// Recipe 94 unlocks at stage 90
// Recipe 133 unlocks at stage 17
[InlineData(new[] { 6, 5 }, true, false, false, true, true, null)]
[InlineData(new[] { 6 }, true, false, false, true, true, null)]
// Unlock Belt without Armor unlock.
Expand Down
198 changes: 198 additions & 0 deletions .Lib9c.Tests/Model/Skill/Arena/ArenaCombatTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
namespace Lib9c.Tests.Model.Skill.Arena
{
using System.Collections.Generic;
using System.Linq;
using Lib9c.Tests.Action;
using Nekoyume.Arena;
using Nekoyume.Model;
using Nekoyume.Model.Buff;
using Nekoyume.Model.Skill.Arena;
using Nekoyume.Model.Stat;
using Nekoyume.Model.State;
using Xunit;

public class ArenaCombatTest
{
private const int ActionBuffId = 708000; // Dispel with duration

private readonly TableSheets _tableSheets;
private readonly AvatarState _avatar1;
private readonly AvatarState _avatar2;

private readonly ArenaAvatarState _arenaAvatar1;
private readonly ArenaAvatarState _arenaAvatar2;

public ArenaCombatTest()
{
_tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
_avatar1 = new AvatarState(
default,
default,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);
_avatar2 = new AvatarState(
default,
default,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);

_arenaAvatar1 = new ArenaAvatarState(_avatar1);
_arenaAvatar2 = new ArenaAvatarState(_avatar2);
}

[Theory]
[InlineData(700009, new[] { 600001 })]
[InlineData(700010, new[] { 600001, 704000 })]
public void DispelOnUse(int dispelId, int[] debuffIdList)
{
var arenaSheets = _tableSheets.GetArenaSimulatorSheets();
var myDigest = new ArenaPlayerDigest(_avatar1, _arenaAvatar1);
var enemyDigest = new ArenaPlayerDigest(_avatar2, _arenaAvatar2);
var simulator = new ArenaSimulator(new TestRandom());
var challenger = new ArenaCharacter(
simulator,
myDigest,
arenaSheets,
simulator.HpModifier,
new List<StatModifier>()
);
var enemy = new ArenaCharacter(
simulator,
enemyDigest,
arenaSheets,
simulator.HpModifier,
new List<StatModifier>()
);

// Add Debuff to avatar1
foreach (var debuffId in debuffIdList)
{
var debuffRow = _tableSheets.ActionBuffSheet.Values.First(bf => bf.Id == debuffId);
challenger.AddBuff(BuffFactory.GetActionBuff(challenger.Stats, debuffRow));
}

Assert.Equal(debuffIdList.Length, challenger.Buffs.Count);

// Use Dispel
var skillRow = _tableSheets.SkillSheet.Values.First(bf => bf.Id == dispelId);
var dispelRow = _tableSheets.ActionBuffSheet.Values.First(
bf => bf.Id == _tableSheets.SkillActionBuffSheet.OrderedList.First(
abf => abf.SkillId == dispelId)
.BuffIds.First()
);
var dispel = new ArenaBuffSkill(skillRow, 0, 100, 0, StatType.NONE);
dispel.Use(challenger, challenger, simulator.Turn, BuffFactory.GetBuffs(
challenger.Stats,
dispel,
_tableSheets.SkillBuffSheet,
_tableSheets.StatBuffSheet,
_tableSheets.SkillActionBuffSheet,
_tableSheets.ActionBuffSheet
));
Assert.Single(challenger.Buffs);
Assert.Equal(dispelRow.GroupId, challenger.Buffs.First().Value.BuffInfo.GroupId);
}

[Fact]
public void DispelOnDuration_Block()
{
var arenaSheets = _tableSheets.GetArenaSimulatorSheets();
var myDigest = new ArenaPlayerDigest(_avatar1, _arenaAvatar1);
var enemyDigest = new ArenaPlayerDigest(_avatar2, _arenaAvatar2);
var simulator = new ArenaSimulator(new TestRandom());
var challenger = new ArenaCharacter(
simulator,
myDigest,
arenaSheets,
simulator.HpModifier,
new List<StatModifier>()
);
var enemy = new ArenaCharacter(
simulator,
enemyDigest,
arenaSheets,
simulator.HpModifier,
new List<StatModifier>()
);

// Use Dispel first
var dispel = _tableSheets.ActionBuffSheet.Values.First(bf => bf.Id == ActionBuffId);
challenger.AddBuff(BuffFactory.GetActionBuff(challenger.Stats, dispel));
Assert.Single(challenger.Buffs);

// Use Bleed
var debuffRow =
_tableSheets.SkillSheet.Values.First(bf => bf.Id == 600001); // 600001 is bleed
var debuff = new ArenaBuffSkill(debuffRow, 100, 100, 0, StatType.NONE);
var battleStatus = debuff.Use(
enemy,
challenger,
simulator.Turn,
BuffFactory.GetBuffs(
challenger.Stats,
debuff,
_tableSheets.SkillBuffSheet,
_tableSheets.StatBuffSheet,
_tableSheets.SkillActionBuffSheet,
_tableSheets.ActionBuffSheet
)
);
Assert.Single(challenger.Buffs);
Assert.False(battleStatus.SkillInfos.First().Affected);
}

[Fact]
public void DispelOnDuration_Affect()
{
var arenaSheets = _tableSheets.GetArenaSimulatorSheets();
var myDigest = new ArenaPlayerDigest(_avatar1, _arenaAvatar1);
var enemyDigest = new ArenaPlayerDigest(_avatar2, _arenaAvatar2);
var simulator = new ArenaSimulator(new TestRandom());
var challenger = new ArenaCharacter(
simulator,
myDigest,
arenaSheets,
simulator.HpModifier,
new List<StatModifier>()
);
var enemy = new ArenaCharacter(
simulator,
enemyDigest,
arenaSheets,
simulator.HpModifier,
new List<StatModifier>()
);

// Use Dispel first
var dispel = _tableSheets.ActionBuffSheet.Values.First(bf => bf.Id == ActionBuffId);
challenger.AddBuff(BuffFactory.GetActionBuff(challenger.Stats, dispel));
Assert.Single(challenger.Buffs);

// Use Focus
var buffRow =
_tableSheets.SkillSheet.Values.First(bf => bf.Id == 700007); // 700007 is Focus
var buff = new ArenaBuffSkill(buffRow, 100, 100, 0, StatType.NONE);
var battleStatus = buff.Use(
challenger,
challenger,
simulator.Turn,
BuffFactory.GetBuffs(
challenger.Stats,
buff,
_tableSheets.SkillBuffSheet,
_tableSheets.StatBuffSheet,
_tableSheets.SkillActionBuffSheet,
_tableSheets.ActionBuffSheet
)
);
Assert.Equal(2, challenger.Buffs.Count);
Assert.True(battleStatus.SkillInfos.First().Affected);
}
}
}
68 changes: 68 additions & 0 deletions .Lib9c.Tests/Model/Skill/Arena/ArenaDoubleAttackTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace Lib9c.Tests.Model.Skill.Arena
{
using System.Collections.Generic;
using System.Linq;
using Lib9c.Tests.Action;
using Nekoyume.Arena;
using Nekoyume.Model;
using Nekoyume.Model.Buff;
using Nekoyume.Model.Skill.Arena;
using Nekoyume.Model.Stat;
using Nekoyume.Model.State;
using Xunit;

public class ArenaDoubleAttackTest
{
private readonly TableSheets _tableSheets;
private readonly AvatarState _avatar1;
private readonly AvatarState _avatar2;
private readonly ArenaAvatarState _arenaAvatar1;
private readonly ArenaAvatarState _arenaAvatar2;

public ArenaDoubleAttackTest()
{
_tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
_avatar1 = new AvatarState(
default,
default,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);
_avatar2 = new AvatarState(
default,
default,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);

_arenaAvatar1 = new ArenaAvatarState(_avatar1);
_arenaAvatar2 = new ArenaAvatarState(_avatar2);
}

[Theory]
[InlineData(100003, 0)]
[InlineData(700008, 2)]
public void DoubleAttackTest(int skillId, int expectedAttackCount)
{
var simulator = new ArenaSimulator(new TestRandom());
var myDigest = new ArenaPlayerDigest(_avatar1, _arenaAvatar1);
var enemyDigest = new ArenaPlayerDigest(_avatar2, _arenaAvatar2);
var arenaSheets = _tableSheets.GetArenaSimulatorSheets();
var challenger =
new ArenaCharacter(simulator, myDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());
var enemy =
new ArenaCharacter(simulator, enemyDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());

var skillRow = _tableSheets.SkillSheet.OrderedList.First(s => s.Id == skillId);
var skill = new ArenaDoubleAttack(skillRow, 100, 100, 0, StatType.NONE);
var used = skill.Use(challenger, enemy, simulator.Turn, new List<Buff>());
Assert.Equal(expectedAttackCount, challenger.AttackCount);
Assert.Equal(2, used.SkillInfos.Count());
Assert.True(used.SkillInfos.First().Effect <= used.SkillInfos.Last().Effect);
}
}
}
103 changes: 103 additions & 0 deletions .Lib9c.Tests/Model/Skill/Arena/ArenaNormalAttackTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
namespace Lib9c.Tests.Model.Skill.Arena
{
using System.Collections.Generic;
using System.Linq;
using Lib9c.Tests.Action;
using Nekoyume.Arena;
using Nekoyume.Model;
using Nekoyume.Model.Buff;
using Nekoyume.Model.Skill;
using Nekoyume.Model.Skill.Arena;
using Nekoyume.Model.Stat;
using Nekoyume.Model.State;
using Xunit;

public class ArenaNormalAttackTest
{
private readonly TableSheets _tableSheets;
private readonly AvatarState _avatar1;
private readonly AvatarState _avatar2;

private readonly ArenaAvatarState _arenaAvatar1;
private readonly ArenaAvatarState _arenaAvatar2;

public ArenaNormalAttackTest()
{
_tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
_avatar1 = new AvatarState(
default,
default,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);
_avatar2 = new AvatarState(
default,
default,
0,
_tableSheets.GetAvatarSheets(),
new GameConfigState(),
default
);

_arenaAvatar1 = new ArenaAvatarState(_avatar1);
_arenaAvatar2 = new ArenaAvatarState(_avatar2);
}

[Fact]
public void NormalAttack()
{
var simulator = new ArenaSimulator(new TestRandom());
var myDigest = new ArenaPlayerDigest(_avatar1, _arenaAvatar1);
var enemyDigest = new ArenaPlayerDigest(_avatar2, _arenaAvatar2);
var arenaSheets = _tableSheets.GetArenaSimulatorSheets();
var challenger =
new ArenaCharacter(simulator, myDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());
var enemy =
new ArenaCharacter(simulator, enemyDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());

var skillRow = _tableSheets.SkillSheet.OrderedList.First(s => s.Id == 100000);
var skill = new ArenaNormalAttack(skillRow, 100, 100, 0, StatType.NONE);
var used = skill.Use(challenger, enemy, simulator.Turn, new List<Buff>());
Assert.Single(used.SkillInfos);
Assert.Equal(1, challenger.AttackCount);
}

[Fact]
public void FocusSkill()
{
const int seed = 10;
var myDigest = new ArenaPlayerDigest(_avatar1, _arenaAvatar1);
var enemyDigest = new ArenaPlayerDigest(_avatar2, _arenaAvatar2);
var arenaSheets = _tableSheets.GetArenaSimulatorSheets();

// Without Focus buff
var simulator = new ArenaSimulator(new TestRandom(seed));
var challenger =
new ArenaCharacter(simulator, myDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());
var enemy =
new ArenaCharacter(simulator, enemyDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());
var skillRow = _tableSheets.SkillSheet.OrderedList.First(s => s.Id == 100000);
var skill = new ArenaNormalAttack(skillRow, 100, 100, 0, StatType.NONE);
var used = skill.Use(challenger, enemy, simulator.Turn, new List<Buff>());
Assert.Equal(0, challenger.AttackCount);

// With Focus Buff
simulator = new ArenaSimulator(new TestRandom(seed));
challenger = new ArenaCharacter(simulator, myDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());
enemy = new ArenaCharacter(simulator, enemyDigest, arenaSheets, simulator.HpModifier, new List<StatModifier>());

challenger.AddBuff(new Focus(
_tableSheets.ActionBuffSheet.OrderedList.First(s =>
s.ActionBuffType == ActionBuffType.Focus)
));
Assert.Single(challenger.ActionBuffs);

skill = new ArenaNormalAttack(skillRow, 100, 100, 0, StatType.NONE);
used = skill.Use(challenger, enemy, simulator.Turn, new List<Buff>());
Assert.Single(used.SkillInfos);
Assert.Equal(1, challenger.AttackCount);
}
}
}
Loading

0 comments on commit c5e4eb3

Please sign in to comment.