コード例 #1
0
ファイル: LobbyServiceTest.cs プロジェクト: ChrisRu/ludo-api
        public void TestGetLobby()
        {
            var lobbyService = new LobbyService();
            var createdLobby = lobbyService.CreateLobby("apples", null);

            var lobby = lobbyService.GetLobby("apples");

            Assert.Same(createdLobby, lobby);
        }
コード例 #2
0
ファイル: LobbyServiceTest.cs プロジェクト: ChrisRu/ludo-api
        public void TestGetLobbyNonExisting()
        {
            var lobbyService = new LobbyService();
            var createdLobby = lobbyService.CreateLobby("apples", null);

            var lobby = lobbyService.GetLobby("pears");

            Assert.NotSame(createdLobby, lobby);
            Assert.Null(lobby);
        }
コード例 #3
0
        public void StartNewGame(string lobbyId)
        {
            var lobby = lobbyService.GetLobby(lobbyId);

            if (lobby == null)
            {
                throw new NullReferenceException("Lobby could not be found");
            }
            else
            {
                CardGame cardGame = cardGameRepository.CreateNewGame(lobbyId, lobby.Players);
                cardGame.Players.ForEach(player => {
                    player.Phase = phaseService.CreateNewPhase(player.Id, PhaseType.One);
                    player.Stage = Stage.Waiting;
                });
                cardGame.Players[0].Stage = Stage.Draw;
                cardGame.DealRound();
                cardGame.SetActivePlayer(cardGame.Players[0].Id);
                cardGame.StartPlayerId = cardGame.Players[0].Id;

                cardGameRepository.UpdateGame(cardGame);
                lobbyHub.Clients.Group(lobbyId).StartGame();
            }
        }