public void WalkOnCannotWall() { 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); gameModel.AdvanceTime(this, new System.EventArgs()); //Place walls Assert.AreEqual(gameModel.getBoard()[2, 4], FieldType.NO_WALL); gameModel.invertWall(new Position(2, 4)); Assert.AreEqual(gameModel.getBoard()[2, 4], FieldType.WALL); gameInfo.robot = new Position(2, 5); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getBoard()[2, 4], FieldType.CANNOT_WALL); }
private void drawBoard() { Fields.Clear(); for (Int32 i = 0; i < _model.getSize(); i++) { for (Int32 j = 0; j < _model.getSize(); j++) { Field toAdd = new Field { Text = (_model.getBoard()[i, j]).ToString() + ", " + i.ToString() + ", " + j.ToString(), X = i, Y = j, Number = i * _model.getSize() + j, StepCommand = new DelegateCommand(param => StepGame(Convert.ToInt32(param))) }; GridButtonStyler(toAdd); Fields.Add(toAdd); } } }
public void HitPlacedWall() //TODO: CSINÁLD MEG A MOCK-OLÁST { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.RIGHT; 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); RobotDirection prevDir; gameModel.AdvanceTime(this, new EventArgs()); //Place walls and hit it from RIGHT prevDir = gameInfo.robotDir; Assert.AreEqual(gameModel.getBoard()[2, 1], FieldType.NO_WALL); gameModel.invertWall(new Position(2, 1)); Assert.AreEqual(gameModel.getBoard()[2, 1], FieldType.WALL); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getBoard()[2, 1], FieldType.CANNOT_WALL); Assert.AreNotEqual(prevDir, gameInfo.robotDir); //Place walls and hit it from LEFT; gameInfo.robotDir = RobotDirection.LEFT; prevDir = gameInfo.robotDir; gameInfo.robot = new Position(2, 2); Assert.AreEqual(gameModel.getBoard()[1, 2], FieldType.NO_WALL); gameModel.invertWall(new Position(1, 2)); Assert.AreEqual(gameModel.getBoard()[1, 2], FieldType.WALL); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getBoard()[1, 2], FieldType.CANNOT_WALL); Assert.AreNotEqual(prevDir, gameInfo.robotDir); //Place walls and hit it from UP; gameInfo.robotDir = RobotDirection.UP; prevDir = gameInfo.robotDir; gameInfo.robot = new Position(5, 3); Assert.AreEqual(gameModel.getBoard()[5, 2], FieldType.NO_WALL); gameModel.invertWall(new Position(5, 2)); Assert.AreEqual(gameModel.getBoard()[5, 2], FieldType.WALL); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getBoard()[5, 2], FieldType.CANNOT_WALL); Assert.AreNotEqual(prevDir, gameInfo.robotDir); //Place walls and hit it from DOWN; gameInfo.robotDir = RobotDirection.DOWN; prevDir = gameInfo.robotDir; gameInfo.robot = new Position(4, 3); Assert.AreEqual(gameModel.getBoard()[4, 4], FieldType.NO_WALL); gameModel.invertWall(new Position(4, 4)); Assert.AreEqual(gameModel.getBoard()[4, 4], FieldType.WALL); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getBoard()[1, 2], FieldType.CANNOT_WALL); Assert.AreNotEqual(prevDir, gameInfo.robotDir); }
public void PlaceWalls() { 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); //Place walls Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.NO_WALL); gameModel.invertWall(new Position(6, 6)); Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.NO_WALL); gameModel.invertWall(new Position(3, 1)); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.NO_WALL); gameModel.invertWall(new Position(2, 5)); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.WALL); //Try to pick up those walls Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.WALL); gameModel.invertWall(new Position(6, 6)); Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.WALL); gameModel.invertWall(new Position(3, 1)); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.WALL); gameModel.invertWall(new Position(2, 5)); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.WALL); //Try place walls on robot and magnet Console.WriteLine(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y].ToString()); Assert.IsTrue(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y] == FieldType.ROBOT); gameModel.invertWall(new Position(gameInfo.robot.X, gameInfo.robot.Y)); Assert.IsTrue(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y] == FieldType.ROBOT); Assert.IsFalse(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y] == FieldType.WALL); Assert.IsTrue(gameModel.getBoard()[gameModel.getMagnetPos().X, gameModel.getMagnetPos().Y] == FieldType.MAGNET); gameModel.invertWall(new Position(6, 6)); Assert.IsTrue(gameModel.getBoard()[gameModel.getMagnetPos().X, gameModel.getMagnetPos().Y] == FieldType.MAGNET); Assert.IsFalse(gameModel.getBoard()[gameModel.getMagnetPos().X, gameModel.getMagnetPos().Y] == FieldType.WALL); }