落地无头规则引擎与局内内容,便于命令行复现对战。
规则、卡包与测试放在同一套核心里,避免表现层自行结算。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using CardGame.Core;
|
||||
using Xunit;
|
||||
|
||||
namespace Game.Core.Tests;
|
||||
|
||||
public sealed class PackTests
|
||||
{
|
||||
private static List<PackDefinition> Catalog() =>
|
||||
PackJson.LoadDirectory(Path.Combine(AppContext.BaseDirectory, "content", "packs"));
|
||||
|
||||
[Fact]
|
||||
public void Base_pack_is_always_in_the_run_pool()
|
||||
{
|
||||
var state = MatchSetup.Create(
|
||||
1,
|
||||
Cards.Repeat(Cards.Wisp, 10),
|
||||
Cards.Repeat(Cards.Wisp, 10),
|
||||
Cards.Catalog,
|
||||
shuffle: false);
|
||||
var unlocked = Packs.Unlocked(state, 0, Catalog());
|
||||
Assert.Contains(unlocked, p => p.Id == "pack.example.base");
|
||||
Assert.DoesNotContain(unlocked, p => p.Id == "pack.example.vitality");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Healing_unlocks_vitality_pack()
|
||||
{
|
||||
var state = MatchSetup.Create(
|
||||
1,
|
||||
Cards.Repeat(Cards.Salve, 10),
|
||||
Cards.Repeat(Cards.Wisp, 10),
|
||||
Cards.Catalog,
|
||||
shuffle: false);
|
||||
state.Players[0].Life = 10;
|
||||
state.Players[0].Energy = 1;
|
||||
var salve = state.Players[0].Hand[0];
|
||||
state = RulesEngine.Execute(state, new PlayCardAction(0, salve.Id));
|
||||
Assert.Equal(2, state.Players[0].Run.HealReceived);
|
||||
Assert.Contains(Packs.Unlocked(state, 0, Catalog()), p => p.Id == "pack.example.vitality");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Fuse_expiry_unlocks_aftermath_for_the_owner()
|
||||
{
|
||||
var state = MatchSetup.Create(
|
||||
1,
|
||||
Cards.Repeat(Cards.Fuse, 10),
|
||||
Cards.Repeat(Cards.Wisp, 10),
|
||||
Cards.Catalog,
|
||||
shuffle: false);
|
||||
var fuse = state.Players[0].Hand[0];
|
||||
state = RulesEngine.Execute(state, new PlayCardAction(0, fuse.Id));
|
||||
state = RulesEngine.Execute(state, new EndTurnAction(0));
|
||||
Assert.Equal(1, state.Players[0].Run.FriendlyDestroyed);
|
||||
Assert.Contains(Packs.Unlocked(state, 0, Catalog()), p => p.Id == "pack.example.aftermath");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user