2025-01-08 01:48:54 +08:00

57 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Entity
{
public class Quest : BaseEntity
{
public string Description { get; set; } = "";
public int EstimatedMinutes { get; set; } = 0;
public QuestState Status { get; set; } = 0;
public int CharacterIndex { get; set; } = 0;
public Dictionary<string, int> Awards { get; set; } = [];
public DateTime? StartTime { get; set; } = null;
public DateTime? SettleTime { get; set; } = null;
public QuestType QuestType { get; set; } = QuestType.Continuous;
public int Progress { get; set; } = 0;
public int MaxProgress { get; set; } = 100;
public override string ToString()
{
string progressString = "";
if (QuestType == QuestType.Progressive)
{
progressString = $"\r\n当前进度{Progress}/{MaxProgress}";
}
return $"{Id}. {Name}\r\n" +
$"{Description}\r\n" +
(QuestType == QuestType.Continuous ? $"需要时间:{EstimatedMinutes} 分钟\r\n" : "") +
(StartTime.HasValue ? $"开始时间:{StartTime.Value.ToString(General.GeneralDateTimeFormatChinese)}" +
(Status == QuestState.InProgress && QuestType == QuestType.Continuous ?
$"\r\n预计在 {Math.Max(Math.Round((StartTime.Value.AddMinutes(EstimatedMinutes) - DateTime.Now).TotalMinutes, MidpointRounding.ToPositiveInfinity), 1)} 分钟后完成" : "")
+ "\r\n"
: "") +
$"完成奖励:{string.Join("", Awards.Select(kv => kv.Key + " * " + kv.Value))}\r\n" +
$"任务状态:{GetStatus()}" + progressString +
(SettleTime.HasValue ? $"\r\n结算时间{SettleTime.Value.ToString(General.GeneralDateTimeFormatChinese)}" : "");
}
private string GetStatus()
{
return Status switch
{
QuestState.InProgress => "进行中",
QuestState.Completed => "已完成",
QuestState.Settled => "已结算",
_ => "未开始"
};
}
public override bool Equals(IBaseEntity? other)
{
return other is Quest && other.Id == Id;
}
}
}