2026-07-18 23:26:56 +08:00
|
|
|
using OECS;
|
|
|
|
|
|
2026-07-20 16:41:10 +08:00
|
|
|
namespace Game.Blackjack;
|
2026-07-18 23:26:56 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deals initial two cards to player and dealer when entering the dealing phase.
|
|
|
|
|
/// Advances to player turn after dealing.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DealSystem : ISystem
|
|
|
|
|
{
|
2026-07-21 13:57:11 +08:00
|
|
|
public void RunImpl(World world)
|
2026-07-18 23:26:56 +08:00
|
|
|
{
|
|
|
|
|
var state = world.ReadSingleton<GameState>();
|
|
|
|
|
if (state.Phase != GamePhase.Dealing)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ref var mutableState = ref world.GetSingleton<GameState>();
|
|
|
|
|
|
|
|
|
|
// Deal two cards to player, then two to dealer.
|
|
|
|
|
HitCommand.DrawCard<PlayerHand>(world);
|
|
|
|
|
HitCommand.DrawCard<PlayerHand>(world);
|
|
|
|
|
HitCommand.DrawCard<DealerHand>(world);
|
|
|
|
|
HitCommand.DrawCard<DealerHand>(world);
|
|
|
|
|
|
|
|
|
|
mutableState.Phase = GamePhase.PlayerTurn;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static class PlayerHandTag { public static readonly PlayerHand Instance = new(); }
|
|
|
|
|
internal static class DealerHandTag { public static readonly DealerHand Instance = new(); }
|