using OECS; namespace Blackjack; /// /// Evaluates the player's hand total after each hit. /// Busts the player if they exceed 21. /// public class PlayerBustCheckSystem : ISystem { public void Run(World world) { var state = world.ReadSingleton(); if (state.Phase != GamePhase.PlayerTurn) return; var total = HandUtil.CalculateHand(world, PlayerHandTag.Instance); if (total <= 21) return; ref var mutableState = ref world.GetSingleton(); mutableState.Phase = GamePhase.RoundOver; mutableState.Result = RoundResult.PlayerBust; world.MarkModified(World.SingletonEntity); } }