forked from PGR/ascnet
1
0
Fork 0
ascnet/AscNet.GameServer/Commands/StageCommand.cs

75 lines
3.1 KiB
C#
Raw Normal View History

2023-11-13 12:10:02 +00:00
using AscNet.Common.MsgPack;
2023-12-10 02:22:33 +00:00
using AscNet.Common.Util;
using AscNet.Table.V2.share.fuben;
2023-11-13 12:10:02 +00:00
namespace AscNet.GameServer.Commands
{
[CommandName("stage")]
internal class StageCommand : Command
{
public StageCommand(Session session, string[] args, bool validate = true) : base(session, args, validate) { }
[Argument(0, @"^[0-9]+$|^all$", "The target stage, value is stage id or 'all'")]
string TargetStage { get; set; } = string.Empty;
public override string Help => "Modify the stage completion status of the account.";
public override void Execute()
{
if (TargetStage == "all")
{
session.stage.Stages.Clear();
2023-12-10 02:22:33 +00:00
foreach (var stageData in TableReaderV2.Parse<StageTable>())
2023-11-13 12:10:02 +00:00
{
session.stage.Stages.Add(stageData.StageId, new()
{
StageId = stageData.StageId,
StarsMark = 7,
Passed = true,
PassTimesToday = 0,
PassTimesTotal = 1,
BuyCount = 0,
Score = 0,
LastPassTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
CreateTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
BestRecordTime = 0,
LastRecordTime = 0,
BestCardIds = new List<long> { 1021001 },
LastCardIds = new List<long> { 1021001 }
});
}
session.SendPush(new NotifyStageData() { StageList = session.stage.Stages.Select(x => x.Value).ToList() });
}
else
{
2023-12-10 02:22:33 +00:00
StageTable? stageData = TableReaderV2.Parse<StageTable>().Find(x => x.StageId == int.Parse(TargetStage));
2023-11-13 12:10:02 +00:00
if (stageData is not null && !session.stage.Stages.ContainsKey(stageData.StageId))
{
StageDatum stage = new()
{
StageId = stageData.StageId,
StarsMark = 7,
Passed = true,
PassTimesToday = 0,
PassTimesTotal = 1,
BuyCount = 0,
Score = 0,
LastPassTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
CreateTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
BestRecordTime = 0,
LastRecordTime = 0,
BestCardIds = new List<long> { 1021001 },
LastCardIds = new List<long> { 1021001 }
};
session.stage.Stages.Add(stageData.StageId, stage);
session.SendPush(new NotifyStageData() { StageList = new() { stage } });
}
}
}
}
}