public async Task <ActionResult <MineSweeper> > PostMineSweeper(MineSweeper mineSweeper) { _context.MineSweeperItems.Add(mineSweeper); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetMineSweeper), new { id = mineSweeper.id }, mineSweeper)); }
public virtual void CheckForVictory() { bool IsClear = true; Tile t; for (int x = 0; x < fieldSize.X; x++) { for (int y = 0; y < fieldSize.Y; y++) { t = tiles[x][y][0]; if (!t.IsOpened && !t.IsFlagged && t.CurrentState > -1) { IsClear = false; break; } } if (!IsClear) { break; } } if (IsClear) { MineSweeper.InvokeLevelWon(); } }
// Difficulty button event public void Difficulty_Click(object sender, EventArgs e) { // Get the name of the sender object String name = ((Button)sender).Name; // Make progress bar visible progressBar.Visible = true; // Setup the game switch (name) { case "btnEasy": game = new MineSweeper(1, progressBar); break; case "btnMedium": game = new MineSweeper(2, progressBar); break; case "btnHard": game = new MineSweeper(3, progressBar); break; case "btnNightmare": game = new MineSweeper(4, progressBar); break; } PlayGame(); }
public void GetMarkedMineFieldReturnsCorrectResult() { var sut = new MineSweeper(); var mineField = new[] { "...*.*", "*....*", "..*.*.", "*....*", "...*..", "......" }; var expected = new[] { "111*3*", "*2234*", "23*2*3", "*2233*", "111*21", "001110" }; var actual = sut.GetMarkedMineField(mineField); Assert.Equal(expected, actual); }
public async Task <IActionResult> PutMineSweeper(long id, MineSweeper mineSweeper) { if (id != mineSweeper.id) { return(BadRequest()); } _context.Entry(mineSweeper).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MineSweeperExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override void StartGame(MineSweeper mineSweeper) { mineSweeper.Width = 515; mineSweeper.Height = 562; board = new Board(mineSweeper, 10, 10, 50); board.InitializeBoard(); }
public override void StartGame(MineSweeper mineSweeper) { mineSweeper.Width = 615; mineSweeper.Height = 663; board = new Board(mineSweeper, 12, 12, 80); board.InitializeBoard(); }
// Start is called before the first frame update void Start() { playerObject = FindObjectOfType <MineSweeper>(); objectiveObject = FindObjectOfType <BattleShip>(); Port.PlayerSavedAShipEvent += OnPlayerSavesShip; }
public override void StartGame(MineSweeper mineSweeper) { mineSweeper.Height = 463; mineSweeper.Width = 416; board = new Board(mineSweeper, 8, 8, 10); board.InitializeBoard(); }
public void IsMine_Asterix_ReturnsTrue() { var sweeper = new MineSweeper(); var result = sweeper.IsMine('*'); Assert.IsTrue(result); }
// Update is called once per frame void Update() { if (goal == null) { goal = FindObjectOfType <Port>(); } shipsSavedDisplay.text = " " + ships; if (playerObject == null) { playerObject = FindObjectOfType <MineSweeper>(); } if (playerObject != null) { mineSweeperHPLabel.text = playerObject.hitPoints.ToString(); } if (objectiveObject == null) { objectiveObject = FindObjectOfType <BattleShip>(); } if (objectiveObject != null) { battleShipHPLabel.text = objectiveObject.hitPoints.ToString(); } }
public void IsMine_NotAsterix_ReturnsFalse() { var sweeper = new MineSweeper(); var result = sweeper.IsMine('.'); Assert.IsFalse(result); }
public MineSweeperUI() { game = new MineSweeper(); buttonsUI = new Button[MAX_BOUNDS, MAX_BOUNDS]; game.setMines(2); InitializeComponent(); }
public void it_should_contain_elements() { var field = new MineField(3, 4, new List <string> { "*...", "*.*.", "...." }); var sweeper = new MineSweeper(field); Assert.AreEqual(true, sweeper.GenerateSolution().Any()); }
/// <summary> /// This method will keep looping until a bug is found, or if the player closes the program. /// </summary> private static void Update() { #region Game-Diff-Selection // Write instructions + information to Console. TextManager.WriteLine("Select a game: "); foreach (var index in IndexToGameMode) { TextManager.WriteLine($"{index.Key}. {index.Value}"); } TextManager.WriteLine(); TextManager.WriteLine("Enter a number to select game: \n", ConsoleColor.Green); // Get gamemode from user input var gameIndex = GetIndexFromUserInput(IndexToGameMode.Count); var gameName = IndexToGameMode[gameIndex]; // Write instrutions + information to Console. TextManager.Clear(); TextManager.WriteLine($"Game Selected: {gameName}"); foreach (var index in IndexToDifficulty) { TextManager.WriteLine($"{index.Key}. {index.Value}"); } TextManager.WriteLine(); TextManager.WriteLine("Enter a number to select difficulty: \n", ConsoleColor.Green); // Get game difficulty from user input var difficultyIndex = GetIndexFromUserInput(IndexToDifficulty.Count); var difficulty = IndexToDifficulty[difficultyIndex]; // Write instructions + information to Console. TextManager.Clear(); TextManager.WriteLine($"Game Selected: {gameName}"); TextManager.WriteLine($"Difficulty Selected: {difficulty}"); TextManager.WriteLineBreak(); TextManager.WriteLine(); #endregion // Start game depending on what the user had input. switch (gameIndex) { case 1: CurrentGame = new MineSweeper(difficulty); break; case 2: CurrentGame = new PuyoPuyo(difficulty); break; default: throw new Exception("Invalid game mode has been declared."); } // Start the game once the user has selected a game and difficulty. CurrentGame.StartGame(); }
public void CountNeighbourMines_EmptyGrid_ReturnsZero() { var sweeper = new MineSweeper(); var grid = new char[][] { }; var expected = 0; var result = sweeper.CountNeighbourMines(grid, 2, 2); Assert.AreEqual(expected, result); }
static void InputEngine_onButtonDown(InputEngine.MouseArgs e) { if (MineSweeper.IsGUI()) { currentScreen.OnButtonDown(e); } if (MineSweeper.IsField()) { s_hud.OnButtonDown(e); } }
public static void Draw() { if (MineSweeper.IsGUI()) { currentScreen.Draw(); } if (MineSweeper.IsField()) { s_hud.Draw(); } }
public static void Update() { if (MineSweeper.IsGUI()) { currentScreen.Update(); } if (MineSweeper.IsField()) { s_hud.Update(); } }
static void InputEngine_onKeyDown(InputEngine.KeyboardArgs e) { if (MineSweeper.IsGUI()) { currentScreen.OnKeyDown(e); } if (MineSweeper.IsField()) { s_hud.OnKeyDown(e); } }
public static void Draw() { MineSweeper.spriteBatch.Begin(); if (MineSweeper.IsField()) { MineSweeper.gameField.Draw(); Entity.EntityManager.Draw(); } GUI.GUIEngine.Draw(); MineSweeper.spriteBatch.End(); }
public void it_should_count_correct_mine_count_for_a_neighbourhood() { var field = new MineField(3, 4, new List <string> { "*...", "*.*.", "...." }); var sweeper = new MineSweeper(field); Assert.AreEqual("1", sweeper.GetMineCount(0, 2)); Assert.AreEqual(MineField.MINE.ToString(), sweeper.GetMineCount(0, 0)); Assert.AreEqual("3", sweeper.GetMineCount(1, 1)); }
public override void OnOpenedWOAnimation() { IsOpened = true; if (CurrentState == -1) { MineSweeper.InvokeLevelLost(); } else { MineSweeper.gameField.CheckForVictory(); } }
static void InputEngine_onButtonDown(InputEngine.MouseArgs e) { leftPressed |= (e.button == 0); rightPressed |= (e.button == 1); if (MineSweeper.IsField()) { if (e.button == 0 && e.curState.RightButton == ButtonState.Released) { allowDnD = true; DnDstart = new Vector2(e.curState.X, e.curState.Y); } } }
public override void OnOpened() { IsOpened = true; Entity.EntityManager.AddSquareFadeOut(Position, Size); if (CurrentState == -1) { MineSweeper.InvokeLevelLost(); } else { MineSweeper.gameField.CheckForVictory(); } }
// Update is called once per frame void Update() { if (minesweep == null) { isMineSweeperActive = false; minesweep = FindObjectOfType <MineSweeper>(); } if (minesweep != null) { isMineSweeperActive = true; } ClickOnCell(); }
public void ReturnEmptyField() { var mineSweeper = new MineSweeper(); const string fields = "~~~\n" + "00\n" + "~~~"; var actual = mineSweeper.Sweep(fields); const string expected = "~~~\n" + "Field #1:\n" + "~~~\n" + "\n"; Assert.AreEqual(expected, actual); }
public void CountNeighbourMines_1MineAndGivenCoordinateAtBottomCorner_ReturnsOne() { var sweeper = new MineSweeper(); var grid = new[] { new[] { '*', '.', '.' }, new[] { '*', '.', '.' }, new[] { '.', '.', '.' } }; var expected = 0; var result = sweeper.CountNeighbourMines(grid, 2, 2); Assert.AreEqual(expected, result); }
public void CountNeighbourMines_TwoMine_ReturnsTwo() { var sweeper = new MineSweeper(); var grid = new[] { new[] { '*', '.', '.' }, new[] { '*', '.', '.' }, new[] { '.', '.', '.' } }; var expected = 2; var result = sweeper.CountNeighbourMines(grid, 0, 1); Assert.AreEqual(expected, result); }
public void it_should_generate_the_correct_the_solution() { var field = new MineField(4, 4, new List <string> { "*...", "*.*.", "....", "...*" }); var sweeper = new MineSweeper(field); var solution = sweeper.GenerateSolution(); Assert.AreEqual(4, solution.Count); Assert.AreEqual("*311", solution[0]); Assert.AreEqual("*3*1", solution[1]); Assert.AreEqual("1222", solution[2]); Assert.AreEqual("001*", solution[3]); }
static void InputEngine_onButtonUp(InputEngine.MouseArgs e) { if (MineSweeper.IsField() && !InputEngine.eventHandled && !ignoreNextClick) { MineSweeper.gameField.HitTest(new Vector3(e.curState.X, e.curState.Y, 0), e.button); } ignoreNextClick = leftPressed && rightPressed; if (e.button == 0) { leftPressed = false; } if (e.button == 1) { rightPressed = false; } }
public void FullMineFieldReturnsMine() { var sut = new MineSweeper(); var mineField = new[] { "*" }; var expected = new[] { "*" }; var actual = sut.GetMarkedMineField(mineField); Assert.Equal(expected, actual); }
public void EmptyMineFieldReturnsZero() { var sut = new MineSweeper(); var mineField = new[] { "." }; var expected = new[] { "0" }; var actual = sut.GetMarkedMineField(mineField); Assert.Equal(expected, actual); }
public void MineFieldHandlesDiagonalMines(string[] mineField, string[] expected) { var sut = new MineSweeper(); var actual = sut.GetMarkedMineField(mineField); Assert.Equal(expected, actual); }
public void OneRowMineFieldReturnsCorrectResult(string source, string result) { var sut = new MineSweeper(); var mineField = new[] { source }; var expected = new[] { result }; var actual = sut.GetMarkedMineField(mineField); Assert.Equal(expected, actual); }