public void OnPlayerGameAction(UserModel user, Enums.ActionPokerType action, decimal actionValue) { if (OnPlayerGameActionEvent != null) { OnPlayerGameActionEvent(user, action, actionValue); } }
/// <summary> /// Wysyła akcję gry (Call, Gold, Raise etc) oraz wartość jeśli potrzebna /// </summary> /// <param name="table"></param> /// <param name="action"></param> /// <param name="actionValue"></param> public void DoGameAction(TableModel table, Enums.ActionPokerType action, decimal actionValue) { var _table = table.FromMemory(); Game _game = null; switch (table.Type) { case Enums.TableType.Normal: _game = GameList.Get <NormalGameController>().FirstOrDefault(p => p.Game.GameTableModel.ID == _table.ID).Game; break; case Enums.TableType.Tournament: _game = GameList.Get <TournamentGameController>().Select(e => e.GameList). FirstOrDefault(t => t.Any(f => f.GameTableModel.ID == table.ID)). FirstOrDefault(t => t.GameTableModel.ID == table.ID); break; default: return; } if (_game != null) { var _user = ClientModel.GetUser(CurrentClient); _game.OnPlayerGameAction(_user.User, action, actionValue); } }
/// <summary> /// Sprawdza sume ktora uzytkownik wprowadzil do akcji /// </summary> /// <param name="action"></param> /// <param name="actionValue"></param> /// <returns></returns> private decimal ParseBetActionValue(Enums.ActionPokerType action, decimal actionValue) { var table = Game.GameTableModel; //Sprawdzenie obliczamy ręcznie if (action == Enums.ActionPokerType.Call) { actionValue = GetCallValue(table.ActionPlayer); } else if (action == Enums.ActionPokerType.Raise) { //Sprawdzamy czy to allin var isPlayerAllIn = (this.Game.GameTableModel.ActionPlayer.Stack - actionValue <= 0); if (!isPlayerAllIn) { //Raise moze byc co najmniej rowny ostatniemu przebiciu (lub big blind) x2 BetOfferAction betOffer = GetBetOfferAction(); if (actionValue < betOffer.MinBet) { actionValue = betOffer.MinBet; } if (actionValue > betOffer.MaxBet) { actionValue = betOffer.MaxBet; } if (actionValue % betOffer.BetTick != 0) { actionValue = betOffer.MinBet; } } } return(actionValue); }
void Game_OnPlayerGameActionEvent(UserModel user, Enums.ActionPokerType action, decimal actionValue) { Console.WriteLine("Game_OnPlayerGameActionEvent()"); //Sprawdzamy czy gracz jest aktywny w tym momencie //lub czy w ogole jest mozliwosc podjecia akcji na tym stole var table = Game.GameTableModel; lock (table.ActionPlayer) { if (table.ActionPlayer == null || ( table.ActionPlayer != null && user.ID != table.ActionPlayer.User.ID) ) { Console.WriteLine("ActinPlayer is null"); return; } if (action == Enums.ActionPokerType.BigBlind || action == Enums.ActionPokerType.SmallBlind) { return; //Nie mozna wywołać bigblind, smallblind z poziomu użytkownika } actionValue = this.ParseBetActionValue(action, actionValue); if (ActionPlayerTimer != null) { ActionPlayerTimer.Elapsed -= ActionPlayerNoAction; ActionPlayerTimer = null; } //Ukrywamy dostępne akcje jako że wykonano akcję betaction //Ukrywamy je tylko dla osob ktore wykonaly akcje, jesli zostala wykonana akacja autoamtyczna to znaczy //ze gracz otrzymal flage DONTPLAY //wiec umozliwiamy mu powrot co zostalo juz wczesniej mu wyslane Task.Factory.StartNew(() => { if (table.ActionPlayer != null && table.ActionPlayer.User.IsOnline() && !table.ActionPlayer.Status.HasFlag(PlayerModel.PlayerStatus.DONTPLAY)) { var _c = table.ActionPlayer.User.GetClient(); _c.OnGameActionOffer(table, new HideOfferAction() { Timestamp = DateTime.Now }); } }); BetAction stageAction = new BetAction() { Action = action, Bet = actionValue, CreatedAt = DateTime.Now, Stage = table.Stage, Player = table.ActionPlayer }; table.ActionHistory.Add(stageAction); string message; string action_str; switch (action) { case Enums.ActionPokerType.Fold: action_str = "pasuje"; break; case Enums.ActionPokerType.Call: action_str = "sprawdza"; break; case Enums.ActionPokerType.Raise: action_str = "podbija do " + CurrencyFormat.Get(table.Currency, table.ActionHistory.OfType <BetAction>().Last().Bet); break; default: action_str = "--bład--"; break; } message = "Gracz " + table.ActionPlayer.User.Username + " " + action_str + "."; Task.Factory.StartNew(() => { Game.SendDealerMessage(message); }); Task.Factory.StartNew(() => { StageLoop(); }); } }