public PlayerState(PlayerStateWindow plyr, string name)
        {
            state = plyr;

            structuresBuilt[StructureType.RawMaterial] = plyr.ResourceStructures;
            structuresBuilt[StructureType.Goods] = plyr.GoodsStructures;
            structuresBuilt[StructureType.Commerce] = plyr.CommerceStructures;
            structuresBuilt[StructureType.Military] = plyr.MilitaryStructures;
            structuresBuilt[StructureType.Science] = plyr.ScienceStructures;
            structuresBuilt[StructureType.Civilian] = plyr.CivilianStructures;
            structuresBuilt[StructureType.Guild] = plyr.GuildStructures;
            structuresBuilt[StructureType.Leader] = plyr.LeaderStructures;
            structuresBuilt[StructureType.City] = plyr.CityStructures;

            plyr.CoinsImage.Visibility = Visibility.Visible;

            plyr.PlayerName.Content = name;
        }
        //constructor: create the UI. create the Coordinator object
        public MainWindow()
        {
            //create the coordinator
            coordinator = new Coordinator(this);

            InitializeComponent();

            //make graphics better
            RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.Fant);

            /* Test code for displaying the Final Score window without actually having to play through a game.
             * Uncomment if you want the UI to display this window, then exit.
             *
            NameValueCollection testScores = HttpUtility.ParseQueryString("JaPlayer1=1,2,3,4,5,6,7,8,9,69&Player2=2,2,2,2,2,2,2,2,2,22&Player3=-3,-3,-3,-3,-3,-3,-3,-3,-3,33");
            NameValueCollection testScores = HttpUtility.ParseQueryString("Player1=1,2,3,4,5,6,7,8,9,69&Player2=2,2,2,2,2,2,2,2,2,22&Player3=-3,-3,-3,-3,-3,-3,-3,-3,-3,33&Player4=4,4,4,4,4,4,4,4,4,44&Player5=5,5,5,5,5,5,5,5,5,55&Player6=6,6,6,6,6,6,6,6,6,66&Player7=7,7,7,7,7,7,7,7,7,77");
            NameValueCollection testScores = HttpUtility.ParseQueryString("Player1=1,2,3,4,5,6,7,8,9,69&Player2=2,2,2,2,2,2,2,2,2,22&Player3=-3,-3,-3,-3,-3,-3,-3,-3,-3,33&Player4=4,4,4,4,4,4,4,4,4,44&Player5=5,5,5,5,5,5,5,5,5,55&Player6=6,6,6,6,6,6,6,6,6,66&Player7=7,7,7,7,7,7,7,7,7,77&Player8=8,8,8,8,8,8,8,8,8,88");
            FinalScore finalScoreUI = new FinalScore(this, testScores);
            finalScoreUI.ShowDialog();
            return;
            */

            /* Test code for displaying the debt token window without having to play a game.
             * Uncomment if you want the UI to display this window, then exit.
             *
            //NameValueCollection testDebtWindow = HttpUtility.ParseQueryString("GetDebtTokens&coin=15&coinsToLose=10");
            NameValueCollection testDebtWindow = HttpUtility.ParseQueryString("GetDebtTokens&coin=10&coinsToLose=15");
            GetDebtToken d = new GetDebtToken(coordinator, testDebtWindow);
            d.ShowDialog();
            return;
            */

            JoinTableUI joinGameDlg = new JoinTableUI();
            bool succeeded = (bool)joinGameDlg.ShowDialog();

            if (!succeeded)
            {
                Close();
                return;
            }

            // Maybe I should have the ability to choose between Joining and Creating?
            // Original code allowed the creator to add AI and select the leaders.
            coordinator.joinGame(joinGameDlg.userName, IPAddress.Parse(joinGameDlg.ipAddressAsText));

            // coordinator.createGame();

            if (!coordinator.client.Connected)
            {
                Close();
                return;
            }

            PlayerStateWindow[,] seatMap = new PlayerStateWindow[,] {
                { SeatA, SeatF, SeatD, null, null, null, null, null },      // 3 players
                { SeatA, SeatG, SeatE, SeatC, null, null, null, null },     // 4 players
                { SeatA, SeatG, SeatF, SeatD, SeatC, null, null, null },    // 5 players
                { SeatA, SeatH, SeatF, SeatE, SeatD, SeatB, null, null },   // 6 players
                { SeatA, SeatH, SeatG, SeatF, SeatD, SeatC, SeatB, null},   // 7 players
                { SeatA, SeatH, SeatG, SeatF, SeatE, SeatD, SeatC, SeatB }, // 8 players
            };

            int playerIndex = 0;

            // each player should see the "A" position for his cards.  Find our index.  Will be 0 for the
            // first player (the game creator), 1 for the 2nd player, 2 for the 3rd, etc.
            while (coordinator.playerNames[playerIndex] != coordinator.nickname)
                playerIndex++;

            for (int i = 0; i < coordinator.playerNames.Length; ++i)
            {
                playerState.Add(coordinator.playerNames[playerIndex],
                    new PlayerState(seatMap[coordinator.playerNames.Length - 3, i], coordinator.playerNames[playerIndex]));
                ++playerIndex;
                if (playerIndex == coordinator.playerNames.Length)
                    playerIndex = 0;
            }

            // coordinator.sendToHost("U");
        }