Exemplo n.º 1
0
        private void PlayerFinishedTournament(PlayerModel player)
        {
            //Miejsce gracza
            var PlayerCounter     = GameModel.TournamentModel.PlayersList.Count();
            var NonPlayingCounter = GameModel.TournamentModel.PlayersList.Where(e => e.Player.Stack == 0).Count();

            //Miejsce gracza wedlug przegranych
            var PlaceID = PlayerCounter - NonPlayingCounter;

            //Kwota wygranej o ile jest jakakolwiek
            decimal WinPot = 0;

            //Sprawdzamy aktualna liste wygranych
            var ListPotWin = PotModel.PrizeCalc();

            if (PlaceID <= ListPotWin.Count())
            {
                WinPot = ListPotWin.First(e => e.PlaceID == PlaceID).Prize;
            }

            if (player.User.IsOnline())
            {
                string message = "Zakońyłeś turniej na " + PlaceID + " miejscu. ";

                if (WinPot != 0)
                {
                    message += "Twoja wygrana w turnieju wynosi " + CurrencyFormat.Get(GameModel.TournamentModel.EntryCurrency, WinPot);
                }

                player.User.GetClient().OnMessage(message);
            }
        }
        public NormalModeStackWindow(PokerGameWindow parent)
        {
            InitializeComponent();
            this.parent = parent;
            this.game   = (NormalGameModel)Session.Data.Client.ServiceProxy.GetGameModelByTable(parent.TableModel);

            this.AvailableBallance.Visibility = Visibility.Hidden;

            this.JoinButton.IsEnabled = false;

            this.table_name.Text = this.game.Name;
            this.Blind.Text      = this.game.Table.Stakes;

            this.StackSlider.TickFrequency = (double)this.game.Table.Blind;
            this.StackSlider.Minimum       = (double)this.game.Minimum;
            this.StackSlider.Maximum       = (double)this.game.Maximum;
            this.MinAmount.Text            = CurrencyFormat.Get(
                this.game.Table.Currency, ((decimal)this.StackSlider.Minimum)
                );
            this.StackSlider.Value = this.StackSlider.Maximum;

            this.StackValue.Text = this.StackSlider.Value.ToString();

            //Pobieramy wallet
            Task.Factory.StartNew(() =>
            {
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    wallet = Session.Data.Client.ServiceProxy.GetWallet(this.game.Table.Currency);
                    if (wallet == null)
                    {
                        AvailableBallance.Text = "Brak konta z walutą";
                    }
                    else
                    {
                        AvailableBallance.Text = CurrencyFormat.Get(this.game.Table.Currency, wallet.Available);
                    }

                    if (wallet != null && wallet.Available > this.game.Minimum)
                    {
                        if (wallet.Available < this.game.Maximum)
                        {
                            this.StackSlider.Maximum = (double)wallet.Available;
                        }
                        this.JoinButton.IsEnabled = true;

                        //Tworzymy rezerwacje
                        //Session.Data.Client.ServiceProxy.DoAction(ActionModel.GameActionType.Booking, this.game.Table);
                    }
                    else
                    {
                        this.JoinButton.Content = "Brak funduszy";
                    }

                    this.Loader.Visibility            = Visibility.Hidden;
                    this.AvailableBallance.Visibility = Visibility.Visible;
                }));
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prywatny konstruktor
        /// </summary>
        public DepositInfoWindow(TransferModel transfer)
        {
            InitializeComponent();

            this.TransferComment.Text            = transfer.Comment;
            this.TransferCurrencyName.Text       = CurrencyFormat.GetName(transfer.Currency);
            this.TransferValue.Text              = CurrencyFormat.Get(transfer.Currency, transfer.Amount);
            this.TransferBalanceCalculation.Text = CurrencyFormat.Get(transfer.Currency, transfer.WalletAmountBefore) + " + " + CurrencyFormat.Get(transfer.Currency, transfer.Amount) + " = " + CurrencyFormat.Get(transfer.Currency, transfer.WalletAmountBefore + transfer.Amount);

            SoundManager.Play("notification");
        }
