31 lines
1009 B
C#
31 lines
1009 B
C#
using OECS;
|
|
|
|
namespace Blackjack;
|
|
|
|
/// <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
|
|
{
|
|
public void Run(World world)
|
|
{
|
|
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;
|
|
world.MarkModified<GameState>(World.SingletonEntity);
|
|
}
|
|
}
|
|
|
|
internal static class PlayerHandTag { public static readonly PlayerHand Instance = new(); }
|
|
internal static class DealerHandTag { public static readonly DealerHand Instance = new(); } |