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); }
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); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game_Main game = new Game_Main()) { game.Run(); } }
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()); }
/// <summary> /// Die Funktion wird aufgerufen, wenn ein Feld der verschiedenen Modi angeklickt wird. /// Hierbei wird ein Parameter übergeben, der den gewählten Modus beschreibt. /// Im Anschluss wird eine neues Objekt der Klasse Game_Main erzeugt und damit ein Spielgestartet, /// indem die Funktion Game.Start aufgerufen wird und als Parameter die Informationen über den gewählten Modus übergeben. /// 1.Stelle: Startspieler 2.Stelle: zweiter Spieler /// Einträge: 0:Nutzer, 1:zufällige KI, 2:lernende KI /// Auch werden im Anschluss die Button für die Modi deaktiviert und die Feldbuttons aktiviert. /// </summary> /// <param name="obj"></param> public void ChooseMode(object obj) { CanExecute_Field = true; CanExecute_Menu = false; GameInProgress = true; Game = new Game_Main(this); int[] playerTypes = new int[2]; string param = obj.ToString(); for (int i = 0; i < 2; i++) { playerTypes[i] = Int32.Parse(param.Substring(i, 1)); } Game.Start(playerTypes); OnNotifyPropertyChanged("GameState"); }
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()); }
//Konstruktor public VM_MainWindow(GameState gameState, MainController controller) { //Initialisieren von Game und GameState GameState = gameState; Controller = controller; Game = new Game_Main(this); //soll eine Konstante sein Field_GridX = new int[90] { 8, 8, 8, 8, 7, 6, 6, 6, 5, 4, 3, 3, 3, 4, 5, 6, 6, 6, 7, 8, 8, 8, 8, 9, 10, 10, 10, 10, 11, 12, 12, 12, 13, 14, 15, 15, 15, 14, 13, 12, 12, 12, 11, 10, 10, 10, 10, 9, 0, 0, 7, 6, 6, 7, 0, 9, 9, 9, 9, 0, 3, 3, 4, 4, 0, 4, 5, 6, 7, 0, 11, 12, 12, 11, 0, 9, 9, 9, 9, 0, 15, 15, 14, 14, 0, 14, 13, 12, 11, 0 }; Field_GridY = new int[90] { 16, 15, 14, 13, 13, 13, 12, 11, 11, 11, 11, 10, 9, 9, 9, 9, 8, 7, 7, 7, 6, 5, 4, 4, 4, 5, 6, 7, 7, 7, 8, 9, 9, 9, 9, 10, 11, 11, 11, 11, 12, 13, 13, 13, 14, 15, 16, 16, 0, 0, 16, 16, 15, 15, 0, 15, 14, 13, 12, 0, 8, 7, 7, 8, 0, 10, 10, 10, 10, 0, 4, 4, 5, 5, 0, 5, 6, 7, 8, 0, 12, 13, 13, 12, 0, 10, 10, 10, 10, 0 }; //Initialisieren der BoardView und setzen alle Feldfarben. BoardView = new List <int[]>(); Field_Color = new string[90]; for (int i = 0; i < 90; i++) { BoardView.Add(new int[2] { 9, 9 }); Field_Color[i] = "beige"; } //Pöppel an ihre Startpositionen setzen Pawn_PositionX = new int[16]; Pawn_PositionY = new int[16]; Pawn_Active = new string[16]; for (int i = 0; i < 4; i++) { for (int k = 0; k < 4; k++) { Pawn_PositionX[(4 * i) + k] = Field_GridX[50 + (10 * i) + k]; Pawn_PositionY[(4 * i) + k] = Field_GridY[50 + (10 * i) + k]; Pawn_Active[(4 * i) + k] = "black"; } } //Farben bestimmen Color_Background = "lightgray"; Color_EmptyField = "Beige"; Color_Player = new string[4]; Color_Player[0] = "red"; Color_Player[1] = "blue"; Color_Player[2] = "yellow"; Color_Player[3] = "green"; PlayerColors = new int[4][]; PlayerColors[0] = new int[3] { 200, 0, 0 }; PlayerColors[1] = new int[3] { 0, 0, 200 }; PlayerColors[2] = new int[3] { 100, 100, 0 }; PlayerColors[3] = new int[3] { 0, 200, 0 }; //Texte Text_Die = "X"; Text_Information = "Hier stehen Dinge."; //Commands Cmd_TestClick = new RelayCommand(TestClick); Cmd_DiePhase = new RelayCommand(DiePhase_Start, parameter => GameState.InDiePhase); Cmd_MovePhase = new RelayCommand(MovePhase_Start); CanEnable_NewGame = true; Cmd_NewGame = new RelayCommand(NewGame, parameter => CanEnable_NewGame); RefreshView_MovePhase(); }