Ejemplo n.º 1
0
        public void TestSquareAttributeRestrictions()
        {
            Map map = new Map(3, 2);

            map.AddSpawner(new Position(0, 0));
            map.AddSpawner(new Position(1, 0));
            map.AddSpawner(new Position(2, 0));

            SquareType fireland = new SquareType();

            fireland.AllowedAttributes.Add("firey");
            fireland.ForbiddenAttributes.Add("holy");

            map.SetSquareTypeAt(new Position(0, 1), fireland);
            map.SetSquareTypeAt(new Position(1, 1), fireland);
            map.SetSquareTypeAt(new Position(2, 1), fireland);

            Character normal_beast     = new Character("normal_beast", "normal_beast");
            Character firey_beast      = new Character("firey_beast", "firey_beast");
            Character holy_firey_beast = new Character("holy_firey_beast", "holy_firey_beast");

            firey_beast.SetAttribute("firey");
            holy_firey_beast.SetAttribute("firey");
            holy_firey_beast.SetAttribute("holy");

            Config config = new Config();

            config.Map = map;
            config.CharacterConfig.ActionPoints = 10;

            Game game = new Game(config);

            List <Character> characters = new List <Character>()
            {
                normal_beast, firey_beast, holy_firey_beast
            };

            game.SetupPlayers(characters);

            game.Start();

            try
            {
                game.DoAction(Game.BasicActions.Movement, Game.MovementParameters.South);
                Assert.Fail();
            } catch (GameException ge)
            {
                Assert.AreEqual("This character is not allowed to step on this square", ge.Message);
            }

            game.DoAction(Game.BasicActions.EndTurn);

            try
            {
                game.DoAction(Game.BasicActions.Movement, Game.MovementParameters.South);
            }
            catch (GameException)
            {
                Assert.Fail();
            }

            game.DoAction(Game.BasicActions.EndTurn);

            try
            {
                game.DoAction(Game.BasicActions.Movement, Game.MovementParameters.South);
                Assert.Fail();
            }
            catch (GameException ge)
            {
                Assert.AreEqual("This character is not allowed to step on this square", ge.Message);
            }
        }