-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
NineChronicles.DataProvider/DataRendering/Crafting/UnlockCombinationSlotData.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,52 @@ | ||
namespace NineChronicles.DataProvider.DataRendering.Crafting | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Libplanet.Action.State; | ||
using Libplanet.Crypto; | ||
using Nekoyume.Action; | ||
using Nekoyume.Module; | ||
using Nekoyume.TableData; | ||
using NineChronicles.DataProvider.Store.Models.Crafting; | ||
|
||
public static class UnlockCombinationSlotData | ||
{ | ||
private const int GoldenDustId = 600201; | ||
private const int RubyDustId = 600202; | ||
|
||
public static UnlockCombinationSlotModel GetUnlockCombinationSlotInfo( | ||
IWorld prevStates, | ||
Address signer, | ||
UnlockCombinationSlot action, | ||
long blockIndex, | ||
DateTimeOffset blockTime | ||
) | ||
{ | ||
var cost = prevStates.GetSheet<UnlockCombinationSlotCostSheet>()[action.SlotIndex]; | ||
var materialCost = new List<string>(); | ||
if (cost.GoldenDustPrice > 0) | ||
{ | ||
materialCost.Add($"{GoldenDustId}:{cost.GoldenDustPrice}"); | ||
} | ||
|
||
if (cost.RubyDustPrice > 0) | ||
{ | ||
materialCost.Add($"{RubyDustId}:{cost.RubyDustPrice}"); | ||
} | ||
|
||
return new UnlockCombinationSlotModel | ||
{ | ||
Id = Guid.NewGuid().ToString(), | ||
AgentAddress = signer.ToString(), | ||
AvatarAddress = action.AvatarAddress.ToString(), | ||
SlotIndex = action.SlotIndex, | ||
NcgCost = (decimal)cost.NcgPrice, | ||
CrystalCost = cost.CrystalPrice, | ||
MaterialCosts = string.Join(",", materialCost), | ||
BlockIndex = blockIndex, | ||
Date = DateOnly.FromDateTime(blockTime.DateTime), | ||
TimeStamp = blockTime, | ||
}; | ||
} | ||
} | ||
} |
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
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