using LinePutScript.Converter;
using LinePutScript.Localization.WPF;
using Panuon.WPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using VPet_Simulator.Core;
using static LinePutScript.Converter.LPSConvert;
namespace VPet_Simulator.Windows.Interface
{
public class Food : NotifyPropertyChangedBase, IFood
{
///
/// 食物类型
///
public enum FoodType
{
///
/// 食物 (默认)
///
Food,
///
/// 收藏 (自定义)
///
Star,
///
/// 正餐
///
Meal,
///
/// 零食
///
Snack,
///
/// 饮料
///
Drink,
///
/// 功能性
///
Functional,
///
/// 药品
///
Drug,
///
/// 礼品 (没做)
///
Gift,
}
///
/// 食物类型
///
[Line(type: ConvertType.ToEnum, ignoreCase: true)]
public FoodType Type { get; set; } = FoodType.Food;
///
/// 食物名字
///
[Line(name: "name")]
public string Name { get; set; }
private string transname = null;
///
/// 食物名字 (翻译)
///
public string TranslateName
{
get
{
if (transname == null)
{
transname = LocalizeCore.Translate(Name);
}
return transname;
}
}
[Line(ignoreCase: true)]
public int Exp { get; set; }
[Line(ignoreCase: true)]
public double Strength { get; set; }
[Line(ignoreCase: true)]
public double StrengthFood { get; set; }
[Line(ignoreCase: true)]
public double StrengthDrink { get; set; }
[Line(ignoreCase: true)]
public double Feeling { get; set; }
[Line(ignoreCase: true)]
public double Health { get; set; }
[Line(ignoreCase: true)]
public double Likability { get; set; }
///
/// 食物价格
///
[Line(ignoreCase: true)]
public double Price { get; set; }
///
/// 描述
///
[Line(ignoreCase: true)]
public string Desc { get; set; }
private string desc = null;
///
/// 描述(ToBetterBuy)
///
public string Description
{
get
{
if (desc == null)
{
StringBuilder sb = new StringBuilder();
if (Exp != 0)
sb.Append(LocalizeCore.Translate("经验值") + ":\t").Append(Exp > 0 ? "+" : "").Append(Exp.ToString("f2")).AppendLine();
if (StrengthFood != 0) sb.Append(LocalizeCore.Translate("饱腹度") + ":\t").Append(StrengthFood > 0 ? "+" : "").Append(StrengthFood.ToString("f2")).Append("\t\t");
if (StrengthDrink != 0) sb.Append(LocalizeCore.Translate("口渴度") + ":\t").Append(StrengthDrink > 0 ? "+" : "").Append(StrengthDrink.ToString("f2")).AppendLine();
if (Strength != 0) sb.Append(LocalizeCore.Translate("体力") + ":\t").Append(Strength > 0 ? "+" : "").Append(Strength.ToString("f2")).Append("\t\t");
if (Feeling != 0)
sb.Append("心情".Translate() + ":\t").Append(Feeling > 0 ? "+" : "").Append(Feeling.ToString("f2")).AppendLine();
if (Health != 0)
sb.Append("健康".Translate() + ":\t").Append(Health > 0 ? "+" : "").Append(Health.ToString("f2")).Append("\t\t");
if (Likability != 0)
sb.Append("好感度".Translate() + ":\t").Append(Likability > 0 ? "+" : "").Append(Likability.ToString("f2"));
sb.AppendLine().Append(Desc.Translate());
desc = sb.ToString();
}
DateTime now = DateTime.Now;
DateTime eattime = imw.Set.PetData.GetDateTime("buytime_" + Name, now);
double eattimes = 0;
string descs;
if (eattime <= now)
{
if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink)
descs = "腻味程度".Translate();
}
else
{
eattimes = (eattime - now).TotalHours;
}
return desc;
}
}
///
/// 显示的图片
///
public ImageSource ImageSource { get; set; }
///
/// 是否已收藏
///
public bool Star { get; set; }
///
/// 物品图片
///
[Line(ignoreCase: true)]
public string Image;
private IMainWindow imw;
///
/// 加载物品图片
///
public void LoadImageSource(IMainWindow imw)
{
ImageSource = imw.ImageSources.FindImage(Image ?? Name, "food");
Star = imw.Set["betterbuy"]["star"].GetInfos().Contains(Name);
this.imw = imw;
}
}
}