Skip to content

Commit

Permalink
主人称呼功能(未完成) #291
Browse files Browse the repository at this point in the history
  • Loading branch information
LorisYounger committed Apr 20, 2024
1 parent 9808de0 commit 934595b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions VPet-Simulator.Core/Handle/GameSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class GameSave : IGameSave
/// </summary>
[Line(name: "name")]
public string Name { get; set; }
public string HostName { get; set; }

/// <summary>
/// 金钱
Expand Down
5 changes: 4 additions & 1 deletion VPet-Simulator.Core/Handle/IGameSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public interface IGameSave
/// 宠物名字
/// </summary>
string Name { get; set; }

/// <summary>
/// 主人称呼
/// </summary>
string HostName { get; set; }
/// <summary>
/// 金钱
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions VPet-Simulator.Windows.Interface/GameSave_VPet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class GameSave_VPet : IGameSave
/// </summary>
[Line(name: "name")]
public string Name { get; set; }
public string HostName { get; set; }

/// <summary>
/// 金钱
Expand Down
20 changes: 0 additions & 20 deletions VPet-Simulator.Windows.Interface/Mod/ICheckText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,5 @@ public virtual bool CheckState(IGameSave save)
/// 检查部分状态是否满足需求
/// </summary>之所以不是全部的,是因为挨个取效率太差了
public virtual bool CheckState(Main m) => CheckState(m.Core.Save);

/// <summary>
/// 将文本转换成实际值
/// </summary>
public string ConverText(Main m) => ConverText(TranslateText, m);
/// <summary>
/// 将文本转换成实际值
/// </summary>
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;
}
}
}
22 changes: 22 additions & 0 deletions VPet-Simulator.Windows.Interface/Mod/IText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using LinePutScript.Localization.WPF;
using System;
using System.Linq;
using VPet_Simulator.Core;

namespace VPet_Simulator.Windows.Interface;

Expand Down Expand Up @@ -47,4 +48,25 @@ public string Tag
/// </summary>
public bool FindTag(string[] tags) => tags.Any(tag => this.tags.Contains(tag));


/// <summary>
/// 将文本转换成实际值
/// </summary>
public string ConverText(Main m) => ConverText(TranslateText, m);
/// <summary>
/// 将文本转换成实际值
/// </summary>
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"))
.Replace("{hostname}", m.Core.Save.HostName);
}
else
return text;
}
}

0 comments on commit 934595b

Please sign in to comment.