-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2450 from planetarium/feature/world-8
Feature/world 8
- Loading branch information
Showing
72 changed files
with
2,617 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
103
.Lib9c.Tests/Model/Skill/Arena/ArenaNormalAttackTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.