Impl ShopGoodsExcelConfigData.json parsing

This commit is contained in:
2022-11-07 23:00:57 +08:00
parent 0c003616cb
commit c018b23913
10 changed files with 239 additions and 30 deletions

View File

@@ -0,0 +1,77 @@
/**
* Grasscutter Tools
* Copyright (C) 2022 jie65535
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
**/
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace GrasscutterTools.Game.Shop
{
public class ShopGoodsData
{
[JsonProperty("goodsId")]
public int GoodsId { get; set; }
[JsonProperty("shopType")]
public int ShopType { get; set; }
[JsonProperty("itemId")]
public int ItemId { get; set; }
[JsonProperty("itemCount")]
public int ItemCount { get; set; }
[JsonProperty("costScoin")]
public int CostScoin { get; set; }
[JsonProperty("costHcoin")]
public int CostHcoin { get; set; }
[JsonProperty("costMcion")]
public int CostMcion { get; set; }
[JsonProperty("costItems")]
public List<ItemParamData> CostItems { get; set; }
[JsonProperty("minPlayerLevel")]
public int MinPlayerLevel { get; set; }
[JsonProperty("maxPlayerLevel")]
public int MaxPlayerLevel { get; set; }
[JsonProperty("buyLimit")]
public int BuyLimit { get; set; }
[JsonProperty("subTabId")]
public int SubTabId { get; set; }
[JsonProperty("refreshType"), JsonConverter(typeof(StringEnumConverter))]
public ShopRefreshType RefreshType { get; set; }
[JsonProperty("refreshParam")]
public int RefreshParam { get; set; }
[JsonProperty("beginTime")]
public DateTime? BeginTime { get; set; }
[JsonProperty("endTime")]
public DateTime? EndTime { get; set; }
}
}

View File

@@ -16,14 +16,44 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
**/
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace GrasscutterTools.Game.Shop
{
public class ShopInfo
{
public ShopInfo()
{
}
public ShopInfo(ShopGoodsData sgd)
{
GoodsId = sgd.GoodsId;
GoodsItem = new ItemParamData(sgd.ItemId, sgd.ItemCount);
SCoin = sgd.CostScoin;
MCoin = sgd.CostMcion;
HCoin = sgd.CostHcoin;
BuyLimit = sgd.BuyLimit;
MinLevel = sgd.MinPlayerLevel;
MaxLevel = sgd.MaxPlayerLevel;
CostItemList = sgd.CostItems.Where(it => it.Id != 0).ToList();
SecondarySheetId = sgd.SubTabId;
RefreshType = sgd.RefreshType;
ShopRefreshParam = sgd.RefreshParam;
if (sgd.BeginTime != null && sgd.EndTime != null)
{
BeginTime = (int)new DateTimeOffset(sgd.BeginTime.Value).ToUnixTimeSeconds();
EndTime = (int)new DateTimeOffset(sgd.EndTime.Value).ToUnixTimeSeconds();
}
}
[JsonProperty("goodsId")]
public int GoodsId { get; set; }
@@ -79,7 +109,7 @@ namespace GrasscutterTools.Game.Shop
[JsonProperty("secondarySheetId")]
public int SecondarySheetId { get; set; }
[JsonProperty("refreshType")]
[JsonProperty("refreshType"), JsonConverter(typeof(StringEnumConverter))]
public ShopRefreshType RefreshType { get; set; }
[JsonProperty("shopRefreshParam")]

View File

@@ -1,5 +1,21 @@
using Newtonsoft.Json;
/**
* Grasscutter Tools
* Copyright (C) 2022 jie65535
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
**/
namespace GrasscutterTools.Game.Shop
{
/// <summary>
@@ -10,25 +26,21 @@ namespace GrasscutterTools.Game.Shop
/// <summary>
/// 不刷新
/// </summary>
[JsonProperty("NONE")]
None,
NONE,
/// <summary>
/// 按天刷新
/// </summary>
[JsonProperty("SHOP_REFRESH_DAILY")]
Daily,
SHOP_REFRESH_DAILY,
/// <summary>
/// 按周刷新
/// </summary>
[JsonProperty("SHOP_REFRESH_WEEKLY")]
Weekly,
SHOP_REFRESH_WEEKLY,
/// <summary>
/// 按月刷新
/// </summary>
[JsonProperty("SHOP_REFRESH_MONTHLY")]
Monthly,
SHOP_REFRESH_MONTHLY,
}
}