Files
card_game/tests/Game.Core.Tests/PhaseATests.cs
T
chenmoranzhiandCursor ae13f1d06a 落地无头规则引擎与局内内容,便于命令行复现对战。
规则、卡包与测试放在同一套核心里,避免表现层自行结算。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 02:06:23 +08:00

55 lines
1.5 KiB
C#

using CardGame.Core;
using Xunit;
namespace Game.Core.Tests;
public sealed class PhaseATests
{
[Fact]
public void Clone_is_independent()
{
var state = new GameState(seed: 1) { Catalog = Cards.Catalog };
state.Players[0].Life = 12;
var clone = RulesEngine.CloneState(state);
clone.Players[0].Life = 7;
Assert.Equal(12, state.Players[0].Life);
Assert.Equal(7, clone.Players[0].Life);
}
[Fact]
public void Rng_is_deterministic_for_same_seed()
{
var a = new GameRng(42);
var b = new GameRng(42);
Assert.Equal(a.NextUInt32(), b.NextUInt32());
Assert.Equal(a.NextInt(10), b.NextInt(10));
}
[Fact]
public void EndTurn_passes_priority_and_base_field_supplies()
{
var state = MatchSetup.Create(
7,
Cards.Repeat(Cards.Wisp, 10),
Cards.Repeat(Cards.Wisp, 10),
Cards.Catalog,
shuffle: false);
Assert.Equal(1, state.Players[0].Energy);
state = RulesEngine.Execute(state, new EndTurnAction(0));
Assert.Equal(1, state.ActivePlayerIndex);
Assert.Equal(1, state.Players[1].Energy);
}
[Fact]
public void GetLegalActions_offers_end_turn()
{
var state = MatchSetup.Create(
1,
Cards.Repeat(Cards.Wisp, 10),
Cards.Repeat(Cards.Wisp, 10),
Cards.Catalog,
shuffle: false);
Assert.Contains(RulesEngine.GetLegalActions(state), a => a is EndTurnAction);
}
}