Skip to content

Commit

Permalink
Merge branch 'main' of github.com:planetarium/market-service into 14-…
Browse files Browse the repository at this point in the history
…merge-main
  • Loading branch information
ipdae committed Sep 23, 2024
2 parents 90391fc + a96c32b commit 4bdf551
Show file tree
Hide file tree
Showing 13 changed files with 695 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/publish_docker_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ on:
push:
branches:
- main
- 2023q1-previewnet
- rc-*
- hotfix/*
- release/*
- feature/issue-123
- feature/custom-craft
env:
DOCKER_REPO: planetariumhq/market-service
jobs:
Expand Down
5 changes: 5 additions & 0 deletions MarketService.Response/Interface/IItemProductSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace MarketService.Response.Interface;
public interface IItemProductSchema : IProductSchema
{
public int ItemId { get; set; }
public int IconId { get; set; }
public int Grade { get; set; }
public ItemType ItemType { get; set; }
public ItemSubType ItemSubType { get; set; }
Expand All @@ -19,4 +20,8 @@ public interface IItemProductSchema : IProductSchema
public ICollection<SkillResponseModel> SkillModels { get; }
public ICollection<StatResponseModel> StatModels { get; }
public int OptionCountFromCombination { get; set; }

// Custom Crafted Equipment
public bool ByCustomCraft { get; set; }
public bool HasRandomOnlyIcon { get; set; }
}
8 changes: 6 additions & 2 deletions MarketService.Response/ItemProductResponseModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Libplanet;
using Libplanet.Crypto;
using MarketService.Response.Interface;
using Nekoyume.Model.Elemental;
Expand All @@ -20,6 +19,7 @@ public class ItemProductResponseModel : IItemProductSchema
public bool Exist { get; set; }
public bool Legacy { get; set; }
public int ItemId { get; set; }
public int IconId { get; set; }
public int Grade { get; set; }
public ItemType ItemType { get; set; }
public ItemSubType ItemSubType { get; set; }
Expand All @@ -34,5 +34,9 @@ public class ItemProductResponseModel : IItemProductSchema
public decimal UnitPrice { get; set; }
public int Crystal { get; set; }
public int CrystalPerPrice { get; set; }

// CustomCraft
public bool ByCustomCraft { get; set; }
public bool HasRandomOnlyIcon { get; set; }
}
}
}
24 changes: 17 additions & 7 deletions MarketService.Tests/RpcClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
using Libplanet.Types.Assets;
using Libplanet.Mocks;
using Libplanet.Types.Blocks;
using Libplanet.Types.Evidence;
using Libplanet.Types.Tx;
using MagicOnion;
using MagicOnion.Server;
using MarketService.Models;
Expand Down Expand Up @@ -371,7 +369,7 @@ public async Task SyncOrder_Cancel(ItemSubType itemSubType)
tradableItem = ItemFactory.CreateCostume(row, order.TradableId);
}

item = (ItemBase) tradableItem;
item = (ItemBase)tradableItem;
var blockIndex = ActionObsoleteConfig.V100080ObsoleteIndex + 1L;

var orderDigest = new OrderDigest(
Expand Down Expand Up @@ -433,7 +431,7 @@ public async Task SyncOrder_ReRegister(ItemSubType itemSubType)
itemSubType, 1);
_testService.SetOrder(order);
var item = ItemFactory.CreateItemUsable(_row, order.TradableId, 0L);
((Equipment) item).optionCountFromCombination = 1;
((Equipment)item).optionCountFromCombination = 1;
var blockIndex = ActionObsoleteConfig.V100080ObsoleteIndex + 1L;
var orderDigest = new OrderDigest(
agentAddress,
Expand Down Expand Up @@ -497,8 +495,11 @@ await _client.SyncOrder(null!, _crystalEquipmentGrindingSheet,
Assert.True(newProduct.Exist);
}

[Fact]
public async Task SyncProduct()
[Theory]
[InlineData(10151000, false, false)]
[InlineData(10151000, true, false)]
[InlineData(10120000, true, true)]
public async Task SyncProduct(int iconId, bool byCustomCraft, bool hasRandomOnlyIcon)
{
var ct = new CancellationToken();
#pragma warning disable EF1001
Expand All @@ -518,7 +519,11 @@ public async Task SyncProduct()
{
var tradableId = Guid.NewGuid();
var productId = Guid.NewGuid();
var item = ItemFactory.CreateItemUsable(_row, tradableId, 1L, i + 1);
var item = (Equipment)ItemFactory.CreateItemUsable(_row, tradableId, 1L, i + 1);
item.IconId = iconId;
item.ByCustomCraft = byCustomCraft;
item.HasRandomOnlyIcon = hasRandomOnlyIcon;

var itemProduct = new ItemProduct
{
ProductId = productId,
Expand Down Expand Up @@ -554,6 +559,10 @@ await _client.SyncProduct(null!, _crystalEquipmentGrindingSheet, _crystalMonster
Assert.True(itemProduct.CombatPoint > 0);
Assert.True(itemProduct.Level > 0);
Assert.Equal(1, itemProduct.Grade);
// If item does not have IconId, IconId is same as ItemId
Assert.Equal(iconId, itemProduct.IconId);
Assert.Equal(byCustomCraft, itemProduct.ByCustomCraft);
Assert.Equal(hasRandomOnlyIcon, itemProduct.HasRandomOnlyIcon);
}
}

Expand Down Expand Up @@ -878,6 +887,7 @@ private void SetShopStates(ItemSubType itemSubType, OrderDigest orderDigest)
{
shopState.Add(orderDigest, 0L);
}

_testService.SetState(shopAddress, shopState.Serialize());
}
}
Expand Down
6 changes: 6 additions & 0 deletions MarketService.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Types", "lib9c\.L
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Crypto", "lib9c\.Libplanet\src\Libplanet.Crypto\Libplanet.Crypto.csproj", "{BFA3CFC7-3725-4A85-B2F0-35998DFDEE32}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Mocks", "lib9c\.Libplanet\test\Libplanet.Mocks\Libplanet.Mocks.csproj", "{B49D18CA-F71C-43E4-A874-343270729F02}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -96,5 +98,9 @@ Global
{BFA3CFC7-3725-4A85-B2F0-35998DFDEE32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BFA3CFC7-3725-4A85-B2F0-35998DFDEE32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BFA3CFC7-3725-4A85-B2F0-35998DFDEE32}.Release|Any CPU.Build.0 = Release|Any CPU
{B49D18CA-F71C-43E4-A874-343270729F02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B49D18CA-F71C-43E4-A874-343270729F02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B49D18CA-F71C-43E4-A874-343270729F02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B49D18CA-F71C-43E4-A874-343270729F02}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Loading

0 comments on commit 4bdf551

Please sign in to comment.