diff --git a/src/GameLogic/MiniGames/HeykelSavasiContext.cs b/src/GameLogic/MiniGames/HeykelSavasiContext.cs index 66c440e..e00e5ce 100644 --- a/src/GameLogic/MiniGames/HeykelSavasiContext.cs +++ b/src/GameLogic/MiniGames/HeykelSavasiContext.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using MUnique.OpenMU.DataModel.Configuration; /// @@ -62,6 +63,15 @@ public class HeykelSavasiContext : MiniGameContext { } + /// + /// Gets a value indicating whether players are allowed to kill each other. + /// + /// + /// This does not prevent friendly fire (team members killing each other); that restriction + /// is added separately via a hook in a later phase. + /// + public override bool AllowPlayerKilling => this.State == MiniGameState.Playing; + /// /// Gets the current number of players assigned to the given team. /// @@ -115,6 +125,27 @@ public class HeykelSavasiContext : MiniGameContext /// All players assigned to . public IEnumerable PlayersOf(HeykelSavasiTeam team) => this._teams.Where(kv => kv.Value == team).Select(kv => kv.Key); + /// + /// + /// 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. + /// + protected override async ValueTask OnGameStartAsync(ICollection 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); + } + } + /// /// Determines, in a pure way, whether joining is allowed given the current /// team counts, according to the balance rule: the absolute difference between the red and blue