29 lines
657 B
C#
29 lines
657 B
C#
using MessagePack;
|
|
using OECS;
|
|
|
|
namespace Blackjack;
|
|
|
|
/// <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;
|
|
world.MarkModified<GameState>(World.SingletonEntity);
|
|
}
|
|
} |