feat(hs): HeykelSavasiContext team tracking + balance rule
Adds the HeykelSavasiTeam enum (None/Red/Blue) and the HeykelSavasiContext skeleton (subclass of MiniGameContext) with team registration (AssignTeam/GetTeam/PlayersOf/TeamCount) and a join-balance rule (|Red-Blue| <= 2 after the prospective join), exposed as a pure static IsJoinAllowed for fast unit testing without constructing the full context. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// <copyright file="HeykelSavasiContextTests.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
namespace MUnique.OpenMU.Tests.HeykelSavasi;
|
||||
|
||||
using MUnique.OpenMU.GameLogic.MiniGames;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for the Heykel Savasi team-balance rule.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="HeykelSavasiContext"/> derives from <see cref="MiniGameContext"/>, whose constructor
|
||||
/// creates a map and launches a background game loop via <c>Task.Run</c>. Constructing a full context
|
||||
/// is impractical in a fast unit test, so the balance decision is exposed as a pure static method,
|
||||
/// <see cref="HeykelSavasiContext.IsJoinAllowed"/>, and tested directly against it.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public class HeykelSavasiContextTests
|
||||
{
|
||||
[Test]
|
||||
public void BalanceRule_BlocksJoinWhenDifferenceWouldExceedTwo()
|
||||
{
|
||||
// Red 0, Blue 0 -> either team may be joined.
|
||||
Assert.That(HeykelSavasiContext.IsJoinAllowed(0, 0, HeykelSavasiTeam.Red), Is.True);
|
||||
|
||||
// Red already has 2, Blue has 0. Adding a 3rd to Red would make the difference 3.
|
||||
Assert.That(HeykelSavasiContext.IsJoinAllowed(2, 0, HeykelSavasiTeam.Red), Is.False, "2-0 iken Red'e katilim farki 3 yapar");
|
||||
Assert.That(HeykelSavasiContext.IsJoinAllowed(2, 0, HeykelSavasiTeam.Blue), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BalanceRule_NoneTeamIsNeverJoinable()
|
||||
{
|
||||
Assert.That(HeykelSavasiContext.IsJoinAllowed(0, 0, HeykelSavasiTeam.None), Is.False);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user