Skip to content

Commit

Permalink
Merge pull request #2193 from planetarium/v70.2-.3-data
Browse files Browse the repository at this point in the history
Update 70.2~70.3 Date
  • Loading branch information
longfin authored Nov 2, 2023
2 parents b77fc81 + fb9a2c0 commit bc8153e
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 534 deletions.
43 changes: 29 additions & 14 deletions .Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using Bencodex.Types;
using Lib9c.DevExtensions.Action;
using Lib9c.Tests;
using Lib9c.Tests.Action;
using Libplanet.Action.State;
using Libplanet.Crypto;
Expand All @@ -24,6 +25,7 @@ namespace Lib9c.DevExtensions.Tests.Action
public class CreateOrReplaceAvatarTest
{
private readonly IAccount _initialStates;
private readonly TableSheets _tableSheets;

public CreateOrReplaceAvatarTest()
{
Expand All @@ -36,6 +38,7 @@ public CreateOrReplaceAvatarTest()
GoldCurrencyState.Address,
new GoldCurrencyState(ncgCurrency).Serialize());
var sheets = TableSheetsImporter.ImportSheets();
_tableSheets = new TableSheets(sheets);
foreach (var (key, value) in sheets)
{
_initialStates = _initialStates.SetState(
Expand Down Expand Up @@ -69,16 +72,8 @@ public CreateOrReplaceAvatarTest()
int.MaxValue,
new[]
{
(10111000, 0),
(10111000, 21), // 21: See also EnhancementCostSheetV2.csv
(10211000, 0),
(10211000, 21),
(10311000, 0),
(10311000, 21),
(10411000, 0),
(10411000, 21),
(10511000, 0),
(10511000, 21),
(ItemSubType.Weapon, 0),
(ItemSubType.Weapon, 21), // 21: See also EnhancementCostSheetV2.csv
},
new[]
{
Expand Down Expand Up @@ -291,12 +286,22 @@ public void Serialize(
int ear,
int tail,
int level,
(int equipmentId, int level)[]? equipments,
(ItemSubType itemSubType, int level)[]? equipmentData,
(int consumableId, int count)[]? foods,
int[]? costumeIds,
(int runeId, int level)[]? runes,
(int stageId, int[] crystalRandomBuffIds)? crystalRandomBuff)
{
var equipments = new List<(int, int)>();
if (!(equipmentData is null))
{
foreach (var data in equipmentData)
{
var row = _tableSheets.EquipmentItemRecipeSheet.Values.First(r =>
r.ItemSubType == data.itemSubType);
equipments.Add((row.ResultEquipmentId, data.level));
}
}
var action = new CreateOrReplaceAvatar(
avatarIndex,
name,
Expand All @@ -305,7 +310,7 @@ public void Serialize(
ear,
tail,
level,
equipments,
equipments.ToArray(),
foods,
costumeIds,
runes,
Expand Down Expand Up @@ -348,12 +353,22 @@ public void Execute_Success(
int ear,
int tail,
int level,
(int equipmentId, int level)[]? equipments,
(ItemSubType itemSubType, int level)[]? equipmentData,
(int consumableId, int count)[]? foods,
int[]? costumeIds,
(int runeId, int level)[]? runes,
(int stageId, int[] crystalRandomBuffIds)? crystalRandomBuff)
{
var equipments = new List<(int, int)>();
if (!(equipmentData is null))
{
foreach (var data in equipmentData)
{
var row = _tableSheets.EquipmentItemRecipeSheet.Values.First(r =>
r.ItemSubType == data.itemSubType);
equipments.Add((row.ResultEquipmentId, data.level));
}
}
var agentAddr = new PrivateKey().ToAddress();
Execute(
_initialStates,
Expand All @@ -366,7 +381,7 @@ public void Execute_Success(
ear,
tail,
level,
equipments,
equipments.ToArray(),
foods,
costumeIds,
runes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using Lib9c.DevExtensions.Action.Factory;
using Lib9c.Tests;
using Nekoyume.Model.Item;
using Xunit;

namespace Lib9c.DevExtensions.Tests.Action.Factory
{
public class CreateOrReplaceAvatarFactoryTest
{
private readonly TableSheets _tableSheets;

public CreateOrReplaceAvatarFactoryTest()
{
_tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
}

[Theory]
[MemberData(
nameof(CreateOrReplaceAvatarTest.Get_Execute_Success_MemberData),
Expand All @@ -22,12 +32,23 @@ public void TryGetByBlockIndex_Success(
int ear,
int tail,
int level,
(int equipmentId, int level)[]? equipments,
(ItemSubType itemSubType, int level)[]? equipmentData,
(int consumableId, int count)[]? foods,
int[]? costumeIds,
(int runeId, int level)[]? runes,
(int stageId, int[] crystalRandomBuffIds)? crystalRandomBuff)
{
var equipments = new List<(int, int)>();
if (!(equipmentData is null))
{
foreach (var data in equipmentData)
{
var row = _tableSheets.EquipmentItemRecipeSheet.Values.First(r =>
r.ItemSubType == data.itemSubType);
equipments.Add((row.ResultEquipmentId, data.level));
}
}

var (e, r) = CreateOrReplaceAvatarFactory
.TryGetByBlockIndex(
blockIndex,
Expand All @@ -38,7 +59,7 @@ public void TryGetByBlockIndex_Success(
ear,
tail,
level,
equipments,
equipments.ToArray(),
foods,
costumeIds,
runes,
Expand Down
29 changes: 21 additions & 8 deletions .Lib9c.Tests/Action/CombinationEquipment0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,28 @@ public void ExecuteWithSubRecipe()
_avatarState.inventory.AddItem2(material, count: materialInfo.Count);
}

for (var i = 1; i < row.UnlockStage + 1; i++)
var worldSheet = _tableSheets.WorldSheet;
var worldId = 1;
foreach (var worldRow in worldSheet.OrderedList)
{
_avatarState.worldInformation.ClearStage(
1,
i,
0,
_tableSheets.WorldSheet,
_tableSheets.WorldUnlockSheet
);
if (worldRow.StageBegin <= row.UnlockStage && row.UnlockStage <= worldRow.StageEnd)
{
worldId = worldRow.Id;
}
}

for (int j = 1; j < worldId + 1; j++)
{
for (var i = 1; i < row.UnlockStage + 1; i++)
{
_avatarState.worldInformation.ClearStage(
j,
i,
0,
_tableSheets.WorldSheet,
_tableSheets.WorldUnlockSheet
);
}
}

_initialState = _initialState.SetState(_avatarAddress, _avatarState.Serialize());
Expand Down
8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/CombinationEquipmentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public CombinationEquipmentTest(ITestOutputHelper outputHelper)
// Migration AvatarState.
[InlineData(null, false, false, true, true, true, 3, 0, true, 1L, 1, null, true, false, false, false)]
// SubRecipe
[InlineData(null, true, true, true, true, false, 11, 0, true, 1L, 2, 1, true, false, false, false)]
[InlineData(null, true, true, true, true, false, 27, 0, true, 1L, 6, 376, true, false, false, false)]
// 3rd sub recipe, not Mimisbrunnr Equipment.
[InlineData(null, true, true, true, true, false, 349, 0, true, 1L, 28, 101520003, true, false, false, false)]
// Purchase CRYSTAL.
Expand All @@ -104,9 +104,9 @@ public CombinationEquipmentTest(ITestOutputHelper outputHelper)
// Arena round not found
[InlineData(null, false, false, true, true, false, 3, 0, true, 0L, 1, null, true, false, false, false)]
// UnlockEquipmentRecipe not executed.
[InlineData(typeof(FailedLoadStateException), false, true, true, true, false, 11, 0, true, 0L, 2, 1, true, false, false, false)]
[InlineData(typeof(FailedLoadStateException), false, true, true, true, false, 11, 0, true, 0L, 6, 1, true, false, false, false)]
// CRYSTAL not paid.
[InlineData(typeof(InvalidRecipeIdException), true, false, true, true, false, 11, 0, true, 0L, 2, 1, true, false, false, false)]
[InlineData(typeof(InvalidRecipeIdException), true, false, true, true, false, 11, 0, true, 0L, 6, 1, true, false, false, false)]
// AgentState not exist.
[InlineData(typeof(FailedLoadStateException), true, true, false, true, false, 3, 0, true, 0L, 1, null, true, false, false, false)]
// AvatarState not exist.
Expand All @@ -119,7 +119,7 @@ public CombinationEquipmentTest(ITestOutputHelper outputHelper)
// CombinationSlotState locked.
[InlineData(typeof(CombinationSlotUnlockException), true, true, true, true, false, 3, 0, false, 0L, 1, null, true, false, false, false)]
// Stage not cleared.
[InlineData(typeof(NotEnoughClearedStageLevelException), true, true, true, true, false, 3, 0, true, 0L, 2, null, true, false, false, false)]
[InlineData(typeof(NotEnoughClearedStageLevelException), true, true, true, true, false, 3, 0, true, 0L, 6, null, true, false, false, false)]
// Not enough material.
[InlineData(typeof(NotEnoughMaterialException), true, true, true, true, false, 3, 0, true, 0L, 1, null, false, false, false, false)]
public void Execute(
Expand Down
Loading

0 comments on commit bc8153e

Please sign in to comment.