更新任务类

This commit is contained in:
yeziuku 2024-12-31 18:19:20 +08:00 committed by GitHub
parent 0416f4de9e
commit 309844997e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,22 +1,36 @@
namespace Milimoe.FunGame.Core.Entity
using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Entity
{
public class Quest()
public class Quest : BaseEntity
{
public int Id { get; set; } = 0;
public string Name { get; set; } = "";
public string Description { get; set; } = "";
public int EstimatedMinutes { get; set; } = 0;
public int 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 override string ToString()
{
return $"{Id}. {Name}\r\n" +
$"{Description}\r\n" +
$"需要时间:{EstimatedMinutes} 分钟\r\n" +
$"奖励:{string.Join("", Awards.Select(kv=> kv.Key + " * " + kv.Value))}\r\n" +
$"是否完成:{GetStatus()}";
(StartTime.HasValue ? $"开始时间:{StartTime.Value.ToString(General.GeneralDateTimeFormatChinese)}" +
(Status == 1 ?
$"\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()}" +
(SettleTime.HasValue ? $"\r\n结算时间{SettleTime.Value.ToString(General.GeneralDateTimeFormatChinese)}" : "");
}
public string GetIdName()
{
return Id + "." + Name;
}
private string GetStatus()
@ -29,5 +43,10 @@
_ => "未开始"
};
}
public override bool Equals(IBaseEntity? other)
{
return other is Quest && other.Id == Id;
}
}
}