Ejemplo n.º 1
0
        // normal game constructor
        public BoardForm(int dim, MainForm mainForm, bool singlePlayer)
        {
            InitializeComponent();

            switch (dim)
            {
            case 3:
                ctrl3 = new Board3Control(this);
                boardElementHost.Child = ctrl3;
                break;

            case 4:
                ctrl4 = new Board4Control(this);
                boardElementHost.Child = ctrl4;
                break;

            case 5:
                ctrl5 = new Board5Control(this);
                boardElementHost.Child = ctrl5;
                break;
            }

            this.dim          = dim;
            this.mainForm     = mainForm;
            this.singlePlayer = singlePlayer;
            this.Text         = "Board " + dim + "x" + dim;
            this.historyMode  = false;
            ended             = false;
            showMessage("Waiting for server..");
            mainForm.getClient().startGameRequest(dim, singlePlayer);
        }
Ejemplo n.º 2
0
        // game history display constructor
        public BoardForm(GameData game, MainForm mainForm)
        {
            InitializeComponent();

            switch (game.BoardSize)
            {
            case 3:
                ctrl3 = new Board3Control(this);
                boardElementHost.Child = ctrl3;
                ctrl3.disableBoard();
                break;

            case 4:
                ctrl4 = new Board4Control(this);
                boardElementHost.Child = ctrl4;
                ctrl4.disableBoard();
                break;

            case 5:
                ctrl5 = new Board5Control(this);
                boardElementHost.Child = ctrl5;
                ctrl5.disableBoard();
                break;
            }

            this.dim         = game.BoardSize;
            this.mainForm    = mainForm;
            this.Text        = "Board " + dim + "x" + dim;
            ended            = true;
            this.gameHistory = game;
            this.historyMode = true;
            btnNext.Visible  = true;

            string str = string.Format("{0}  vs.  {1}",
                                       "[" + gameHistory.Player1_Name.Replace(" ", string.Empty) + "]",
                                       "[" + gameHistory.Player2_Name.Replace(" ", string.Empty) + "]");

            showMessage(str);

            this.moves = getGameMovesFromString(gameHistory.Moves);     // simple string
            if (moves != null && moves.Length > 0)
            {
                btnNext.Enabled = true;
                currentMove     = 0;
            }
            else
            {
                MessageBox.Show("No moves available for this game", "Moves", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }