Ejemplo n.º 1
0
        public void TestChangeOptionsPieceProviderOccuranciesModified()
        {
            GameOptions originalOptions = new GameOptions();
            originalOptions.Initialize(GameRules.Custom);
            IGame game = CreateGame("game1", 5, 10, GameRules.Custom, originalOptions);
            game.Start(new CancellationTokenSource());
            IClient client1 = CreateClient("client1", new CountCallTetriNETCallback());
            game.Join(client1, false);

            GameOptions newOptions = new GameOptions();
            newOptions.Initialize(GameRules.Standard);
            game.ChangeOptions(client1, newOptions);

            Assert.IsNotNull(PieceProvider.Occurancies);
            Assert.AreEqual(newOptions.PieceOccurancies, PieceProvider.Occurancies());
        }
Ejemplo n.º 2
0
 protected override IGame CreateGame(string name, int maxPlayers, int maxSpectators)
 {
     GameOptions options = new GameOptions();
     options.Initialize(GameRules.Standard);
     return CreateGame(name, maxPlayers, maxSpectators, GameRules.Classic, options);
 }
Ejemplo n.º 3
0
        public void TestChangeOptionsClientsInformed()
        {
            GameOptions originalOptions = new GameOptions();
            originalOptions.Initialize(GameRules.Custom);
            IGame game = CreateGame("game1", 5, 10, GameRules.Custom, originalOptions);
            game.Start(new CancellationTokenSource());
            CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback();
            IClient client1 = CreateClient("client1", callback1);
            game.Join(client1, false);
            CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback();
            IClient client2 = CreateClient("client2", callback2);
            game.Join(client2, true);
            CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback();
            IClient client3 = CreateClient("client3", callback3);
            game.Join(client3, false);

            GameOptions newOptions = new GameOptions();
            newOptions.Initialize(GameRules.Custom);
            game.ChangeOptions(client1, newOptions);

            Assert.AreEqual(1, callback1.GetCallCount("OnGameOptionsChanged"));
            Assert.AreEqual(1, callback2.GetCallCount("OnGameOptionsChanged"));
            Assert.AreEqual(1, callback3.GetCallCount("OnGameOptionsChanged"));
        }
Ejemplo n.º 4
0
        public void TestChangeOptionsOkWhenWaitingGameStart()
        {
            GameOptions originalOptions = new GameOptions();
            originalOptions.Initialize(GameRules.Custom);
            IGame game = CreateGame("game1", 5, 10, GameRules.Custom, originalOptions);
            game.Start(new CancellationTokenSource());
            IClient client1 = CreateClient("client1", new CountCallTetriNETCallback());
            game.Join(client1, false);

            GameOptions newOptions = new GameOptions();
            newOptions.Initialize(GameRules.Custom);
            game.ChangeOptions(client1, newOptions);

            Assert.AreEqual(newOptions, game.Options);
        }
Ejemplo n.º 5
0
        public void TestChangeOptionsFailedIfNotGameMaster()
        {
            GameOptions originalOptions = new GameOptions();
            originalOptions.Initialize(GameRules.Custom);
            IGame game = CreateGame("game1", 5, 10, GameRules.Custom, originalOptions);
            game.Start(new CancellationTokenSource());
            IClient client1 = CreateClient("client1", new CountCallTetriNETCallback());
            game.Join(client1, false);
            IClient client2 = CreateClient("client2", new CountCallTetriNETCallback());
            game.Join(client2, false);

            GameOptions newOptions = new GameOptions();
            newOptions.Initialize(GameRules.Custom);
            bool succeed = game.ChangeOptions(client2, newOptions);

            Assert.AreEqual(originalOptions, game.Options);
            Assert.IsFalse(succeed);
        }
Ejemplo n.º 6
0
 protected override IGame CreateGame(string name)
 {
     GameOptions options = new GameOptions();
     options.Initialize(GameRules.Standard);
     return new Game(new ActionQueueMock(), new PieceProviderMock(), name, 10, 10, GameRules.Standard, options);
 }