2023-09-10 14:03:47 +00:00
|
|
|
|
using LinePutScript.Localization.WPF;
|
|
|
|
|
using System;
|
2023-08-25 21:23:30 +00:00
|
|
|
|
using System.Collections.Generic;
|
2023-09-10 14:03:47 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
2023-08-25 21:23:30 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-09-10 14:03:47 +00:00
|
|
|
|
using System.Windows;
|
2023-09-27 07:13:48 +00:00
|
|
|
|
using VPet_Simulator.Core;
|
2023-08-25 21:23:30 +00:00
|
|
|
|
using static VPet_Simulator.Core.GraphHelper;
|
|
|
|
|
|
|
|
|
|
namespace VPet_Simulator.Windows.Interface
|
|
|
|
|
{
|
|
|
|
|
public static class ExtensionFunction
|
|
|
|
|
{
|
2023-10-25 14:11:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作计算等级
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly int[] WorkCalLevel = new int[] { 1, 5, 10, 20, 30, 40, 50, 75, 100, 200 };
|
2023-08-25 21:23:30 +00:00
|
|
|
|
/// <summary>
|
2023-11-13 14:34:57 +00:00
|
|
|
|
/// 工作获取效率
|
2023-08-25 21:23:30 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="work">工作</param>
|
2023-11-13 14:34:57 +00:00
|
|
|
|
/// <returns>工作获取效率</returns>
|
|
|
|
|
public static double Get(this Work work)
|
|
|
|
|
{
|
2023-10-25 14:11:30 +00:00
|
|
|
|
double get = 0;
|
|
|
|
|
foreach (var lv in WorkCalLevel)
|
|
|
|
|
{
|
|
|
|
|
get += (work.MoneyBase + Math.Sqrt(lv) * work.MoneyLevel) * (1 + work.FinishBonus / 2);
|
|
|
|
|
}
|
|
|
|
|
get /= WorkCalLevel.Length;
|
2023-08-31 14:18:38 +00:00
|
|
|
|
if (work.Type != Work.WorkType.Work)
|
2023-08-25 21:23:30 +00:00
|
|
|
|
{
|
|
|
|
|
get /= 12;//经验值换算
|
|
|
|
|
}
|
2023-11-13 14:34:57 +00:00
|
|
|
|
return get;
|
|
|
|
|
}
|
|
|
|
|
public static double Spend(this Work work)
|
|
|
|
|
{
|
|
|
|
|
var spend = ((work.StrengthFood >= 0 ? 1 : -1) * Math.Pow(work.StrengthFood * 2 + 1, 2) / 6 +
|
|
|
|
|
(work.StrengthDrink >= 0 ? 1 : -1) * Math.Pow(work.StrengthDrink * 2 + 1, 2) / 9 +
|
|
|
|
|
(work.Feeling >= 0 ? 1 : -1) * Math.Pow((work.Type == Work.WorkType.Play ? -1 : 1) * work.Feeling * 2 + 1, 2) / 12) *
|
|
|
|
|
(Math.Pow(work.LevelLimit / 2 + 1, 0.5) / 4 + 1) - 0.5;
|
|
|
|
|
return spend;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断这个工作是否超模
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="work">工作</param>
|
|
|
|
|
/// <returns>是否超模</returns>
|
|
|
|
|
public static bool IsOverLoad(this Work work)
|
|
|
|
|
{//判断这个工作是否超模
|
|
|
|
|
if (work.FinishBonus < 0)
|
|
|
|
|
return true;
|
|
|
|
|
var spend = work.Spend();
|
|
|
|
|
var get = work.Get();
|
2023-08-25 21:23:30 +00:00
|
|
|
|
var rel = get / spend;
|
2023-09-12 05:15:22 +00:00
|
|
|
|
if (rel < 0)
|
|
|
|
|
return true;
|
2023-10-25 14:11:30 +00:00
|
|
|
|
if (Math.Abs(get) > (work.LevelLimit + 4) * 3) //等级获取速率限制
|
2023-09-13 09:29:45 +00:00
|
|
|
|
return true;
|
2023-10-25 14:11:30 +00:00
|
|
|
|
return rel > 0.75; // 推荐rel为0.5左右 超过0.75就是超模
|
2023-08-25 21:23:30 +00:00
|
|
|
|
}
|
2023-09-27 07:13:48 +00:00
|
|
|
|
|
|
|
|
|
public static string FoodToDescription(this IFood food)
|
|
|
|
|
{
|
|
|
|
|
var dic = new List<Tuple<string, double, string>>()
|
|
|
|
|
{
|
|
|
|
|
new Tuple<string, double, string>(LocalizeCore.Translate("经验值"), food.Exp, ValueToPlusPlus(food.Exp, 1 / 4, 5)),
|
|
|
|
|
new Tuple<string, double, string>(LocalizeCore.Translate("饱腹度"),food.StrengthFood, ValueToPlusPlus(food.StrengthFood, 1 / 2, 5)) ,
|
|
|
|
|
new Tuple<string, double, string>(LocalizeCore.Translate("口渴度"), food.StrengthDrink, ValueToPlusPlus(food.StrengthDrink, 1 / 2.5, 5)),
|
|
|
|
|
new Tuple<string, double, string>(LocalizeCore.Translate("体力"),food.Strength, ValueToPlusPlus(food.Strength, 1 / 4, 5)),
|
|
|
|
|
new Tuple<string, double, string>(LocalizeCore.Translate("心情"), food.Feeling, ValueToPlusPlus(food.Feeling, 1 / 3, 5)),
|
|
|
|
|
new Tuple<string, double, string>(LocalizeCore.Translate("健康"),food.Health, ValueToPlusPlus(food.Health, 1, 5)) ,
|
|
|
|
|
new Tuple<string, double, string>(LocalizeCore.Translate("好感度"),food.Likability, ValueToPlusPlus(food.Likability, 1.5, 5))
|
|
|
|
|
};
|
|
|
|
|
var dic2 = dic.Where(kv => kv.Item2 != 0)
|
|
|
|
|
.Select(x => x.Item1 + x.Item3);
|
|
|
|
|
return string.Join("\n", dic2);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 把值变成++
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">值</param>
|
|
|
|
|
/// <param name="magnification">倍率</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string ValueToPlusPlus(double value, double magnification, int max = 10)
|
|
|
|
|
{
|
|
|
|
|
int v = (int)Math.Abs(value);
|
|
|
|
|
v = (int)(Math.Pow(v, magnification));
|
|
|
|
|
v = Math.Min(Math.Max(v, 0), max);
|
|
|
|
|
if (value < 0)
|
|
|
|
|
return new string('-', v);
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
return new string('+', v);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-25 21:23:30 +00:00
|
|
|
|
}
|
2023-12-29 19:37:41 +00:00
|
|
|
|
public static partial class ExtensionValue
|
2023-09-10 14:03:47 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前运行目录
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string BaseDirectory = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName;
|
|
|
|
|
}
|
2023-09-27 07:13:48 +00:00
|
|
|
|
|
2023-08-25 21:23:30 +00:00
|
|
|
|
}
|