Beispiel #1
0
        private void CreateBotton_Click(object sender, RoutedEventArgs e)
        {
            if (GameModeComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please Choose Game Mode");
                return;
            }
            if (_minPlayer == -1)
            {
                MessageBox.Show("Please enter Minimum Playes");
                return;
            }
            if (_maxPlayers == -1)
            {
                MessageBox.Show("Please enter Maximum Playes");
                return;
            }
            if (_chipPolicy == -1)
            {
                MessageBox.Show("Please enter Chip Policy");
                return;
            }
            if (_buyInPolicy == -1)
            {
                MessageBox.Show("Please enter Buy-In Policy");
                return;
            }
            if (SpectatorsComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please choose Spectetors Allowed");
                return;
            }
            if (_minBet == -1)
            {
                MessageBox.Show("Please enter Chip Policy");
                return;
            }
            GameDataCommMessage newRoom = _logic.CreateNewRoom(_mode, _minBet, _chipPolicy, _buyInPolicy, _canSpectate, _minPlayer, _maxPlayers);

            if (newRoom != null)
            {
                MessageBox.Show("New Room sucssesfully Created, Enjoy!");
                GameScreen newGameWindow = new GameScreen(_logic);

                newGameWindow.UpdateGame(newRoom);
                _logic.AddNewRoom(newGameWindow);
                newGameWindow.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("New room creation failed!");
            }
        }
Beispiel #2
0
 public void LeaveAsSpectetorOk(GameDataCommMessage msgGameData)
 {
     if (msgGameData.IsSucceed)
     {
         Dispatcher.Invoke(() =>
         {
             MessageBox.Show("BYE BYE " + _logic.user.username + " see you soon!");
             this.Close();
         });
     }
     else
     {
         MessageBox.Show("Leave the game faild, please try again");
     }
 }
Beispiel #3
0
 public void LeaveOkay(GameDataCommMessage gd)
 {
     if (gd.IsSucceed)
     {
         MessageBox.Show("Leave Game Okay. BYE BYE");
         Dispatcher.Invoke(() =>
         {
             ListViewItem toAdd = new ListViewItem();
             toAdd.Content      = string.Concat($"Player {_logic.user.name}Just leaved the room");
             chatListView.Items.Add(toAdd);
             this.Close();
         });
     }
     else
     {
         MessageBox.Show("Something went wrong. Leave Game Fail");
     }
 }
Beispiel #4
0
        public GameScreen(ClientLogic c)
        {
            InitializeComponent();
            _logic = c;

            /*  UserID.Content = _logic.user.id;
             * UserName.Content = _logic.user.username;
             * string path = _logic.user.avatar;
             * Avatar.Source = new BitmapImage(new Uri(@path, UriKind.Relative));*/
            update = null;
            ActionLabel.Visibility           = Visibility.Hidden;
            ChooseActionLabel.Visibility     = Visibility.Hidden;
            ActionAmountLabel.Visibility     = Visibility.Hidden;
            ActionChosenComboBox.Visibility  = Visibility.Hidden;
            InputForActionTextBox.Visibility = Visibility.Hidden;
            DoActiomBotton.Visibility        = Visibility.Hidden;
            isSpectrtor = false;
            _logic.SetLogoutScreen(this);
        }
Beispiel #5
0
 public void JoinOkay(GameDataCommMessage msgGameData)
 {
     if (msgGameData.IsSucceed)
     {
         Dispatcher.Invoke(() =>
         {
             MessageBox.Show("You joined the game successfully!");
             GameScreen newGameWindow = new GameScreen(cl);
             newGameWindow.UpdateGame(msgGameData);
             cl.AddNewRoom(newGameWindow);
             newGameWindow.Show();
             Hide();
         });
     }
     else
     {
         MessageBox.Show("Joined the game failed!");
     }
 }
Beispiel #6
0
 public void PlayerReturnResponseReceived(GameDataCommMessage msgGameData)
 {
     if (msgGameData.IsSucceed)
     {
         Dispatcher.Invoke(() =>
         {
             MessageBox.Show("You Return the game successfully! Enjoy");
             GameScreen newGameWindow = new GameScreen(_cl);
             newGameWindow.UpdateGame(msgGameData);
             _cl.AddNewRoom(newGameWindow);
             newGameWindow.Show();
             Hide();
         });
     }
     else
     {
         Dispatcher.Invoke(() =>
         {
             MessageBox.Show("You Can't Return to be a player in this game!");
         });
     }
 }
