using LinePutScript.Converter; using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static VPet_Simulator.Core.Main; using VPet_Simulator.Core; namespace VPet_Simulator.Windows.Interface { /// /// 所有可以检查的文本格式 /// public class ICheckText { [Line(ignoreCase: true)] private int mode { get; set; } = 7; /// /// 需求状态模式 /// public ModeType Mode { get => (ModeType)mode; set => mode = (int)value; } /// /// 宠物状态模式 /// [Flags] public enum ModeType { /// /// 高兴 /// Happy = 1, /// /// 普通 /// Nomal = 2, /// /// 状态不佳 /// PoorCondition = 4, /// /// 生病(躺床) /// Ill = 8 } /// /// 好感度要求:最小值 /// [Line(IgnoreCase = true)] public double LikeMin { get; set; } = 0; /// /// 好感度要求:最大值 /// [Line(IgnoreCase = true)] public double LikeMax { get; set; } = int.MaxValue; /// /// 健康度要求:最小值 /// [Line(IgnoreCase = true)] public double HealthMin { get; set; } = 0; /// /// 健康度要求:最大值 /// [Line(IgnoreCase = true)] public double HealthMax { get; set; } = int.MaxValue; /// /// 等级要求:最小值 /// [Line(IgnoreCase = true)] public double LevelMin { get; set; } = 0; /// /// 等级要求:最大值 /// [Line(IgnoreCase = true)] public double LevelMax { get; set; } = int.MaxValue; /// /// 金钱要求:最小值 /// [Line(IgnoreCase = true)] public double MoneyMin { get; set; } = int.MinValue; /// /// 金钱要求:最大值 /// [Line(IgnoreCase = true)] public double MoneyMax { get; set; } = int.MaxValue; /// /// 食物要求:最小值 /// [Line(IgnoreCase = true)] public double FoodMin { get; set; } = 0; /// /// 食物要求:最大值 /// [Line(IgnoreCase = true)] public double FoodMax { get; set; } = int.MaxValue; /// /// 口渴要求:最小值 /// [Line(IgnoreCase = true)] public double DrinkMin { get; set; } = 0; /// /// 口渴要求:最大值 /// [Line(IgnoreCase = true)] public double DrinkMax { get; set; } = int.MaxValue; /// /// 心情要求:最小值 /// [Line(IgnoreCase = true)] public double FeelMin { get; set; } = 0; /// /// 心情要求:最大值 /// [Line(IgnoreCase = true)] public double FeelMax { get; set; } = int.MaxValue; /// /// 体力要求:最小值 /// [Line(IgnoreCase = true)] public double StrengthMin { get; set; } = 0; /// /// 体力要求:最大值 /// [Line(IgnoreCase = true)] public double StrengthMax { get; set; } = int.MaxValue; /// /// 说话的内容 /// [Line(IgnoreCase = true)] public string Text { get; set; } private string transText = null; /// /// 说话的内容 (翻译) /// public string TranslateText { get { if (transText == null) { transText = LocalizeCore.Translate(Text); } return transText; } set { transText = value; } } /// /// 检查部分状态是否满足需求 /// 之所以不是全部的,是因为挨个取效率太差了 public virtual bool CheckState(Main m) { if (m.Core.Save.Likability < LikeMin || m.Core.Save.Likability > LikeMax) return false; if (m.Core.Save.Health < HealthMin || m.Core.Save.Health > HealthMax) return false; if (m.Core.Save.Level < LevelMin || m.Core.Save.Level > LevelMax) return false; if (m.Core.Save.Money < MoneyMin || m.Core.Save.Money > MoneyMax) return false; if (m.Core.Save.StrengthFood < FoodMin || m.Core.Save.StrengthFood > FoodMax) return false; if (m.Core.Save.StrengthDrink < DrinkMin || m.Core.Save.StrengthDrink > DrinkMax) return false; if (m.Core.Save.Feeling < FeelMin || m.Core.Save.Feeling > FeelMax) return false; if (m.Core.Save.Strength < StrengthMin || m.Core.Save.Strength > StrengthMax) return false; return true; } /// /// 将文本转换成实际值 /// public string ConverText(Main m) => ConverText(TranslateText, m); /// /// 将文本转换成实际值 /// public static string ConverText(string text, Main m) { if (text.Contains('{') && text.Contains('}')) { return text.Replace("{name}", m.Core.Save.Name).Replace("{food}", m.Core.Save.StrengthFood.ToString("f0")) .Replace("{drink}", m.Core.Save.StrengthDrink.ToString("f0")).Replace("{feel}", m.Core.Save.Feeling.ToString("f0")). Replace("{strength}", m.Core.Save.Strength.ToString("f0")).Replace("{money}", m.Core.Save.Money.ToString("f0")) .Replace("{level}", m.Core.Save.Level.ToString("f0")).Replace("{health}", m.Core.Save.Health.ToString("f0")); } else return text; } } }