示例#1
0
        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;

            CrazyBotInfo  gameInfo  = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy);
            CrazyBotModel gameModel = new CrazyBotModel();

            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);
        }
示例#2
0
        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;

            CrazyBotInfo  gameInfo  = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy);
            CrazyBotModel gameModel = new CrazyBotModel();

            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);
        }
示例#3
0
        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;

            CrazyBotInfo  gameInfo  = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy);
            CrazyBotModel gameModel = new CrazyBotModel();

            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);
        }
示例#4
0
 public void gridButtonClicked(object obj, EventArgs e)
 {
     model.invertWall((obj as GridButton).getPosition());
 }