예제 #1
0
        public void CanMoveQuestion_MoveOutby6_1()
        {
            //Arrange:
            VM_MainWindow vm   = new VM_MainWindow();
            Game_Main     Game = new Game_Main(vm);

            Game.GameState.ActivePlayer       = 1;
            Game.GameState.PawnPosition[1][0] = -1;
            Game.GameState.PawnPosition[1][1] = 3;
            Game.GameState.PawnPosition[1][2] = -1;
            Game.GameState.PawnPosition[1][3] = 34;
            Game.GameState.DieValue           = 1;

            int[] expect = new int[4] {
                90, 4, 90, 35
            };

            //Act:
            int[] actual = Game.PawnMovement.CheckWhichPawnCanMove();

            //Assert:
            string errorMsg = "Failed: ";

            foreach (int x in actual)
            {
                errorMsg += x.ToString() + ", ";
            }
            CollectionAssert.AreEqual(actual, expect, errorMsg);
        }
예제 #2
0
        public void RollDie()
        {
            //Arrange:
            VM_MainWindow vm   = new VM_MainWindow();
            Game_Main     game = new Game_Main(vm);

            int[] dieValues = new int[50];
            int[] expected  = new int[2] {
                1, 6
            };

            //Act:
            for (int i = 0; i < 50; i++)
            {
                game.RollDie();
                dieValues[i] = game.GameState.DieValue;
            }

            //Assert:
            int[] actual = new int[2] {
                dieValues.Min(), dieValues.Max()
            };
            string errorMsg = "Failed: ";

            foreach (int x in actual)
            {
                errorMsg += x.ToString() + ", ";
            }
            CollectionAssert.AreEqual(expected, actual, errorMsg);
        }
예제 #3
0
        public void MovePawn_Beating_beimRauskommen()
        {
            //Arrange:
            VM_MainWindow VM = new VM_MainWindow();
            GameState     GS = VM.GameState;

            GS.ActivePlayer = 1;
            int PawnID      = 0;
            int otherPlayer = 0;
            int otherPawnID = 0;

            GS.PawnPosition[GS.ActivePlayer][PawnID] = -1;
            GS.PawnOptions = new int[4] {
                0, 33, 45, 90
            };
            GS.PawnPosition[otherPlayer][otherPawnID] = 12;
            int expected = -1;

            //Act:
            VM.Game.PawnMovement.MovePawn(PawnID);

            //Assert:
            int actual = GS.PawnPosition[otherPlayer][otherPawnID];

            Assert.AreEqual(expected, actual);
        }
예제 #4
0
 public MainWindow()
 {
     InitializeComponent();
     m_VM = new VM_MainWindow();
     //st = new SettingsWindow();
     //lg = new LogWindow();
     DataContext = m_VM;
 }
예제 #5
0
 public void GetMainWindow()
 {
     MainWindow             = new MainWindow();
     this.GS                = new GameState();
     VM_MainWindow          = new VM_MainWindow(GS, this);
     MainWindow.DataContext = VM_MainWindow;
     MainWindow.Show();
 }
예제 #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            VM_MainWindow vm = new VM_MainWindow();

            Application.Current.MainWindow = vm.UIElement as Window;
            vm.Show();
            base.OnStartup(e);
        }