Beispiel #7
0
        public void Initialize()
        {
            proxy          = new GameDataProxy(gameCenter);
            _userDataProxy = new UserDataProxy();
            user1          = new User(1, "test1", "mo", "1234", 0, 5000, "*****@*****.**");
            user2          = new User(2, "test2", "no", "1234", 0, 5000, "*****@*****.**");
            user3          = new User(3, "test3", "3test", "1234", 0, 5000, "*****@*****.**");
            _userDataProxy.AddNewUser(user1);
            _userDataProxy.AddNewUser(user2);
            _userDataProxy.AddNewUser(user3);
            useCommunication     = false;
            roomID               = 9999;
            players              = new List <Player>();
            player1              = new Player(user1, 1000, roomID);
            player1.RoundChipBet = 22;
            players.Add(player1);
            Decorator deco = SetDecoratoresNoLimitWithSpectatores();

            gameRoom = new GameRoom(players, roomID, deco, gameCenter, logControl, replayManager, ses);
            Card        c1     = new Card(Suits.Clubs, 1);
            Card        c2     = new Card(Suits.Clubs, 2);
            List <Card> pCards = new List <Card>();

            pCards.Add(c1);
            pCards.Add(c2);
            long sid = 1;

            msg = new GameDataCommMessage(gameRoom.GetPlayersInRoom().First().user.Id(), gameRoom.Id, sid, new Card(Suits.Diamonds, 1), new Card(Suits.Diamonds, 2),
                                          pCards, 3, 4, new List <string>(), new List <string>(), "", "", "", true, "", "", 1,
                                          new CommunicationMessage.ActionType(), "Flop", "");
            var ob = new List <Tuple <CommunicationMessage, bool, bool, TexasHoldemShared.CommMessages.ServerToClient.ResponeCommMessage> >();

            res = new ResponeCommMessage(1, 1, true, msg);
            var t = new Tuple <CommunicationMessage, bool, bool, TexasHoldemShared.CommMessages.ServerToClient.ResponeCommMessage>(msg, false, false, res);

            ob.Add(t);
            rn = new ResponseNotifier(ob, cl);
        }
Beispiel #8
0
        public void SpecReturnResponseReceived(GameDataCommMessage msgGameData)
        {
            if (msgGameData == null)
            {
                Dispatcher.Invoke(() =>
                {
                    MessageBox.Show("You Can't Return to be a spectator in this game!");
                });
            }
            else
            {
                Dispatcher.Invoke(() =>
                {
                    MessageBox.Show("You Return to watch game successfully! as Spectetor");
                    GameScreen newGameWindow = new GameScreen(_cl);
                    newGameWindow.UpdateGame(msgGameData);

                    _cl.AddNewRoom(newGameWindow);
                    newGameWindow.Show();
                    newGameWindow.isSpectrtor = true;
                    Hide();
                });
            }
        }
Beispiel #9
0
        public void JoinOkayAsSpectate(GameDataCommMessage msgGameData)
        {
            if (msgGameData == null || !msgGameData.IsSucceed)
            {
                Dispatcher.Invoke(() =>
                {
                    MessageBox.Show("You Can't be a spectator in this game!");
                });
            }
            else
            {
                Dispatcher.Invoke(() =>
                {
                    MessageBox.Show("You joined the game successfully! as Spectetor");
                    GameScreen newGameWindow = new GameScreen(cl);
                    newGameWindow.UpdateGame(msgGameData);

                    cl.AddNewRoom(newGameWindow);
                    newGameWindow.Show();
                    newGameWindow.isSpectrtor = true;
                    Hide();
                });
            }
        }
Beispiel #10
0
 public CreateNewGameResponse(int id, long sid, bool success, CommunicationMessage originalMsg,
                              GameDataCommMessage gameData) : base(id, sid, success, originalMsg)
 {
     GameData = gameData;
 }
Beispiel #11
0
 public void SpecReturnsToGame(GameDataCommMessage gameData)
 {
     _returnToGamesScreen.SpecReturnResponseReceived(gameData);
 }
