-
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.
Merge pull request #769 from planetarium/feature/unlock-combination-slot
Save UnlockCombinationSlot action
- Loading branch information
Showing
12 changed files
with
4,714 additions
and
65 deletions.
There are no files selected for viewing
4,415 changes: 4,415 additions & 0 deletions
4,415
...icles.DataProvider.Executable/Migrations/20240912163112_UnlockCombinationSlot.Designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
NineChronicles.DataProvider.Executable/Migrations/20240912163112_UnlockCombinationSlot.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,64 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace NineChronicles.DataProvider.Executable.Migrations | ||
{ | ||
public partial class UnlockCombinationSlot : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "UnlockCombinationSlot", | ||
columns: table => new | ||
{ | ||
Id = table.Column<string>(type: "varchar(255)", nullable: false) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
AgentAddress = table.Column<string>(type: "varchar(255)", nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
AvatarAddress = table.Column<string>(type: "varchar(255)", nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
SlotIndex = table.Column<int>(type: "int", nullable: false), | ||
NcgCost = table.Column<decimal>(type: "decimal(65,30)", nullable: false), | ||
CrystalCost = table.Column<decimal>(type: "decimal(65,30)", nullable: false), | ||
MaterialCosts = table.Column<string>(type: "longtext", nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
BlockIndex = table.Column<long>(type: "bigint", nullable: false), | ||
Date = table.Column<DateOnly>(type: "date", nullable: false), | ||
TimeStamp = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_UnlockCombinationSlot", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_UnlockCombinationSlot_Agents_AgentAddress", | ||
column: x => x.AgentAddress, | ||
principalTable: "Agents", | ||
principalColumn: "Address"); | ||
table.ForeignKey( | ||
name: "FK_UnlockCombinationSlot_Avatars_AvatarAddress", | ||
column: x => x.AvatarAddress, | ||
principalTable: "Avatars", | ||
principalColumn: "Address"); | ||
}) | ||
.Annotation("MySql:CharSet", "utf8mb4"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_UnlockCombinationSlot_AgentAddress", | ||
table: "UnlockCombinationSlot", | ||
column: "AgentAddress"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_UnlockCombinationSlot_AvatarAddress", | ||
table: "UnlockCombinationSlot", | ||
column: "AvatarAddress"); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "UnlockCombinationSlot"); | ||
} | ||
} | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
NineChronicles.DataProvider/Store/Models/Base/BaseModel.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,21 @@ | ||
namespace NineChronicles.DataProvider.Store.Models | ||
{ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
public abstract class BaseModel | ||
{ | ||
[Key] | ||
public string? Id { get; set; } | ||
|
||
public long BlockIndex { get; set; } | ||
|
||
public string? AgentAddress { get; set; } | ||
|
||
public AgentModel? Agent { get; set; } | ||
|
||
public DateOnly Date { get; set; } | ||
|
||
public DateTimeOffset TimeStamp { get; set; } | ||
} | ||
} |
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,9 @@ | ||
namespace NineChronicles.DataProvider.Store.Models | ||
{ | ||
public interface IAvatar | ||
{ | ||
string? AvatarAddress { get; set; } | ||
|
||
AvatarModel? Avatar { get; set; } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
NineChronicles.DataProvider/Store/Models/Crafting/UnlockCombinationSlotModel.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,17 @@ | ||
namespace NineChronicles.DataProvider.Store.Models.Crafting | ||
{ | ||
public class UnlockCombinationSlotModel : BaseModel, IAvatar | ||
{ | ||
public string? AvatarAddress { get; set; } | ||
|
||
public AvatarModel? Avatar { get; set; } | ||
|
||
public int SlotIndex { get; set; } | ||
|
||
public decimal NcgCost { get; set; } | ||
|
||
public decimal CrystalCost { get; set; } | ||
|
||
public string? MaterialCosts { get; set; } | ||
} | ||
} |
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
Oops, something went wrong.