Skip to content

Commit

Permalink
Merge pull request #2860 from planetarium/release/1.18.0
Browse files Browse the repository at this point in the history
Release/1.18.0
  • Loading branch information
sonohoshi authored Sep 27, 2024
2 parents 95968df + 5e6cea5 commit 810b1d8
Show file tree
Hide file tree
Showing 313 changed files with 17,410 additions and 4,956 deletions.
2 changes: 1 addition & 1 deletion .Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)
Address agentAddress = new PrivateKey().Address;
_avatarAddress = new PrivateKey().Address;
var agentState = new AgentState(agentAddress);
var avatarState = new AvatarState(
var avatarState = AvatarState.Create(
_avatarAddress,
agentAddress,
0,
Expand Down
29 changes: 22 additions & 7 deletions .Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public AccountStateDeltaExtensionsTest()
_agentState = new AgentState(_agentAddress);
_agentState.avatarAddresses[0] = _avatarAddress;
_tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
_avatarState = new AvatarState(
_avatarState = AvatarState.Create(
_avatarAddress,
_agentAddress,
0,
Expand Down Expand Up @@ -59,8 +59,8 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys
var random = new TestRandom();
var tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
var runeSheet = tableSheets.RuneSheet;
var materialItemSheet = tableSheets.MaterialItemSheet;
var runeCurrency = RuneHelper.ToCurrency(runeSheet[10001]);
var avatarAddress = new PrivateKey().Address;
var bossState = new WorldBossState(
tableSheets.WorldBossListSheet[1],
tableSheets.WorldBossGlobalHpSheet[1]
Expand All @@ -71,14 +71,27 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys
1,{bossId},0,10001,100
");
var killRewardSheet = new WorldBossKillRewardSheet();
killRewardSheet.Set($@"id,boss_id,rank,rune_min,rune_max,crystal
1,{bossId},0,1,1,100
killRewardSheet.Set($@"id,boss_id,rank,rune_min,rune_max,crystal,circle
1,{bossId},0,1,1,100,0
");

if (exc is null)
{
var nextState = states.SetWorldBossKillReward(context, rewardInfoAddress, rewardRecord, 0, bossState, runeWeightSheet, killRewardSheet, runeSheet, random, avatarAddress, _agentAddress);
Assert.Equal(expectedRune * runeCurrency, nextState.GetBalance(avatarAddress, runeCurrency));
var nextState = states.SetWorldBossKillReward(
context,
rewardInfoAddress,
rewardRecord,
0,
bossState,
runeWeightSheet,
killRewardSheet,
runeSheet,
materialItemSheet,
random,
_avatarState.inventory,
_avatarAddress,
_agentAddress);
Assert.Equal(expectedRune * runeCurrency, nextState.GetBalance(_avatarState.address, runeCurrency));
Assert.Equal(expectedCrystal * CrystalCalculator.CRYSTAL, nextState.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL));
var nextRewardInfo = new WorldBossKillRewardRecord((List)nextState.GetLegacyState(rewardInfoAddress));
Assert.All(nextRewardInfo, kv => Assert.True(kv.Value));
Expand All @@ -96,8 +109,10 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys
runeWeightSheet,
killRewardSheet,
runeSheet,
materialItemSheet,
random,
avatarAddress,
_avatarState.inventory,
_avatarAddress,
_agentAddress)
);
}
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AccountStateViewExtensionsTest()
_agentState = new AgentState(_agentAddress);
_agentState.avatarAddresses[0] = _avatarAddress;
_tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());
_avatarState = new AvatarState(
_avatarState = AvatarState.Create(
_avatarAddress,
_agentAddress,
0,
Expand Down
4 changes: 0 additions & 4 deletions .Lib9c.Tests/Action/ActionEvaluationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public ActionEvaluationTest()
[InlineData(typeof(TransferAsset))]
[InlineData(typeof(CreateAvatar))]
[InlineData(typeof(HackAndSlash))]
[InlineData(typeof(ActivateAccount))]
[InlineData(typeof(AddActivatedAccount))]
[InlineData(typeof(AddRedeemCode))]
[InlineData(typeof(Buy))]
[InlineData(typeof(ChargeActionPoint))]
Expand Down Expand Up @@ -157,8 +155,6 @@ private ActionBase GetAction(Type type)
StageId = 0,
AvatarAddress = new PrivateKey().Address,
},
ActivateAccount _ => new ActivateAccount(new PrivateKey().Address, new byte[] { 0x0 }),
AddActivatedAccount _ => new AddActivatedAccount(),
AddRedeemCode _ => new AddRedeemCode
{
redeemCsv = "csv",
Expand Down
83 changes: 0 additions & 83 deletions .Lib9c.Tests/Action/ActivateAccountTest.cs

This file was deleted.

9 changes: 4 additions & 5 deletions .Lib9c.Tests/Action/ActivateCollectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ public ActivateCollectionTest()

_avatarAddress = _agentAddress.Derive("avatar");
var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]);
var avatarState = new AvatarState(
var avatarState = AvatarState.Create(
_avatarAddress,
_agentAddress,
0,
_tableSheets.GetAvatarSheets(),
default
)
{
level = 100,
};
);
avatarState.level = 100;

agentState.avatarAddresses.Add(0, _avatarAddress);

_initialState = new World(MockUtil.MockModernWorldState)
Expand Down
69 changes: 0 additions & 69 deletions .Lib9c.Tests/Action/AddActivatedAccountTest.cs

This file was deleted.

63 changes: 42 additions & 21 deletions .Lib9c.Tests/Action/AdventureBoss/ClaimAdventureBossRewardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ public class ClaimAdventureBossRewardTest
private static readonly Address WantedAvatarAddress =
Addresses.GetAvatarAddress(WantedAddress, 0);

private static readonly AvatarState WantedAvatarState = new (
WantedAvatarAddress, WantedAddress, 0L, TableSheets.GetAvatarSheets(),
new PrivateKey().Address, name: "wanted"
private static readonly AvatarState WantedAvatarState = AvatarState.Create(
WantedAvatarAddress,
WantedAddress,
0L,
TableSheets.GetAvatarSheets(),
new PrivateKey().Address,
name: "wanted"
);

private static readonly AgentState WantedState = new (WantedAddress)
Expand All @@ -58,9 +62,13 @@ public class ClaimAdventureBossRewardTest
private static readonly Address ExplorerAvatarAddress =
Addresses.GetAvatarAddress(ExplorerAddress, 0);

private static readonly AvatarState ExplorerAvatarState = new (
ExplorerAvatarAddress, ExplorerAddress, 0L, TableSheets.GetAvatarSheets(),
new PrivateKey().Address, name: "explorer"
private static readonly AvatarState ExplorerAvatarState = AvatarState.Create(
ExplorerAvatarAddress,
ExplorerAddress,
0L,
TableSheets.GetAvatarSheets(),
new PrivateKey().Address,
name: "explorer"
);

private static readonly AgentState ExplorerState = new (ExplorerAddress)
Expand All @@ -78,9 +86,13 @@ public class ClaimAdventureBossRewardTest
private static readonly Address TesterAvatarAddress =
Addresses.GetAvatarAddress(TesterAddress, 0);

private static readonly AvatarState TesterAvatarState = new (
TesterAvatarAddress, TesterAddress, 0L, TableSheets.GetAvatarSheets(),
new PrivateKey().Address, name: "Tester"
private static readonly AvatarState TesterAvatarState = AvatarState.Create(
TesterAvatarAddress,
TesterAddress,
0L,
TableSheets.GetAvatarSheets(),
new PrivateKey().Address,
name: "Tester"
);

private static readonly AgentState TesterState = new (TesterAddress)
Expand Down Expand Up @@ -169,7 +181,7 @@ public static IEnumerable<object[]> GetWantedTestData()
{
600201, 140
}, // (300*1.2) * 0.7 / 0.5 * (100/360)
{ 600202, 15 }, // (300*1.2) * 0.3 / 2 * (100/360)
{ 600202, 15 }, // (300*1.2) * 0.3 / 2 * (100/360)
{ 600203, 0 },
},
FavReward = new Dictionary<int, int>
Expand Down Expand Up @@ -442,12 +454,13 @@ public void WantedMultipleSeason()
NcgReward = 0 * NCG, // No Raffle Reward
FavReward = new Dictionary<int, int>
{
{ 20001, 0 },
{ 30001, 0 },
{ 10035, 84 }, // 100NCG * 1.2 * 0.7 Fixed / 1 NCG Ratio * 100% contribution for season 3
},
ItemReward = new Dictionary<int, int>
{
{ 600201, 336 },
{ 600201, 168 }, // 100NCG * 1.2 * 0.7 Fixed / 0.5 Ratio for season 1
// 100NCG * 1.2 * 0.3 Random / 2 Ratio for season 1
// 100NCG * 1.3 * 0.3 Random / 2 Ratio for season 3
{ 600202, 36 },
{ 600203, 0 },
},
Expand Down Expand Up @@ -707,14 +720,13 @@ public void ExploreMultipleSeason()
NcgReward = 40 * NCG,
FavReward = new Dictionary<int, int>
{
{ 20001, 0 },
{ 30001, 0 },
{ 10035, 40 }, // (100 AP * 0.4 Exchange / 1 Ratio * 100% contribution) for season 3
},
ItemReward = new Dictionary<int, int>
{
{
600201, 160
}, // (100 AP * 0.4 Exchange / 0.5 Ratio * 100% contribution) for season 1 and 3
600201, 80
}, // (100 AP * 0.4 Exchange / 0.5 Ratio * 100% contribution) for season 1
{ 600202, 0 },
{ 600203, 0 },
},
Expand Down Expand Up @@ -1043,16 +1055,25 @@ private void Test(IWorld world, AdventureBossGameData.ClaimableReward expectedRe
}

var inventory = world.GetInventoryV2(TesterAvatarAddress);
foreach (var item in expectedReward.ItemReward)
var materialSheet = world.GetSheet<MaterialItemSheet>();
var circleRow = materialSheet.OrderedList.First(i => i.ItemSubType == ItemSubType.Circle);
foreach (var (id, amount) in expectedReward.ItemReward)
{
var itemState = inventory.Items.FirstOrDefault(i => i.item.Id == item.Key);
if (item.Value == 0)
var itemState = inventory.Items.FirstOrDefault(i => i.item.Id == id);
if (amount == 0)
{
Assert.Null(itemState);
}
else if (id == circleRow.Id)
{
var itemCount = inventory.TryGetTradableFungibleItems(circleRow.ItemId, null, 1L, out var items)
? items.Sum(item => item.count)
: 0;
Assert.Equal(amount, itemCount);
}
else
{
Assert.Equal(item.Value, itemState!.count);
Assert.Equal(amount, itemState!.count);
}
}
}
Expand Down
Loading

0 comments on commit 810b1d8

Please sign in to comment.