private void GridButtonStyler(Field btn) { int x = btn.X; int y = btn.Y; btn.Text += " S"; if (_model.getBoard()[x, y] == FieldType.NO_WALL) { btn.ImgSrc = "/View/stone.png"; } else if (_model.getBoard()[x, y] == FieldType.WALL) { btn.ImgSrc = "/View/brick.png"; } else if (_model.getBoard()[x, y] == FieldType.CANNOT_WALL) { btn.ImgSrc = "/View/cobble.png"; } else if (_model.getBoard()[x, y] == FieldType.MAGNET) { btn.ImgSrc = "/View/magnet.png"; } if (_model.getRobotPos().Equals(new Position(x, y))) { btn.ImgSrc = "/View/robot.png"; } }
public void ConstructorCheck() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; RoboChaseInfo gameInfo = new RoboChaseInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); RoboChaseModel gameModel = new RoboChaseModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); RoboChaseInfo gameInfo11 = new RoboChaseInfo(11, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); gameModel.newGame(11, gameInfo11); Assert.AreEqual(gameModel.getRobotPos(), gameInfo11.robot); Assert.AreEqual(gameModel.getSize(), 11); Assert.AreEqual(gameInfo11.size, 11); for (int i = 0; i < 10; i++) { int prev = gameModel.getTime(); gameModel.AdvanceTime(this, new System.EventArgs()); if (gameModel.isInGame()) { Assert.IsTrue(prev < gameModel.getTime()); } } }
public async Task LoadCheck() { _model.newGame(5); Assert.AreEqual(_model.getSize(), 5); RoboChaseInfo gameInfo = await _model.loadFromFileAsync(String.Empty); _model.newGame(gameInfo.size, gameInfo); _mock.Verify(dataAccess => dataAccess.LoadAsync(String.Empty), Times.Once()); Assert.AreEqual(_model.getRobotPos(), gameInfo.robot); Assert.AreEqual(_model.getSize(), 11); Assert.AreEqual(gameInfo.size, 11); Assert.AreEqual(gameInfo.time, (ulong)0); Assert.AreEqual(_model.getTime(), 0); for (int i = 0; i < 10; i++) { int prev = _model.getTime(); _model.AdvanceTime(this, new System.EventArgs()); if (_model.isInGame()) { Assert.IsTrue(prev < _model.getTime()); } } }
public void MoveRobot() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; RoboChaseInfo gameInfo = new RoboChaseInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); RoboChaseModel gameModel = new RoboChaseModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); gameModel.AdvanceTime(this, new System.EventArgs()); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Console.WriteLine(gameModel.getRobotPos().X + ", " + gameModel.getRobotPos().Y); Assert.AreEqual(gameModel.getRobotPos(), new Position(1, 0)); gameInfo.robotDir = RobotDirection.DOWN; gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getRobotPos(), new Position(1, 1)); gameInfo.robotDir = RobotDirection.RIGHT; gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getRobotPos(), new Position(2, 1)); gameInfo.robotDir = RobotDirection.LEFT; gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getRobotPos(), new Position(1, 1)); }