public async Task ProcessClientAction(PlayerEvent playerAction) { //TODO: validate that the player can perform the given action. E.G Can't check and Can't call if someone has raised. switch (playerAction.EventType) { //case PlayerActionType.PostSmallBlind: // Raise(Table.TableConfig.SmallBlindSize, playerAction.PlayerId); // await DispatchPlayerAction(playerAction); // break; //case PlayerActionType.PostBigBlind: // Raise(Table.TableConfig.BigBlindSize, playerAction.PlayerId); // await DispatchPlayerAction(playerAction); // break; case PlayerActionType.Call: Call(playerAction.BetSize, playerAction.PlayerId); await DispatchPlayerAction(playerAction); break; case PlayerActionType.Raise: Raise(playerAction.BetSize, playerAction.PlayerId); await DispatchPlayerAction(playerAction); break; case PlayerActionType.Fold: Fold(playerAction.PlayerId); await DispatchPlayerAction(playerAction); break; case PlayerActionType.Check: Check(playerAction.PlayerId); await DispatchPlayerAction(playerAction); break; case PlayerActionType.ShowCards: await DispatchPlayerAction(playerAction); break; case PlayerActionType.MockCards: await DispatchPlayerAction(playerAction); break; default: // Throw an exception here or dispatch an error message to the clients trying to hack the game or something funny Debug.WriteLine($"PLAYER INVALID ACTION ${playerAction.PlayerId} ${playerAction.EventType}"); break; } }
public async Task DispatchPlayerAction(PlayerEvent playerAction) { await _hubContext.Clients.All.SendAsync(ClientInvokableMethods.PlayerAction, playerAction); }