예제 #7
0
        public void BoardView_AllInHouse()
        {
            //Arrange:
            VM_MainWindow VM = new VM_MainWindow();

            VM.GameState.PawnPosition[0] = new int[4] {
                -1, -1, -1, -1
            };
            VM.GameState.PawnPosition[1] = new int[4] {
                -1, -1, -1, -1
            };
            VM.GameState.PawnPosition[2] = new int[4] {
                -1, -1, -1, -1
            };
            VM.GameState.PawnPosition[3] = new int[4] {
                -1, -1, -1, -1
            };

            List <int[]> expected = new List <int[]>();

            for (int i = 0; i < 90; i++)
            {
                expected.Add(new int[2] {
                    9, 9
                });
            }
            for (int i = 0; i < 4; i++)
            {
                expected[50 + (10 * i) + 0] = new int[2] {
                    i, 0
                };
                expected[50 + (10 * i) + 1] = new int[2] {
                    i, 1
                };
                expected[50 + (10 * i) + 2] = new int[2] {
                    i, 2
                };
                expected[50 + (10 * i) + 3] = new int[2] {
                    i, 3
                };
            }

            //Act:
            VM.Change_BoardView();

            //Assert:
            List <int[]> actual          = VM.BoardView;
            string       expected_string = "";
            string       actual_string   = "";

            for (int i = 0; i < 90; i++)
            {
                expected_string = expected_string + expected[i][0].ToString() + "," + expected[i][1].ToString() + "|";
                actual_string   = actual_string + actual[i][0].ToString() + "," + actual[i][1].ToString() + "|";
            }
            Assert.AreEqual(expected_string, actual_string);
        }
예제 #8
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = new VM_MainWindow();

            // params int[]
            // __arglist
            //throw new NullReferenceException();
            //throw null;
        }
예제 #9
0
        public Game_Main(VM_MainWindow view)
        {
            this.VM   = view;
            GameState = new Game_State();

            GameHistory     = new List <int[]>();
            DecisionHistory = new List <int>();

            AIInformation = new int[2];
            Context       = new SituationContext();
            AI            = new Game_PlayerAI(this, Context);
        }
예제 #10
0
        public void StartNewGame()
        {
            MainWindow.Close();

            MainWindow                 = new MainWindow();
            this.GS                    = new GameState();
            GS.PlayerNames             = NewGameOptions.PlayerNames;
            GS.AI                      = NewGameOptions.PlayerAI;
            VM_MainWindow              = new VM_MainWindow(GS, this);
            VM_MainWindow.PlayerColors = NewGameOptions.PlayerColors;
            MainWindow.DataContext     = VM_MainWindow;
            MainWindow.Show();
            NewGameWindow.Close();
        }
예제 #11
0
        public void PlayerChange_backToStart()
        {
            //Arrange
            VM_MainWindow vm   = new VM_MainWindow();
            Game_Main     Game = new Game_Main(vm);

            Game.GameState.ActivePlayer = 3;
            int expected = 0;

            //Act
            Game.ChangePlayer();

            //Assert
            int actual = Game.GameState.ActivePlayer;

            Assert.AreEqual(expected, actual, "Failed. actual:" + actual.ToString());
        }
예제 #12
0
        public void VictoryConditions_OneWinner()
        {
            //Arrange:
            VM_MainWindow vm   = new VM_MainWindow();
            Game_Main     game = new Game_Main(vm);

            game.GameState.PawnPosition[2] = new int[4] {
                48, 51, 50, 49
            };
            bool expected_GameOver = true;
            int  expected_Winner   = 2;

            //Act:
            game.VictoryConditions();

            //Assert:
            bool actual_GameOver = game.GameState.GameOver;
            int  actual_Winner   = game.GameState.Winner;

            Assert.AreEqual(expected_Winner, actual_Winner, "Failed. actual:" + actual_Winner.ToString());
            Assert.AreEqual(expected_GameOver, actual_GameOver, "Failed. actual:" + actual_GameOver.ToString());
        }
예제 #13
0
        public void MovePawn_NoBeating_InGoalArea()
        {
            //Arrange:
            VM_MainWindow VM = new VM_MainWindow();
            GameState     GS = VM.GameState;

            GS.ActivePlayer = 3;
            int PawnID = 2;

            GS.PawnPosition[GS.ActivePlayer][PawnID] = 45;
            GS.PawnOptions = new int[4] {
                90, 33, 87, 90
            };

            int expected = 87;

            //Act:
            VM.Game.PawnMovement.MovePawn(PawnID);

            //Assert:
            int actual = GS.PawnPosition[GS.ActivePlayer][PawnID];

            Assert.AreEqual(expected, actual);
        }
