Exemplo n.º 1
0
        static Game CreateSampleGame1(int seed)
        {
            var game    = new Game(seed);
            var player  = new GameActor(GameActor.Alignment.Player, "alice");
            var player2 = new GameActor(GameActor.Alignment.Player, "bob");
            var mob     = new GameActor(GameActor.Alignment.Mob, "carly");
            var mob2    = new GameActor(GameActor.Alignment.Mob, "denise");

            // set targeting and affinities
            player.AddAction(new ActionChooseRandomTarget(GameActor.Alignment.Mob));
            player2.AddAction(new ActionChooseRandomTarget(GameActor.Alignment.Mob));
            mob.AddAction(new ActionChooseRandomTarget(GameActor.Alignment.Player));
            mob2.AddAction(new ActionChooseRandomTarget(GameActor.Alignment.Player));

            player.AddAction(new ActionAttack());
            player2.AddAction(new ActionAttack());
            mob.AddAction(new ActionAttack());
            mob2.AddAction(new ActionAttack());

            player.Weapon  = new GameWeapon("alice's axe", 22);
            player2.Weapon = new GameWeapon("bob's burger", 12);
            mob.Weapon     = new GameWeapon("carly's cutlass", 33);
            mob2.Weapon    = new GameWeapon("denise's dog", 5);

            game.AddActor(player);
            game.AddActor(player2);
            game.AddActor(mob);
            game.AddActor(mob2);
            return(game);
        }
Exemplo n.º 2
0
        public TestGameWithActors(int seed = 2112)
        {
            game = new Game(seed);

            playerAlice.AddAction(playerMockAction);
            mobCarly.AddAction(mobMockAction);

            game.AddActor(playerAlice);
            game.AddActor(playerBob);
            game.AddActor(mobCarly);
            game.AddActor(mobDenise);
        }
Exemplo n.º 3
0
        public void EnumerateTurnShouldRunAllActions()
        {
            var game   = new Game();
            var player = new GameActor(GameActor.Alignment.Player);
            var mob    = new GameActor(GameActor.Alignment.Mob);

            var mock1 = new MockAction();
            var mock2 = new MockAction();

            player.AddAction(mock1);
            mob.AddAction(mock2);
            game.AddActor(player);
            game.AddActor(mob);

            var turns = game.EnumerateRound();

            while (turns.MoveNext())
            {
                ;
            }

            Assert.AreEqual(1, mock1.timesCalled);
            Assert.AreEqual(1, mock2.timesCalled);
            Assert.IsTrue(mock1.orderCalledIn < mock2.orderCalledIn);
        }
Exemplo n.º 4
0
        static Game CreateSampleGame2(RNG rng)
        {
            var game = new Game(rng);

            GameActor CreatePlayer(string name, string weaponName, int weaponDmg)
            {
                var player = new GameActor(GameActor.Alignment.Player, name, 10)
                {
                    Weapon = new GameWeapon(weaponName, weaponDmg)
                };

                player.AddAction(new ActionChooseRandomTarget(GameActor.Alignment.Mob));
                player.AddAction(new ActionAttack());
                player.SetScrypt(ScryptUtil.defaultAttack);
                return(player);
            }

            game.AddActor(CreatePlayer("Andrew", "ahlspiess", 4));
            game.AddActor(CreatePlayer("Beatrice", "bow", 5));
            game.AddActor(CreatePlayer("Candy", "cutlass", 6));
            game.AddActor(CreatePlayer("Dierdre", "dagger", 3));
            return(game);
        }
Exemplo n.º 5
0
        public void ActionEnumeratorShouldCallActions()
        {
            Game      game  = new Game();
            GameActor actor = new GameActor();

            MockAction action1 = new MockAction();
            MockAction action2 = new MockAction();

            actor.AddAction(action1);
            actor.AddAction(action2);

            var actions = actor.EnumerateActions(game);

            while (actions.MoveNext())
            {
                ;
            }

            Assert.AreEqual(action1.timesCalled, 1);
            Assert.AreEqual(action2.timesCalled, 1);
            Assert.IsTrue(action1.orderCalledIn < action2.orderCalledIn);
            Assert.AreEqual(action1.gCalledWith, game);
            Assert.AreEqual(action1.aCalledWith, actor);
        }