示例#1
0
        public string JoinGame(ulong guildId, ulong chanId, ulong playerId)
        {
            AGame game = _games.Find(x => x.IsSelf(chanId));

            if (game == null)
            {
                return(Sentences.LobbyNoWaiting(guildId));
            }
            if (!game.IsWaitingForPlayers())
            {
                return(Sentences.LobbyNoWaiting(guildId));
            }
            if (!game.HaveMultiplayerLobby())
            {
                return(Sentences.LobbySoloJoin(guildId));
            }
            if (game.IsFull())
            {
                return(Sentences.LobbyFull(guildId));
            }
            if (game.IsPlayerInLobby(playerId))
            {
                return(Sentences.LobbyAlreadyInThis(guildId));
            }
            if (_games.Any(x => x.IsPlayerInLobby(playerId)))
            {
                return(Sentences.LobbyAlreadyIn(guildId));
            }
            game.AddPlayerToLobby(playerId);
            return(Sentences.LobbyJoined(guildId, game.GetName()));
        }
示例#2
0
        public string LeaveGame(ulong guildId, ulong chanId, ulong playerId)
        {
            AGame game = _games.Find(x => x.IsSelf(chanId));

            if (game == null)
            {
                return(Sentences.LobbyNoWaiting(guildId));
            }
            if (!game.IsWaitingForPlayers())
            {
                return(Sentences.LobbyAlreadyStarted(guildId));
            }
            if (!game.HaveMultiplayerLobby())
            {
                return(Sentences.LobbySoloLeave(guildId));
            }
            if (!game.IsPlayerInLobby(playerId))
            {
                return(Sentences.LobbyAlreadyOut(guildId));
            }
            game.RemovePlayerFromLobby(playerId);
            return(Sentences.LobbyLeaved(guildId) + (game.IsLobbyEmpty() ? Environment.NewLine + Sentences.LobbyEmpty(guildId) : ""));
        }
示例#3
0
        public async Task <string> StartGame(ulong guildId, ulong chanId, ulong playerId)
        {
            AGame game = _games.Find(x => x.IsSelf(chanId));

            if (game == null)
            {
                return(Sentences.LobbyNoWaiting(guildId));
            }
            if (!game.IsWaitingForPlayers())
            {
                return(Sentences.LobbyNoWaiting(guildId));
            }
            if (!game.IsPlayerInLobby(playerId))
            {
                return(Sentences.LobbyAlreadyOut(guildId));
            }
            if (!game.HaveEnoughPlayer())
            {
                return(Sentences.LobbyNotEnoughPlayer(guildId));
            }
            await game.Start();

            return(null);
        }