예제 #14
0
        public void MovePawn_NoBeating_OutOfHouse()
        {
            //Arrange:
            VM_MainWindow VM = new VM_MainWindow();
            GameState     GS = VM.GameState;

            GS.ActivePlayer = 1;
            int PawnID = 0;

            GS.PawnPosition[GS.ActivePlayer][PawnID] = -1;
            GS.PawnOptions = new int[4] {
                0, 33, 45, 90
            };

            int expected = 0;

            //Act:
            VM.Game.PawnMovement.MovePawn(PawnID);

            //Assert:
            int actual = GS.PawnPosition[GS.ActivePlayer][PawnID];

            Assert.AreEqual(expected, actual);
        }
예제 #15
0
 public VM_MainWindow()
 {
     _instance = this;
 }
예제 #16
0
 public App()
 {
     _Instance = this;
     InitEnv();
     vm_MainWindow = new VM_MainWindow();
 }
 private void Window_Loaded(object sender, RoutedEventArgs args)
 {
     DataContext = new VM_MainWindow();
 }
예제 #18
0
 public Game_Main(VM_MainWindow vm)
 {
     this.VM           = vm;
     this.GameState    = VM.GameState;
     this.PawnMovement = new Pawn_Movement(this);
 }
예제 #19
0
        public void BoardView_AllInGoal()
        {
            //Arrange:
            VM_MainWindow VM = new VM_MainWindow();

            VM.GameState.PawnPosition[0] = new int[4] {
                52 - 4, 53 - 4, 54 - 4, 55 - 4
            };
            VM.GameState.PawnPosition[1] = new int[4] {
                55 - 4, 53 - 4, 54 - 4, 52 - 4
            };
            VM.GameState.PawnPosition[2] = new int[4] {
                55 - 4, 54 - 4, 53 - 4, 52 - 4
            };
            VM.GameState.PawnPosition[3] = new int[4] {
                54 - 4, 52 - 4, 53 - 4, 55 - 4
            };

            List <int[]> expected = new List <int[]>();

            for (int i = 0; i < 90; i++)
            {
                expected.Add(new int[2] {
                    9, 9
                });
            }
            expected[50 + 5] = new int[2] {
                0, 0
            };
            expected[51 + 5] = new int[2] {
                0, 1
            };
            expected[52 + 5] = new int[2] {
                0, 2
            };
            expected[53 + 5] = new int[2] {
                0, 3
            };

            expected[63 + 5] = new int[2] {
                1, 0
            };
            expected[61 + 5] = new int[2] {
                1, 1
            };
            expected[62 + 5] = new int[2] {
                1, 2
            };
            expected[60 + 5] = new int[2] {
                1, 3
            };

            expected[73 + 5] = new int[2] {
                2, 0
            };
            expected[72 + 5] = new int[2] {
                2, 1
            };
            expected[71 + 5] = new int[2] {
                2, 2
            };
            expected[70 + 5] = new int[2] {
                2, 3
            };

            expected[82 + 5] = new int[2] {
                3, 0
            };
            expected[80 + 5] = new int[2] {
                3, 1
            };
            expected[81 + 5] = new int[2] {
                3, 2
            };
            expected[83 + 5] = new int[2] {
                3, 3
            };


            //Act:
            VM.Change_BoardView();

            //Assert:
            List <int[]> actual          = VM.BoardView;
            string       expected_string = "";
            string       actual_string   = "";

            for (int i = 0; i < 90; i++)
            {
                expected_string = expected_string + expected[i][0].ToString() + "," + expected[i][1].ToString() + "|";
                actual_string   = actual_string + actual[i][0].ToString() + "," + actual[i][1].ToString() + "|";
            }
            Assert.AreEqual(expected_string, actual_string);
        }