using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
using BetterGenshinImpact.GameTask.Common;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation.Config;
[Serializable]
public class CostItem
{
///
/// 唯一id
///
public int Id { get; set; }
///
/// 类型名
///
public string NameEn { get; set; } = string.Empty;
///
/// unaligned_element 无色元素
/// energy 充能
///
public string Type { get; set; } = string.Empty;
///
/// 消耗多少
///
public int Count { get; set; }
}
[Serializable]
public class SkillsItem
{
///
///
///
public string NameEn { get; set; } = string.Empty;
///
/// 流天射术
///
public string Name { get; set; } = string.Empty;
///
///
///
public List SkillTag { get; set; } = [];
///
///
///
public List Cost { get; set; } = [];
}
[Serializable]
public class CharacterCard
{
///
/// 唯一id
///
public int Id { get; set; }
///
///
///
public string NameEn { get; set; } = string.Empty;
///
///
///
public string Type { get; set; } = string.Empty;
///
/// 甘雨
///
public string Name { get; set; } = string.Empty;
///
///
///
public int Hp { get; set; }
///
///
///
public int Energy { get; set; }
///
/// 冰元素
///
public string Element { get; set; } = string.Empty;
///
/// 弓
///
public string Weapon { get; set; } = string.Empty;
///
///
///
public List Skills { get; set; } = [];
public static void CopyCardProperty(Character source, CharacterCard characterCard)
{
try
{
source.Element = characterCard.Element.Replace("元素", "").ChineseToElementalType();
source.Hp = characterCard.Hp;
source.Skills = new Skill[characterCard.Skills.Count + 1];
short skillIndex = 0;
for (var i = characterCard.Skills.Count - 1; i >= 0; i--)
{
var skillsItem = characterCard.Skills[i];
if (skillsItem.SkillTag.Contains("被动技能"))
{
continue;
}
skillIndex++;
source.Skills[skillIndex] = GetSkill(skillsItem);
source.Skills[skillIndex].Index = skillIndex;
}
}
catch (System.Exception e)
{
TaskControl.Logger.LogError($"角色【{characterCard.Name}】卡牌配置解析失败:{e.Message}");
throw new System.Exception($"角色【{characterCard.Name}】卡牌配置解析失败:{e.Message}。请自行进行角色定义", e);
}
}
public static Skill GetSkill(SkillsItem skillsItem)
{
Skill skill = new()
{
Name = skillsItem.Name
};
var specificElementNum = 0;
foreach (var cost in skillsItem.Cost)
{
if (cost.NameEn == "unaligned_element")
{
skill.AnyElementCost = cost.Count;
}
else if (cost.NameEn == "energy")
{
continue;
}
else
{
skill.SpecificElementCost = cost.Count;
skill.Type = cost.NameEn.ToElementalType();
specificElementNum++;
}
}
if (specificElementNum != 1)
{
throw new System.Exception($"技能[{skillsItem.Name}]默认技能数据技能解析失败");
}
skill.AllCost = skill.SpecificElementCost + skill.AnyElementCost;
return skill;
}
}