优化任务类;添加地区类

This commit is contained in:
milimoe 2025-02-04 23:05:59 +08:00
parent 342ff5b52c
commit 765c89dde6
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
3 changed files with 84 additions and 4 deletions

View File

@ -6,13 +6,18 @@ namespace Milimoe.FunGame.Core.Entity
public class Quest : BaseEntity public class Quest : BaseEntity
{ {
public string Description { get; set; } = ""; public string Description { get; set; } = "";
public int EstimatedMinutes { get; set; } = 0;
public QuestState Status { get; set; } = 0; public QuestState Status { get; set; } = 0;
public int CharacterIndex { get; set; } = 0; public long CharacterId { get; set; } = 0;
public Dictionary<string, int> Awards { get; set; } = []; public long RegionId { get; set; } = 0;
public double CreditsAward { get; set; } = 0;
public double MaterialsAward { get; set; } = 0;
public HashSet<Item> Awards { get; set; } = [];
public Dictionary<string, int> AwardsCount { get; set; } = [];
public string AwardsString { get; set; } = "";
public DateTime? StartTime { get; set; } = null; public DateTime? StartTime { get; set; } = null;
public DateTime? SettleTime { get; set; } = null; public DateTime? SettleTime { get; set; } = null;
public QuestType QuestType { get; set; } = QuestType.Continuous; public QuestType QuestType { get; set; } = QuestType.Continuous;
public int EstimatedMinutes { get; set; } = 0;
public int Progress { get; set; } = 0; public int Progress { get; set; } = 0;
public int MaxProgress { get; set; } = 100; public int MaxProgress { get; set; } = 100;
@ -24,6 +29,21 @@ namespace Milimoe.FunGame.Core.Entity
progressString = $"\r\n当前进度{Progress}/{MaxProgress}"; progressString = $"\r\n当前进度{Progress}/{MaxProgress}";
} }
List<string> awards = [];
if (CreditsAward > 0)
{
awards.Add($"{General.GameplayEquilibriumConstant.InGameCurrency} * {CreditsAward}");
}
if (MaterialsAward > 0)
{
awards.Add($"{General.GameplayEquilibriumConstant.InGameMaterial} * {MaterialsAward}");
}
foreach (Item item in Awards)
{
awards.Add($"[{ItemSet.GetQualityTypeName(item.QualityType)}|{ItemSet.GetItemTypeName(item.ItemType)}] {item.Name} * {AwardsCount[item.Name]}");
}
AwardsString = string.Join("", awards);
return $"{Id}. {Name}\r\n" + return $"{Id}. {Name}\r\n" +
$"{Description}\r\n" + $"{Description}\r\n" +
(QuestType == QuestType.Continuous ? $"需要时间:{EstimatedMinutes} 分钟\r\n" : "") + (QuestType == QuestType.Continuous ? $"需要时间:{EstimatedMinutes} 分钟\r\n" : "") +
@ -32,7 +52,7 @@ namespace Milimoe.FunGame.Core.Entity
$"\r\n预计在 {Math.Max(Math.Round((StartTime.Value.AddMinutes(EstimatedMinutes) - DateTime.Now).TotalMinutes, MidpointRounding.ToPositiveInfinity), 1)} 分钟后完成" : "") $"\r\n预计在 {Math.Max(Math.Round((StartTime.Value.AddMinutes(EstimatedMinutes) - DateTime.Now).TotalMinutes, MidpointRounding.ToPositiveInfinity), 1)} 分钟后完成" : "")
+ "\r\n" + "\r\n"
: "") + : "") +
$"完成奖励:{string.Join("", Awards.Select(kv => kv.Key + " * " + kv.Value))}\r\n" + $"完成奖励:{AwardsString}\r\n" +
$"任务状态:{GetStatus()}" + progressString + $"任务状态:{GetStatus()}" + progressString +
(SettleTime.HasValue ? $"\r\n结算时间{SettleTime.Value.ToString(General.GeneralDateTimeFormatChinese)}" : ""); (SettleTime.HasValue ? $"\r\n结算时间{SettleTime.Value.ToString(General.GeneralDateTimeFormatChinese)}" : "");
} }

48
Entity/System/Region.cs Normal file
View File

@ -0,0 +1,48 @@
using System.Text;
using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Entity
{
public class Region : BaseEntity
{
public string Description { get; set; } = "";
public HashSet<Character> Organisms { get; } = [];
public HashSet<Item> Crops { get; } = [];
public string Weather { get; set; } = "";
public int Temperature { get; set; } = 15;
public RarityType Difficulty { get; set; } = RarityType.OneStar;
public override bool Equals(IBaseEntity? other)
{
return other is Region && other.GetIdName() == GetIdName();
}
public override string ToString()
{
StringBuilder builder = new();
builder.AppendLine($"☆--- {Name} ---☆");
builder.AppendLine($"编号:{Id}");
builder.AppendLine($"天气:{Weather}");
builder.AppendLine($"温度:{Temperature} °C");
builder.AppendLine($"{Description}");
if (Organisms.Count > 0)
{
builder.AppendLine($"== 生物 ==");
builder.AppendLine(string.Join("", Organisms.Select(o => o.Name)));
}
if (Organisms.Count > 0)
{
builder.AppendLine($"== 作物 ==");
builder.AppendLine(string.Join("", Crops.Select(c => c.Name)));
}
builder.AppendLine($"探索难度:{CharacterSet.GetRarityTypeName(Difficulty)}");
return builder.ToString().Trim();
}
}
}

View File

@ -392,6 +392,18 @@ namespace Milimoe.FunGame.Core.Library.Constant
_ => "角色现在完全行动不能" _ => "角色现在完全行动不能"
}; };
} }
public static string GetRarityTypeName(RarityType type)
{
return type switch
{
RarityType.TwoStar => "★★",
RarityType.ThreeStar => "★★★",
RarityType.FourStar => "★★★★",
RarityType.FiveStar => "★★★★★",
_ => "★"
};
}
} }
public class ItemSet public class ItemSet