Beispiel #12
0
        public void UpdateGame(GameDataCommMessage msg)
        {
            PopupUser(msg.ActionPlayerName, msg.Action, msg.IsSucceed);

            update = msg;
            Dispatcher.Invoke(() =>
            {
                UserID.Content   = _logic.user.id;
                UserName.Content = _logic.user.username;
                string path      = _logic.user.avatar;
                Avatar.Source    = new BitmapImage(new Uri(@path, UriKind.Relative));
                if (_logic.user.username.Equals(msg.CurrPlayerTurn))
                {
                    ActionLabel.Visibility           = Visibility.Visible;
                    ChooseActionLabel.Visibility     = Visibility.Visible;
                    ActionAmountLabel.Visibility     = Visibility.Visible;
                    ActionChosenComboBox.Visibility  = Visibility.Visible;
                    InputForActionTextBox.Visibility = Visibility.Visible;
                    DoActiomBotton.Visibility        = Visibility.Visible;
                }
                else
                {
                    ActionLabel.Visibility           = Visibility.Hidden;
                    ChooseActionLabel.Visibility     = Visibility.Hidden;
                    ActionAmountLabel.Visibility     = Visibility.Hidden;
                    ActionChosenComboBox.Visibility  = Visibility.Hidden;
                    InputForActionTextBox.Visibility = Visibility.Hidden;
                    DoActiomBotton.Visibility        = Visibility.Hidden;
                }
                if (!String.IsNullOrEmpty(msg.Winner))
                {
                    if (msg.Winner.Contains(","))
                    {
                        winnerNameLabel.Content = "Winners: ";
                    }
                    else
                    {
                        winnerNameLabel.Content = "Winner: ";
                    }
                    winnerName.Content = msg.Winner;
                    string msgToChat   = string.Concat("*GAME MESSAGE* ", "The " + winnerNameLabel.Content + winnerName.Content, " Won the game.");
                    ListViewItem toAdd = new ListViewItem();
                    toAdd.Content      = msgToChat;
                    this.chatListView.Items.Add(toAdd);
                    msgToChat           = string.Concat("*GAME MESSAGE* ", " Game is Over ");
                    ListViewItem toAdd1 = new ListViewItem();
                    toAdd1.Content      = msgToChat;
                    this.chatListView.Items.Add(toAdd1);
                    this.PotAmountLabel.Content    = "";
                    this.BB.Content                = "";
                    this.CurrRound.Content         = "";
                    this.CurrTurnNameLabel.Content = "";
                    this.DealerNameLabel.Content   = "";
                    this.SB.Content                = "";
                    this.PublicCardView.Items.Clear();
                    this.PlayerCards        = msg.PlayerCards;
                    string pre1             = "First Card is :    ";
                    string pre2             = "Second Card is : ";
                    this.Card1Labek.Content = string.Concat(pre1);
                    this.Card2Label.Content = string.Concat(pre2);
                    return;
                }
                this.RoomId = msg.RoomId;
                string pre  = "Room Number: ";

                RoomNum.Content = string.Concat(pre, RoomId);
                if (msg.SbName != null)
                {
                    this.SbName     = msg.SbName;
                    this.SB.Content = msg.SbName;
                }
                if (msg.AllPlayerNames != null)
                {
                    this.AllPlayerNames    = msg.AllPlayerNames;
                    List <ViewObj> players = new List <ViewObj>();
                    this.ListViewPlayers.Items.Clear();
                    foreach (string aString in AllPlayerNames)
                    {
                        ListViewItem toAdd = new ListViewItem();
                        toAdd.Content      = aString;
                        this.ListViewPlayers.Items.Add(aString);
                    }
                    // ListViewPlayers.ItemsSource = players;
                    foreach (string playerName in AllPlayerNames)
                    {
                        if (_logic.user.name.Equals(playerName))
                        {
                            this.SpecOrPlay = true;
                        }
                    }
                }

                if (msg.AllSpectatorNames != null)
                {
                    this.AllSpecNames = msg.AllSpectatorNames;
                    this.ListViewSpectetors.Items.Clear();
                    foreach (string aString in AllSpecNames)
                    {
                        if (_logic.user.username.Equals(aString))
                        {
                            isSpectrtor = true;
                        }
                        ListViewItem toAdd = new ListViewItem();
                        toAdd.Content      = aString;
                        this.ListViewSpectetors.Items.Add(aString);
                    }
                }

                if (msg.BbName != null)
                {
                    this.BbName     = msg.BbName;
                    this.BB.Content = msg.BbName;
                }

                if (msg.CurrRound != null)
                {
                    this.CurrRound.Content = msg.CurrRound;
                }

                if (msg.CurrPlayerTurn != null)
                {
                    this.CurrPlayerTurn            = msg.CurrPlayerTurn;
                    this.CurrTurnNameLabel.Content = msg.CurrPlayerTurn;
                }
                if (msg.DealerName != null)
                {
                    this.DealerName = msg.DealerName;
                    this.DealerNameLabel.Content = msg.DealerName;
                }
                if (!isSpectrtor)
                {
                    if ((msg.PlayerCards[0] != null) || (msg.PlayerCards[1] != null))
                    {
                        this.PlayerCards        = msg.PlayerCards;
                        string pre1             = "First Card is :    ";
                        string pre2             = "Second Card is : ";
                        this.Card1Labek.Content = string.Concat(pre1, (msg.PlayerCards[0]).ToString());
                        this.Card2Label.Content = string.Concat(pre2, (msg.PlayerCards[1]).ToString());
                    }
                }
                else
                {
                    myCardsLabel.Content  = "";
                    Card1Labek.Visibility = Visibility.Hidden;
                    Card2Label.Visibility = Visibility.Hidden;
                }


                this.PotSize = msg.PotSize;
                this.PotAmountLabel.Content = msg.PotSize;

                if (msg.TableCards != null)
                {
                    this.PublicCardView.Items.Clear();
                    this.TableCards = msg.TableCards;
                    foreach (Card aCard in TableCards)
                    {
                        if (aCard != null)
                        {
                            // PUBLIC cards
                            ListViewItem publicCardItem = new ListViewItem();
                            publicCardItem.Content      = string.Concat(aCard.ToString());
                            this.PublicCardView.Items.Add(publicCardItem);
                        }
                    }
                }
                if (!isSpectrtor)
                {
                    this.TotalChips = msg.TotalChips;
                    this.ChipAmountLabel.Content = msg.TotalChips;
                }
                else
                {
                    this.TotalChips = 0;
                    this.ChipAmountLabel.Content = "";
                }

                if (msg.IsSucceed)
                {
                    string msgToChat = "";
                    if (msg.Action.Equals(CommunicationMessage.ActionType.Bet))
                    {
                        if (msg.BetAmount == 0)
                        {
                            msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " Checked");
                        }
                        else
                        {
                            msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " Bet with amount of ",
                                                      msg.BetAmount);
                        }
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.Fold))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " Folded.");
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.Join))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " Joined the game.");
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.Spectate))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " Joined as a spectetor to game.");
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.ReturnToGame))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " return to The game.");
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.Leave))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", " player: " + msg.ActionPlayerName,
                                                  " left the game.");
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.SpectatorLeave))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", " spectetor: " + msg.ActionPlayerName,
                                                  " left the game.");
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.StartGame))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " started the game.");
                    }
                    else if (msg.Action.Equals(CommunicationMessage.ActionType.CreateRoom))
                    {
                        msgToChat = string.Concat("*GAME MESSAGE* ", msg.ActionPlayerName, " game  was created.");
                    }


                    ListViewItem toAdd = new ListViewItem();
                    toAdd.Content      = msgToChat;
                    this.chatListView.Items.Add(toAdd);
                    if (msg.ActionPlayerName.Equals(_logic.user.username) && msg.Action.Equals(CommunicationMessage.ActionType.Leave))
                    {
                        this.Close();
                    }
                }
            });
        }
Beispiel #13
0
 public void HandleEvent(GameDataCommMessage msg)
 {
     //show in GUI
     throw new NotImplementedException();
 }
Beispiel #14
0
 public void SetGameData(GameDataCommMessage gameData)
 {
     GameData = gameData;
 }
Beispiel #15
0
 public JoinResponseCommMessage(long sid, int id, bool success, CommunicationMessage originalMsg,
                                GameDataCommMessage gameData) : base(id, sid, success, originalMsg)
 {
     GameData = gameData;
 }
Beispiel #16
0
 public ActionResultInfo(int id, GameDataCommMessage gameData)
 {
     Id       = id;
     GameData = gameData;
 }
Beispiel #17
0
 public bool GeneralCase(GameDataCommMessage msgGameData)
 {
     _logic.GameUpdateReceived(msgGameData);
     return(true);
 }