Esempio n. 1
0
        public void UpdateFromStatus(MsgGameStatus status)
        {
            player_hands = status.Hands;
            center_cards = status.CenterActionCards;

            player_position = -1;
            for (int i = 0; i < status.Players.Count; ++i)
            {
                if (status.Players[i].Equals(Network.GameComms.GetPlayer()))
                {
                    player_position = i;
                    break;
                }
            }

            for (int i = 0; i < status.PlayedCardsByPlayer.Count; ++i)
            {
                played_game_cards[i].SetCard(c: status.PlayedCardsByPlayer[i]);
            }

            players = status.Players;

            current_player_turn = status.CurrentPlayer;

            scores = status.Scores;

            SyncHandCards();
            SyncCenterCards();
        }
Esempio n. 2
0
        public void UpdateGame(MsgGameStatus status)
        {
            // Check that the ID values
            if (status.GameID != game_id)
            {
                return;
            }

            // Update the status window
            gameScreen.UpdateFromStatus(status);
            if (status.CurrentGameStatus != null && status.CurrentGameStatus.Length > 0)
            {
                toolStripStatus.Text = "Status: " + status.CurrentGameStatus;
            }
            else
            {
                toolStripStatus.Text = "No Game Status";
            }
        }
Esempio n. 3
0
        private void tmrServerTick_Tick(object sender, EventArgs e)
        {
            // Read input messages
            int read_msg = 0;

            while (read_msg < 10)
            {
                MsgBase msg = Network.GameComms.ReceiveMessage();

                if (msg == null)
                {
                    break;
                }

                Console.WriteLine("Received " + msg.GetType().ToString());

                if (msg is MsgGameStatus)
                {
                    MsgGameStatus status = (MsgGameStatus)msg;

                    if (game_window != null)
                    {
                        game_window.UpdateGame(status);
                    }
                }
                else if (msg is MsgGameList)
                {
                    MsgGameList game_list = (MsgGameList)msg;

                    ListGames.Items.Clear();
                    foreach (MsgGameList.ListItem i in game_list.Games)
                    {
                        CommonEntry  gi  = new CommonEntry(id: i.GameIDValue, game_type: (GameTypes)i.GameType);
                        ListViewItem lvi = new ListViewItem(gi.ToString())
                        {
                            Tag = gi
                        };
                        ListGames.Items.Add(lvi);
                    }

                    ListLobbies.Items.Clear();
                    foreach (MsgGameList.ListItem i in game_list.Lobbies)
                    {
                        CommonEntry  li  = new CommonEntry(id: i.GameIDValue, game_type: (GameTypes)i.GameType);
                        ListViewItem lvi = new ListViewItem(li.ToString())
                        {
                            Tag = li
                        };
                        ListLobbies.Items.Add(lvi);
                    }
                }
                else if (msg is MsgLobbyStatus)
                {
                    MsgLobbyStatus status = (MsgLobbyStatus)msg;
                    if (lobby_window != null)
                    {
                        lobby_window.UpdateStatus(status);
                    }
                }

                read_msg += 1;
            }

            // Check for server failure
            if (Network.GameComms.Failed())
            {
#if DEBUG
                Application.Exit();
#else
                Application.Restart();
#endif
            }
        }