Exemplo n.º 1
0
        public void OtherPlayersPiece()
        {
            var game      = new TaikyokuShogi();
            var testPiece = new Piece(Player.White, PieceIdentity.Queen);
            var startLoc  = (17, 17);

            game.Debug_SetPiece(testPiece, startLoc);
            Assert.False(game.MakeMove(startLoc, Movement.ComputeMove(startLoc, Movement.Up, 1).Value));
        }
Exemplo n.º 2
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (e.Source == newGameMenuItem)
            {
                NewGame();
            }
            else if (e.Source == saveGameMenuItem)
            {
                var saveDialog = new Microsoft.Win32.SaveFileDialog()
                {
                    InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                    DefaultExt       = "shogi",
                    FileName         = "save",
                    Filter           = "Shogi files (*.shogi)|*.shogi|All files (*.*)|*.*"
                };

                if (saveDialog.ShowDialog() ?? false)
                {
                    SaveGame(saveDialog.FileName);
                }
            }
            else if (e.Source == loadGameMenuItem)
            {
                var loadDialog = new Microsoft.Win32.OpenFileDialog()
                {
                    InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                    Multiselect      = false,
                    DefaultExt       = "shogi",
                    FileName         = "",
                    Filter           = "Shogi files (*.shogi)|*.shogi|All files (*.*)|*.*"
                };

                if (loadDialog.ShowDialog() ?? false)
                {
                    LoadGame(loadDialog.FileName);
                }
            }
            else if (e.Source == closeMenuItem)
            {
                Close();
            }
            else if (e.Source == rotateMenuItem)
            {
                gameBoard.IsRotated = rotateMenuItem.IsChecked;
            }
            else if (e.Source == debugModeMenuItem)
            {
                // nothing to do... "Debug" state is tracked through the "checked" property of this menu item
            }
            else if (pieceMenuItems.TryGetValue(e.Source as MenuItem, out var piece))
            {
                gameBoard.AddingPiece = piece;
            }
            else if (e.Source == removePieceMenuItem)
            {
                gameBoard.RemovingPiece = true;
            }
            else if (e.Source == clearBoardMenuItem)
            {
                for (int i = 0; i < TaikyokuShogi.BoardHeight; ++i)
                {
                    for (int j = 0; j < TaikyokuShogi.BoardHeight; ++j)
                    {
                        Game.Debug_SetPiece(null, (i, j));
                    }
                }
            }
            else if (e.Source == switchTurnMenuItem)
            {
                Game.Debug_EndTurn();
            }
            else
            {
                throw new NotImplementedException();
            }
        }