feat(CS-P1): GM chat commands (/csstatus /csstart /csphase /cssetowner /csreset)
Some checks failed
.NET Core / build (push) Has been cancelled
Some checks failed
.NET Core / build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// <copyright file="CastleSiegePhaseChatCommandPlugIn.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
namespace MUnique.OpenMU.GameLogic.PlugIns.ChatCommands;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using MUnique.OpenMU.GameLogic.CastleSiege;
|
||||
using MUnique.OpenMU.GameLogic.PlugIns.PeriodicTasks;
|
||||
using MUnique.OpenMU.GameLogic.Views;
|
||||
using MUnique.OpenMU.Interfaces;
|
||||
using MUnique.OpenMU.PlugIns;
|
||||
|
||||
/// <summary>Forces a specific Castle Siege phase. GM only. Usage: /csphase Siege.</summary>
|
||||
[Guid("A1B2C3D4-0003-4E5F-9A0B-CA5710000003")]
|
||||
[PlugIn]
|
||||
[Display(Name = "Castle Siege Phase", Description = "GM command: /csphase <Ownership|Registration|Preparation|Siege|Settlement>")]
|
||||
[ChatCommandHelp(Command, CharacterStatus.GameMaster)]
|
||||
public class CastleSiegePhaseChatCommandPlugIn : IChatCommandPlugIn
|
||||
{
|
||||
private const string Command = "/csphase";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Key => Command;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public CharacterStatus MinCharacterStatusRequirement => CharacterStatus.GameMaster;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask HandleCommandAsync(Player player, string command)
|
||||
{
|
||||
var parts = command.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length < 2 || !Enum.TryParse<CastleSiegePhase>(parts[1], true, out var phase))
|
||||
{
|
||||
await player.InvokeViewPlugInAsync<IShowMessagePlugIn>(p => p.ShowMessageAsync("Usage: /csphase <Ownership|Registration|Preparation|Siege|Settlement>", MessageType.BlueNormal)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var context = CastleSiegeEventPlugIn.TryGetContext(player.GameContext);
|
||||
if (context is null)
|
||||
{
|
||||
await player.InvokeViewPlugInAsync<IShowMessagePlugIn>(p => p.ShowMessageAsync("Castle Siege plugin not active.", MessageType.BlueNormal)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await context.ForcePhaseAsync(phase, DateTime.UtcNow).ConfigureAwait(false);
|
||||
await player.InvokeViewPlugInAsync<IShowMessagePlugIn>(p => p.ShowMessageAsync($"Castle Siege: phase set to {phase}.", MessageType.BlueNormal)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user