Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/GameLogic/IGameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public interface IGameContext
/// </summary>
IPartyManager PartyManager { get; }

/// <summary>
/// Gets the manager which hosts and tracks the mini game instances of the game.
/// </summary>
IMiniGameManager MiniGames { get; }

/// <summary>
/// Gets the initialized maps which are hosted on this context.
/// </summary>
Expand Down Expand Up @@ -160,11 +165,6 @@ public interface IGameContext
/// </returns>
ValueTask<GameMap?> GetMapAsync(ushort mapId, bool createIfNotExists = true);

/// <summary>
/// Gets the manager which hosts and tracks the mini game instances of the game.
/// </summary>
IMiniGameManager MiniGames { get; }

/// <summary>
/// Gets the player object by character name.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/GameLogic/MiniGames/Kanturu/IKanturuEventViewPlugIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface IKanturuEventViewPlugIn : IViewPlugIn
/// <param name="remainTime">
/// Remaining time. Semantics depend on state:
/// Standby → time until the event opens (client shows minutes).
/// Tower → time the tower has been open (client shows hours).
/// Tower → time until the tower closes (client shows hours).
/// Otherwise zero.
/// </param>
ValueTask ShowStateInfoAsync(KanturuState state, byte detailState, bool canEnter, int userCount, TimeSpan remainTime);
Expand Down
27 changes: 27 additions & 0 deletions src/GameLogic/MiniGames/Kanturu/IKanturuPhaseRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="IKanturuPhaseRunner.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.GameLogic.MiniGames.Kanturu;

using System.Threading;

/// <summary>
/// Runs one phase of the Kanturu event. Each phase kind has its own implementation,
/// which the game loop selects through this interface.
/// </summary>
internal interface IKanturuPhaseRunner
{
/// <summary>
/// Gets the kind of phase this runner executes.
/// </summary>
KanturuPhaseKind Kind { get; }

/// <summary>
/// Runs the phase.
/// </summary>
/// <param name="phase">The phase to run.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns><c>true</c> when the phase completed; <c>false</c> when its time limit expired.</returns>
Task<bool> RunAsync(KanturuPhaseDefinition phase, CancellationToken cancellationToken);
}
32 changes: 32 additions & 0 deletions src/GameLogic/MiniGames/Kanturu/KanturuBarrierAreaHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// <copyright file="KanturuBarrierAreaHelper.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.GameLogic.MiniGames.Kanturu;

/// <summary>
/// Enumerates the terrain cells of the Elphis barrier areas.
/// </summary>
internal static class KanturuBarrierAreaHelper
{
/// <summary>
/// Enumerates every cell covered by the given areas, inclusive.
/// </summary>
/// <param name="areas">The terrain areas to expand.</param>
/// <returns>Every cell covered by the areas.</returns>
public static IEnumerable<(byte X, byte Y)> EnumerateCells(IEnumerable<KanturuTerrainArea> areas)
{
// int loop variables: byte would wrap 255 -> 0 and loop forever
// when an area touches the map border.
foreach (var area in areas)
{
for (var x = (int)area.StartX; x <= area.EndX; x++)
{
for (var y = (int)area.StartY; y <= area.EndY; y++)
{
yield return ((byte)x, (byte)y);
}
}
}
}
}
Loading
Loading