oecs-sharp/Game.Blackjack/Commands/PlaceBetCommand.cs

28 lines
600 B
C#
Raw Permalink Normal View History

2026-07-18 23:26:56 +08:00
using MessagePack;
using OECS;
namespace Game.Blackjack;
2026-07-18 23:26:56 +08:00
/// <summary>
/// Places a bet and advances the game to the dealing phase.
/// </summary>
[MessagePackObject]
public struct PlaceBetCommand : ICommand
{
[Key(0)] public int Amount;
public void Execute(World world)
{
ref var state = ref world.GetSingleton<GameState>();
if (state.Phase != GamePhase.Betting)
return;
if (Amount < 1 || Amount > state.Chips)
return;
state.CurrentBet = Amount;
state.Chips -= Amount;
state.Phase = GamePhase.Dealing;
}
}