private void raisePlayerPerformedBet(Player player, BetAction betAction, int callAmount, int raiseAmount, bool isBlindAction) { if (PlayerPerformedAction != null) { PlayerPerformedAction(this, new PlayerActionEventArgs(player, betAction, callAmount, raiseAmount, isBlindAction)); } }
/// <summary> /// <para>Initializes an instance of the <see cref="PlayerActionEventArgs"/> class.</para> /// </summary> /// <param name="player">The player which performed the action</param> /// <param name="betAction">The action performed by the player</param> /// <param name="callAmount">The player call amount (can be 0)</param> /// <param name="raiseAmount">The player raise amount (can be 0)</param> /// <param name="isBlindAction">A flag indicating if the action was made by the player or was a blind action</param> public PlayerActionEventArgs(Player player, BetAction betAction, int callAmount, int raiseAmount, bool isBlindAction) { Player = player; CallAmount = callAmount; RaiseAmount = raiseAmount; IsBlindAction = isBlindAction; PlayerAction = betAction; }
private void OnClickItem(ItemController item) { var blockIndex = AgentHelper.InnerAgent.BlockIndex; var bet = new BetAction(blockIndex - (blockIndex % 2), item.itemIndex); Agent.instance.MakeTransaction(new BetAction[] { bet }); _gamePanel.SelectedIndex = item.itemIndex; }
public BetActionRepresentation(BetAction betAction, int?index = null, bool isCurrentBetAction = false) { BetAction = betAction; BetRepresentation = BetAction.Type == BetActionType.Bet ? new BetRepresentation(betAction.Bet) : null; Index = index; IsCurrentBetAction = isCurrentBetAction; }
private IList <BetAction> GetFollowedBetActions(BetAction betAction) { var betActionIndex = BetActionList.IndexOf(betAction); var followUpCount = BetActionList.Count - (betActionIndex + 1); var followedActions = followUpCount > 0 ? BetActionList.ToList().GetRange(betActionIndex + 1, followUpCount) : new List <BetAction>(); return(followedActions); }
/// <summary> /// Called when the game round starts and the blind raise is made /// </summary> /// <param name="raiser">The blind raiser</param> /// <param name="raiseAmount">The raise amount, can be 0</param> /// <param name="openAmount">The original open amount which was notified by <see cref="NotifyBlindOpen"/></param> protected virtual void NotifyBlindRaise(Player raiser, int openAmount, int raiseAmount) { if (startingPlayer > 2) { BetAction action = BetAction.Raise; if (raiseAmount == 0) { action = BetAction.CheckOrCall; } raisePlayerPerformedBet(raiser, action, openAmount, raiseAmount, true); } }
public void ProcessBetAction(BetAction betAction) { if (BetResult != null) { var msg = "Inconsistency: Once the Bet phase is over no BetAction can be processed!"; Log.Error(msg); throw new InvalidOperationException(msg); } BetActionList.Add(betAction); BetResult = GetBetResult(); if (BetResult == null && betAction.PlayerInfo == CurrentPlayer) { CurrentPlayer = PlayerGroup.GetNextPlayer(CurrentPlayer.PlayerId); } }
/// <summary> /// Marks this action as a Raise action with the given amount. /// </summary> /// <param name="raiseAmount">The amount to raise in addition to the <see cref="CallAmount"/></param> /// <remarks> /// If the raise amount is negative, the action will fold. /// If the action is marked with the flag <see cref="CanRaise"/> as false, the action will call. /// </remarks> public void Raise(int raiseAmount) { this.raiseAmount = raiseAmount; // check if the action can be raised or if the raiseAmount is 0 if (!CanRaise || raiseAmount == 0) { Call(); } else if (raiseAmount < 0) // can't raise with negative values { Fold(); } else { action = BetAction.Raise; } }
/// <summary> /// Called by the client when a player performs an action. /// </summary> /// <param name="player">The player which performed the action</param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The call amount if any, can be 0</param> /// <param name="raiseAmount">The raise amount if any, can be 0</param> public void NotifyPlayerAction(Player player, BetAction betAction, int callAmount, int raiseAmount) { Console.Write(player); Console.Write(' '); int totalAmount = callAmount + raiseAmount; if (betAction == BetAction.Raise && 0 == player.Money) { Console.WriteLine("is All In {0}$", totalAmount); } else { switch (betAction) { case BetAction.CheckOrCall: if (callAmount == 0) { Console.WriteLine("Checked"); } else { Console.WriteLine("Called {0}$", callAmount); } break; case BetAction.Raise: if (callAmount == 0) { Console.WriteLine("Raised {0}$", raiseAmount); } else { Console.WriteLine("Called {0}$ & Raised {1}$", callAmount, raiseAmount); } break; case BetAction.Fold: Console.WriteLine("Folds"); break; } } }
/// <summary> /// Wpłata dużych i małych ciemnych /// </summary> protected void BlindPayment() { BetAction smallBlind = new BetAction() { Action = Enums.ActionPokerType.SmallBlind, Bet = GameTableModel.Blind, CreatedAt = DateTime.Now, Stage = GameTableModel.Stage, Player = NextPlayer(GameTableModel.Dealer) }; GameTableModel.ActionHistory.Add(smallBlind); BetAction bigBlind = new BetAction() { Action = Enums.ActionPokerType.BigBlind, Bet = GameTableModel.Blind * 2, CreatedAt = DateTime.Now, Stage = GameTableModel.Stage, Player = NextPlayer(smallBlind.Player) }; GameTableModel.ActionHistory.Add(bigBlind); }
/// <summary> /// Parsuje wykonanie akcji /// </summary> /// <param name="action"></param> private void ParseBetAction(IAction action, bool IsSilenceMode = false) { if (action is BetAction) { BetAction actionEntry = (BetAction)action; Seat playerSeat = SeatList.FirstOrDefault(s => s.player != null && s.player.User.ID == actionEntry.Player.User.ID); //Gracz wyszedł, nie ma sensu parsować jego przebić if (playerSeat == null) { return; } //Gracz wykonał akcję więc są zmiany if (!IsSilenceMode) { playerSeat.UpdatePlayer(actionEntry.Player); } //Pasujemy akcje przebicia switch (actionEntry.Action) { case Enums.ActionPokerType.Call: //Sprawdzamy cze bet czy check if (actionEntry.Bet == 0) { //check if (!IsSilenceMode) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { SoundManager.Play("Checkmark-4"); })); } } else { //bid if (!IsSilenceMode) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { SoundManager.Play("Bet-4"); })); } //Dodajemy pieniądze na stół OnPlayerBid(actionEntry.Player, actionEntry.Bet); } break; case Enums.ActionPokerType.Raise: //Wpłacamy pieniądze na stół if (!IsSilenceMode) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { SoundManager.Play("Bet-4"); })); } //Dodajemy pieniądze na stół OnPlayerBid(actionEntry.Player, actionEntry.Bet); break; case Enums.ActionPokerType.Fold: if (!IsSilenceMode) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { SoundManager.Play("Fold-3"); })); } break; case Enums.ActionPokerType.SmallBlind: case Enums.ActionPokerType.BigBlind: //Hajs na stół OnPlayerBid(actionEntry.Player, actionEntry.Bet); break; } } }
public void StartEdit() { _originalBetAmount = BetAmount; _originalBetType = BetType; }
public void Save() { _originalBetAmount = BetAmount; _originalBetType = BetType; if (BetTypeChanged != null) BetTypeChanged(); }
/// <summary> /// Called by the client when a player performs an action. /// </summary> /// <param name="player">The player which performed the action</param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The call amount if any, can be 0</param> /// <param name="raiseAmount">The raise amount if any, can be 0</param> public void NotifyPlayerAction(Player player, BetAction betAction, int callAmount, int raiseAmount) { Invoke <Player, BetAction, int, int>(realHelper.NotifyPlayerAction, player, betAction, callAmount, raiseAmount); }
/// <summary> /// Marks this action as a Fold action. /// </summary> public void Fold() { action = BetAction.Fold; }
/// <summary> /// Called after each player performs an action /// </summary> /// <param name="player">The player which performed the action </param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The amount which the player had to call</param> /// <param name="raiseAmount">The amount which the player raised (if any)</param> public void NotifyPlayerAction(Player player, BetAction betAction, int callAmount, int raiseAmount) { Player safePlayer = GetSafePlayer(player); forEachClient((cur) => cur.NotifyPlayerAction(safePlayer, betAction, callAmount, raiseAmount)); }
/// <summary> /// Called after each player performs an action /// </summary> /// <param name="player">The player which performed the action </param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The amount which the player had to call</param> /// <param name="raiseAmount">The amount which the player raised (if any)</param> protected override void NotifyPlayerAction(Player player, BetAction betAction, int callAmount, int raiseAmount) { helper.NotifyPlayerAction(player, betAction, callAmount, raiseAmount); }
/// <summary> /// Called after each player performs an action /// </summary> /// <param name="player">The player which performed the action </param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The amount which the player had to call</param> /// <param name="raiseAmount">The amount which the player raised (if any)</param> protected virtual void NotifyPlayerAction(Player player, BetAction betAction, int callAmount, int raiseAmount) { raisePlayerPerformedBet(player, betAction, callAmount, raiseAmount, false); }
/// <summary> /// Called by the client when a player performs an action. /// </summary> /// <param name="player">The player which performed the action</param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The call amount if any, can be 0</param> /// <param name="raiseAmount">The raise amount if any, can be 0</param> public void NotifyPlayerAction(Player player, BetAction betAction, int callAmount, int raiseAmount) { checkBettingStarted(); concreteClient.NotifyPlayerAction(player, betAction, callAmount, raiseAmount); }
/// <summary> /// Called after each player performs an action /// </summary> /// <param name="player">The player which performed the action </param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The amount which the player had to call</param> /// <param name="raiseAmount">The amount which the player raised (if any)</param> public void NotifyPlayerAction(PokerEngine.Player player, BetAction betAction, int callAmount, int raiseAmount) { concreteHelper.NotifyPlayerAction(player, betAction, callAmount, raiseAmount); }
/// <summary> /// Marks this action as a Call action. /// </summary> public void Call() { action = BetAction.CheckOrCall; }
public static HandSnapshotModel GetSnapshot(HandSnapshotModel lastAction, BetAction action, float amount) { if (lastAction.NextPlayer != null) { ActiveStatus[] status = lastAction.GetStatus(); float[] bets = lastAction.GetBets(); float[] stacks = lastAction.GetStacks(); bool[] active = lastAction.GetActive(); ApplyBet(action, (int)lastAction.NextPlayer, amount, status, bets, stacks); return new HandSnapshotModel(lastAction.Round, lastAction.Button, active, status, bets, stacks, lastAction.NextPlayer); } else { if (lastAction.IsHandEnd) { return lastAction; } else { HoldemHandRound round = (HoldemHandRound)(((int)lastAction.Round) + 1); ActiveStatus[] status = GetNextRoundStatus(lastAction.GetStatus()); float[] bets = lastAction.GetBets(); float[] stacks = lastAction.GetStacks(); bool[] active = lastAction.GetActive(); int start = BetPolicyService.GetRoundStart(round, lastAction.Button, status.Length); start = (int)GetNextActivePlayer(status, bets, (int)round); ApplyBet(action, start, amount, status, bets, stacks); return new HandSnapshotModel(round, lastAction.Button, active, status, bets, stacks, start); } } }
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(); }); } }
void Instance_OnPlayerActionTriggerEvent(TableModel table, BaseAction action) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (this.gameTable.GameTable.ID != table.ID || this.player == null) { return; } if (action is BetAction) { BetAction actionEntry = (BetAction)action; if (this.player.User.ID == actionEntry.Player.User.ID) { ParserPlayer(actionEntry.Player); CloseTimer(); //Jeśli fold, ukrywamy karty if (actionEntry.Action == Enums.ActionPokerType.Fold) { HideCards(); } } } else if (action is CardBacksideAction) { //Otrzymanie kart (tyły kart) CardBacksideAction actionEntry = (CardBacksideAction)action; if (this.player.User.ID == actionEntry.Player.User.ID) { ParserPlayer(actionEntry.Player); ShowEmptyCards(actionEntry.Count); } } else if (action is CardHideupAction) { CardHideupAction actionEntry = (CardHideupAction)action; if (this.player.User.ID == actionEntry.Player.User.ID) { ParserPlayer(actionEntry.Player); HideCards(); } } else if (action is CardShowupAction) { CardShowupAction actionEntry = (CardShowupAction)action; if (this.player.User.ID == actionEntry.Player.User.ID) { ParserPlayer(actionEntry.Player); ShowCards(actionEntry.Cards); } } else if (action is TablePotAction) { TablePotAction actionEntry = (TablePotAction)action; if (this.player.User.ID == actionEntry.Player.User.ID) { ParserPlayer(actionEntry.Player); } } })); }
/// <summary> /// Applies a bet and adjusts the players status according to the bet /// </summary> private static void ApplyBet(BetAction action, int playerIndex, float amount, ActiveStatus[] status, float[] bets, float[] stacks) { switch (action) { case BetAction.Bet: case BetAction.Raise: bets[playerIndex] += amount; for (int i = 0; i < status.Length; i++) if (status[i] == ActiveStatus.LastToRaise) status[i] = ActiveStatus.HasBet; status[playerIndex] = ActiveStatus.LastToRaise; break; case BetAction.Call: bets[playerIndex] += amount; status[playerIndex] = ActiveStatus.HasBet; break; case BetAction.Check: status[playerIndex] = ActiveStatus.HasBet; break; case BetAction.Fold: status[playerIndex] = ActiveStatus.HasFolded; break; case BetAction.AllIn: bets[playerIndex] += amount; for (int i = 0; i < status.Length; i++) if (status[i] == ActiveStatus.LastToRaise) status[i] = ActiveStatus.HasBet; status[playerIndex] = ActiveStatus.AllIn; break; } if (bets[playerIndex] == stacks[playerIndex]) status[playerIndex] = ActiveStatus.AllIn; }
/// <summary> /// Called by the client when a player performs an action. /// </summary> /// <param name="player">The player which performed the action</param> /// <param name="betAction">The action performed</param> /// <param name="callAmount">The call amount if any, can be 0</param> /// <param name="raiseAmount">The raise amount if any, can be 0</param> public virtual void NotifyPlayerAction(Player player, BetAction betAction, int callAmount, int raiseAmount) { helper.NotifyPlayerAction(player, betAction, callAmount, raiseAmount); }