添加项目文件。
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using CommonDomain.BaseModel;
|
||||
|
||||
namespace CommonDomain;
|
||||
|
||||
public static class BattleOrderGiftProductHelper
|
||||
{
|
||||
public static void Enrich(BattleOrderConfig? battleOrder, GameConfig? gameConfig)
|
||||
{
|
||||
if (battleOrder == null || gameConfig == null) return;
|
||||
|
||||
var gifts = (battleOrder.LevelConfig ?? new List<BattleOrderConfig.BattleOrderLevelConfig>())
|
||||
.SelectMany(level =>
|
||||
(level.NormalGiftList ?? new List<GiftConfig>())
|
||||
.Concat(level.LuxuryGiftList ?? new List<GiftConfig>())
|
||||
.Concat(level.SupremeGiftList ?? new List<GiftConfig>()))
|
||||
.Concat((battleOrder.AdvanceGift ?? new List<BattleOrderConfig.AdvanceGiftConfig>())
|
||||
.SelectMany(advance => advance.GiftList ?? new List<GiftConfig>()));
|
||||
|
||||
foreach (var gift in gifts)
|
||||
EnrichGift(gift, gameConfig);
|
||||
}
|
||||
|
||||
private static void EnrichGift(GiftConfig gift, GameConfig gameConfig)
|
||||
{
|
||||
if (gift.Type != 3 || string.IsNullOrWhiteSpace(gift.OtherId)) return;
|
||||
|
||||
var number = gift.OtherId.Trim();
|
||||
var fragment = gameConfig.PropFragments?.FirstOrDefault(item => item.Number == number);
|
||||
BaseProduct? product = fragment;
|
||||
var imageUrl = fragment?.ImageUrl ?? string.Empty;
|
||||
|
||||
if (fragment != null && string.IsNullOrWhiteSpace(imageUrl))
|
||||
{
|
||||
imageUrl = gameConfig.PropConfig?
|
||||
.FirstOrDefault(item => item.Number == fragment.ProductNumber)?.ImageUrl ?? string.Empty;
|
||||
}
|
||||
|
||||
if (product == null)
|
||||
{
|
||||
product = gameConfig.PropConfig?.FirstOrDefault(item => item.Number == number);
|
||||
imageUrl = product?.ImageUrl ?? string.Empty;
|
||||
}
|
||||
|
||||
if (product == null) return;
|
||||
|
||||
gift.Product = new BaseProduct
|
||||
{
|
||||
Number = product.Number,
|
||||
Name = product.Name,
|
||||
Desc = product.Desc,
|
||||
ImageUrl = imageUrl,
|
||||
Type = product.Type,
|
||||
Level = product.Level
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user