Exemplo n.º 4
0
        public static void Deposit(this UserModel user, Enums.CurrencyType currency, decimal value, string comment = "", string flag = "")
        {
            using (var session = DatabaseSession.Open())
            {
                var wallet = session.QueryOver <WalletModel>().
                             Where(u => u.User.ID == user.ID).
                             Where(u => u.Type == currency).
                             SingleOrDefault();

                if (wallet == null)
                {
                    return;
                }

                using (var transaction = session.BeginTransaction())
                {
                    TransferModel transfer = new TransferModel()
                    {
                        Wallet             = wallet,
                        Amount             = value,
                        Timestamp          = DateTime.Now.ToUniversalTime(),
                        Type               = Enums.TransferType.DEPOSIT,
                        Comment            = comment,
                        Flag               = flag,
                        Currency           = wallet.Type,
                        WalletAmountBefore = wallet.Available
                    };

                    wallet.Available += value;

                    session.Save(transfer);
                    session.Update(wallet);

                    transaction.Commit();

                    if (user.IsOnline())
                    {
                        var client = user.GetClient();

                        if (transfer.Comment == "")
                        {
                            transfer.Comment = "Wpłata na konto w wysokości " + CurrencyFormat.Get(wallet.Type, transfer.Amount);
                        }

                        client.OnDepositInfo(transfer);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void ParseTable(TableModel table)
        {
            //Ustawienie stacka głównego w razie gydyby się zmienił za pośrednictwem gracza
            GameTable.Stage  = table.Stage;
            GameTable.Dealer = table.Dealer;
            GameTable.Blind  = table.Blind;
            GameTable.AvgPot = table.AvgPot;

            if (table.TablePot != 0)
            {
                this.GameTable.TablePot      = table.TablePot;
                this.StackCounter.Visibility = Visibility.Visible;
                this.StackCounterLabel.Text  = "Stawka: " + CurrencyFormat.Get(this.GameTable.Currency, this.GameTable.TablePot);
            }
        }
Exemplo n.º 6
0
        public void Update()
        {
            //W zaleznosci od statusu
            if (player.Status.HasFlag(PlayerModel.PlayerStatus.DONTPLAY) || player.Status.HasFlag(PlayerModel.PlayerStatus.LEAVED))
            {
                SeatInfo.Visibility = Visibility.Hidden;
                UserInfo.Visibility = Visibility.Visible;
                UsernameLbl.Text    = player.User.Username;
                StatusLabel.Text    = "Nie gra";
                ColorBrush.Opacity  = 0.3;
            }
            else if (player.Status.HasFlag(PlayerModel.PlayerStatus.FOLDED) || player.Status.HasFlag(PlayerModel.PlayerStatus.WAITING))
            {
                SeatInfo.Visibility = Visibility.Hidden;
                UserInfo.Visibility = Visibility.Visible;
                UsernameLbl.Text    = player.User.Username;
                StatusLabel.Text    = "Saldo: " + CurrencyFormat.Get(this.gameTable.GameTable.Currency, player.Stack);
                ColorBrush.Opacity  = 0.3;
            }
            else if (player.Status.HasFlag(PlayerModel.PlayerStatus.INGAME))
            {
                SeatInfo.Visibility = Visibility.Hidden;
                UserInfo.Visibility = Visibility.Visible;
                UsernameLbl.Text    = player.User.Username;
                StatusLabel.Text    = "Saldo: " + CurrencyFormat.Get(this.gameTable.GameTable.Currency, player.Stack);
                ColorBrush.Opacity  = 0.7;

                if (player.Stack == 0.0m)
                {
                    StatusLabel.Text = "ALL IN";
                }
            }

            if (gameTable.GameTable.Dealer != null && gameTable.GameTable.Dealer.User.ID == player.User.ID)
            {
                this.IsDealer.Visibility = Visibility.Visible;
            }
            else
            {
                this.IsDealer.Visibility = Visibility.Hidden;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Pobiera liste operacji gracza
        /// </summary>
        /// <param name="wallet"></param>
        /// <returns></returns>
        public List <TransferModel> GetTransferOperations(WalletModel wallet)
        {
            using (ISession session = DatabaseSession.Open())
            {
                var transferList = session.QueryOver <WalletModel>().
                                   Where(w => w.ID == wallet.ID).
                                   SingleOrDefault().
                                   TransferList;

                foreach (var transfer in transferList)
                {
                    if (transfer.Comment == "")
                    {
                        transfer.Comment = "Wpłata na konto w wysokości " + CurrencyFormat.Get(wallet.Type, transfer.Amount);
                    }
                }

                return(transferList.OrderByDescending(d => d.Timestamp).Take(15).ToList());
            }
        }
Exemplo n.º 8
0
        private void LoadNewWallet()
        {
            Task.Factory.StartNew(() =>
            {
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    WalletModel wallet = CurrencyList.SelectedItem as WalletModel;
                    //Pobieramy zaktualizowany element
                    wallet = Session.Data.Client.ServiceProxy.GetWallet(wallet.Type);

                    this.Available.Text = CurrencyFormat.Get(wallet.Type, wallet.Available);
                    this.InGame.Text    = CurrencyFormat.Get(wallet.Type, wallet.InGame);
                    this.Sum.Text       = CurrencyFormat.Get(wallet.Type, wallet.Sum);
                    this.Sum2.Text      = this.Sum.Text;
                    this.Currency.Text  = wallet.Type.ToString();

                    //Ładujemy także historię
                    List <TransferModel> historyList       = Session.Data.Client.ServiceProxy.GetTransferOperations(wallet);
                    this.TransferOperationList.ItemsSource = historyList;

                    ((Storyboard)FindResource("fadeOutAnimation")).Begin(Loader);
                }));
            });
        }
Exemplo n.º 9
0
        private void InitializeStage()
        {
            Console.WriteLine("InitializeStage()");

            StageGameProcess = new StageProcess(this);
            StageGameProcess.Initialize();

            StageGameProcess.OnStageChangeEvent += (stage) =>
            {
                Console.WriteLine("OnStageChangeEvent()");
                Thread.Sleep(100);
                List <CardModel> cards = new List <CardModel>();
                switch (stage)
                {
                case Enums.Stage.Flop:
                    this.SendDealerMessage("Rozkładam flopa.");
                    cards.Add(Helper.Pop <CardModel>(GameTypeHandler.CardList));
                    cards.Add(Helper.Pop <CardModel>(GameTypeHandler.CardList));
                    cards.Add(Helper.Pop <CardModel>(GameTypeHandler.CardList));
                    break;

                case Enums.Stage.Turn:
                    this.SendDealerMessage("Rozkładam turn.");
                    cards.Add(Helper.Pop <CardModel>(GameTypeHandler.CardList));
                    break;

                case Enums.Stage.River:
                    this.SendDealerMessage("Rozkładam river.");
                    cards.Add(Helper.Pop <CardModel>(GameTypeHandler.CardList));
                    break;
                }

                Console.WriteLine("Rozdanie kart na stole = " + stage.ToString());

                //Zapisuje zebrane karty do pamieci
                GameTableModel.TableCardList = GameTableModel.TableCardList.Concat(cards).ToList();

                //Przekazujemy karty publice
                CardTableAction cardAction = new CardTableAction()
                {
                    CreatedAt = DateTime.Now,
                    Cards     = cards,
                    Stage     = GameTableModel.Stage
                };

                GameTableModel.ActionHistory.Add(cardAction);
                Thread.Sleep(1500);
            };
            StageGameProcess.OnStageProcessFinishEvent += () =>
            {
                Console.WriteLine("OnStageProcessFinishEvent");
                if (GameTableModel.PlayerHavingPlayStatus().Count == 1)
                {
                    //Wygrywa jeden gracz
                    var playerWinner = GameTableModel.PlayerHavingPlayStatus().FirstOrDefault();
                    playerWinner.Stack += GameTableModel.TablePot;
                    var message = "Gracz " + playerWinner.User.Username + " wygrywa główną pulę " + CurrencyFormat.Get(GameTableModel.Currency, GameTableModel.TablePot) + " ponieważ reszta graczy spasowała karty.";
                    Console.WriteLine(message);

                    this.SendDealerMessage(message);

                    GameTableModel.ShowSystemMessage("Wygrywa " + playerWinner.User.Username, message);
                    Thread.Sleep(2000);
                    GameTableModel.HideSystemMessage();
                }
                else
                {
                    //Showdown
                    StageShowdown stageShowdown = new StageShowdown(this);
                    stageShowdown.OnShowdownWinnerEvent += (evaluatorItem) =>
                    {
                        Console.WriteLine("points: " + evaluatorItem.Points + " (kicker points: " + evaluatorItem.KickerPoints + ")");
                    };
                    stageShowdown.ShowdownStart();
                    stageShowdown.ShowdownPotDistribution();
                }

                Thread.Sleep(100);
                GameTableModel.ShowSystemMessage("Zakończenie rozdania", "Nowe rozdanie zostanie rozpoczęte za 4 sekundy");
                Console.WriteLine("Zakończenie gry na stole " + this.GameTableModel.Name);
                Thread.Sleep(3600);
                GameTableModel.HideSystemMessage();

                BaseFinished();

                if (OnGameFinishedEvent != null)
                {
                    OnGameFinishedEvent(this);
                }

                IsFinished = true;
            };
        }
Exemplo n.º 10
0
        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();
                });
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Rozdzielanie puli według układów
        /// </summary>
        public void ShowdownPotDistribution()
        {
            var gameTable = Game.GameTableModel;

            //Sortujemy od najsilniejszych układów
            var evaluatorGroupedList = Evaluator.EvaluatorStrenghtList.
                                       GroupBy(c => c.FullPoints).
                                       OrderByDescending(e => e.First().FullPoints).ThenBy(e => e.OrderBy(f => f.Contributed)).
                                       ToList();

            //Suma pinieniędzy
            decimal totalPot = gameTable.ActionHistory.OfType <BetAction>().Sum(c => c.Bet);

            //Wszystkie wyniki na jednym poziomie
            var contributionFlatList = gameTable.ActionHistory.OfType <BetAction>().GroupBy(c => c.Player).Select(c => new PlayerContributed
            {
                Player      = c.First().Player,
                Contributed = c.Sum(e => e.Bet)
            }).ToList();

            foreach (var evaluatorItem in evaluatorGroupedList)
            {
                foreach (var evaluatorPlayer in evaluatorItem)
                {
                    decimal winPot = 0;
                    decimal evaluatorPlayerContributed = evaluatorPlayer.Contributed;

                    foreach (var evaluatorContributedPlayer in contributionFlatList)
                    {
                        decimal takenPot = 0;
                        if (evaluatorContributedPlayer.Contributed >= evaluatorPlayerContributed)
                        {
                            takenPot = evaluatorPlayerContributed;
                        }
                        else
                        {
                            takenPot = evaluatorContributedPlayer.Contributed;
                        }

                        evaluatorContributedPlayer.Contributed -= takenPot;
                        winPot += takenPot;
                    }

                    winPot = winPot / (evaluatorItem.Count());

                    if (winPot == 0)
                    {
                        break;
                    }

                    //Infomracja o wygranej puli
                    string message;
                    if (evaluatorPlayer.IsBest == true)
                    {
                        message = "Gracz " + evaluatorPlayer.Player.User.Username + " wygrywa główną pulę " + CurrencyFormat.Get(gameTable.Currency, winPot);
                    }
                    else
                    {
                        message = "Gracz " + evaluatorPlayer.Player.User.Username + " wygrywa boczną pulę " + CurrencyFormat.Get(gameTable.Currency, winPot);
                    }

                    if (evaluatorPlayer.IsKickerWin)
                    {
                        message += " kickerem " + CardModel.GetNormalizeNominal(evaluatorPlayer.KickerCards.FirstOrDefault().Face, CardModel.NormalizeNominalSize.ONE);
                    }

                    OnShowdownWinnerEvent(evaluatorPlayer);

                    TablePotAction tablePotAction = new TablePotAction()
                    {
                        Stage     = Game.GameTableModel.Stage,
                        CreatedAt = DateTime.Now,
                        Player    = evaluatorPlayer.Player,
                        Pot       = winPot
                    };
                    Game.GameTableModel.ActionHistory.Add(tablePotAction);

                    Game.SendDealerMessage(message);
                    Console.WriteLine(message);
                    gameTable.ShowSystemMessage("Wygrana " + evaluatorPlayer.Player.User.Username, message);
                    Thread.Sleep(2000);
                    gameTable.HideSystemMessage();
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Informacje o stole
        /// </summary>
        /// <param name="table"></param>
        public void SetNormalModeNote(NormalGameModel normalMode)
        {
            if (normalMode == null)
            {
                return;
            }
            TablePlayerList.Visibility = Visibility.Visible;

            //Ukrywamy loader
            Loader.Visibility = Visibility.Hidden;

            //Wypisujemy informacje o stole
            EventName.Text   = normalMode.Name;
            EventStatus.Text = "Gra stołowa";
            EventNameID.Text = "ID: #" + (normalMode.ID).ToString().PadLeft(8, '0');

            //PlayerList.ItemsSource = normalMode.Table.PlayersList;
            PlayerList.ItemsSource = null;
            PlayerList.ItemsSource = Session.Data.Client.ServiceProxy.GetTablePlayers(normalMode.Table);

            //Usuwamy click handler
            var routedEventHandlers = Helper.GetRoutedEventHandlers(JoinButton, ButtonBase.ClickEvent);

            if (routedEventHandlers != null)
            {
                foreach (var routedEventHandler in routedEventHandlers)
                {
                    JoinButton.Click -= (RoutedEventHandler)routedEventHandler.Handler;
                }
            }

            //Dajemy zmieniony click handler
            JoinButton.Click += new RoutedEventHandler((object sender, RoutedEventArgs e) => {
                Lobby.OpenGameWindow(normalMode);
            });

            //Parsujemy informacje na temat stolu do listy elementow
            TableSideElementList.ItemsSource = null;
            List <TableSideElement> tableSideElementList = new List <TableSideElement>();

            tableSideElementList.Add(
                new TableSideElement()
            {
                Title       = "Ilość graczy:",
                Description = "Zajęte miejsca/Maksymalna ilość miejsc",
                Value       = normalMode.Table.Players + "/" + normalMode.Table.Seats
            }
                );
            tableSideElementList.Add(
                new TableSideElement()
            {
                Title       = "Średni stack:",
                Description = "Ostatnie 15 rozdań",
                Value       = normalMode.Table.AvgPotCurrency
            }
                );
            tableSideElementList.Add(
                new TableSideElement()
            {
                Title       = "Minimalna kwota:",
                Description = "Minimalna kwota wejścia do gry",
                Value       = CurrencyFormat.Get(normalMode.Currency, normalMode.Minimum)
            }
                );

            TableSideElementList.ItemsSource = tableSideElementList;

            //Jeśli nie ma graczy ukrywamy panel
            if (normalMode.Table.Players == 0)
            {
                NoPlayers.Visibility = Visibility.Visible;
            }
            else
            {
                NoPlayers.Visibility = Visibility.Hidden;
            }
        }