feat(hs): warp teams to base on start + cancel if a team is empty

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Acentech Dev
2026-07-20 23:09:39 +03:00
parent 8295c30b71
commit 5bc5f461e5

View File

@@ -8,6 +8,7 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using MUnique.OpenMU.DataModel.Configuration; using MUnique.OpenMU.DataModel.Configuration;
/// <summary> /// <summary>
@@ -62,6 +63,15 @@ public class HeykelSavasiContext : MiniGameContext
{ {
} }
/// <summary>
/// Gets a value indicating whether players are allowed to kill each other.
/// </summary>
/// <remarks>
/// This does not prevent friendly fire (team members killing each other); that restriction
/// is added separately via a <see cref="Player"/> hook in a later phase.
/// </remarks>
public override bool AllowPlayerKilling => this.State == MiniGameState.Playing;
/// <summary> /// <summary>
/// Gets the current number of players assigned to the given team. /// Gets the current number of players assigned to the given team.
/// </summary> /// </summary>
@@ -115,6 +125,27 @@ public class HeykelSavasiContext : MiniGameContext
/// <returns>All players assigned to <paramref name="team"/>.</returns> /// <returns>All players assigned to <paramref name="team"/>.</returns>
public IEnumerable<Player> PlayersOf(HeykelSavasiTeam team) => this._teams.Where(kv => kv.Value == team).Select(kv => kv.Key); public IEnumerable<Player> PlayersOf(HeykelSavasiTeam team) => this._teams.Where(kv => kv.Value == team).Select(kv => kv.Key);
/// <inheritdoc />
/// <remarks>
/// Cancels the event if either team is empty at start (no opponent to fight); otherwise
/// warps every participant to their team's base spawn gate.
/// </remarks>
protected override async ValueTask OnGameStartAsync(ICollection<Player> players)
{
await base.OnGameStartAsync(players).ConfigureAwait(false);
if (this.TeamCount(HeykelSavasiTeam.Red) == 0 || this.TeamCount(HeykelSavasiTeam.Blue) == 0)
{
this.FinishEvent();
return;
}
foreach (var player in players)
{
await player.WarpToAsync(this.GetTeamSpawnGate(this.GetTeam(player))).ConfigureAwait(false);
}
}
/// <summary> /// <summary>
/// Determines, in a pure way, whether joining <paramref name="team"/> is allowed given the current /// Determines, in a pure way, whether joining <paramref name="team"/> is allowed given the current
/// team counts, according to the balance rule: the absolute difference between the red and blue /// team counts, according to the balance rule: the absolute difference between the red and blue