Пример #1
0
    public void OnChangeLobbyAccess(int access)
    {
        lobbyAccess = (LobbyAccess)access;

        if (SteamNetworkManager.Instance != null)
        {
            SteamNetworkManager.Instance.lobbyAccess = (ELobbyType)access;
        }
    }
Пример #2
0
        public Task <LobbyDataWrapper> CreateAndAddLobbyAsync(GameType type, LobbyAccess access, string name)
        {
            var createDTO = new CreateLobbyDto()
            {
                GameType    = type,
                LobbyAccess = access,
                Name        = name
            };

            return(BASE_URL.WithOAuthBearerToken(userManagerService.AccessToken).AppendPathSegment("api/lobbies").PostJsonAsync(createDTO).ReceiveJson <LobbyDataWrapper>());
        }
Пример #3
0
        public async Task <LobbyDataWrapper> CreateLobbyAs(LobbyAccess lobbyAccess, string user)
        {
            var response = await client.PostJsonAsync(
                "api/lobbies",
                new CreateLobbyDto
            {
                GameIdentifier = 0,
                LobbyAccess    = lobbyAccess,
                Name           = "Teszt lobby"
            },
                user);

            response.IsSuccessStatusCode.Should().BeTrue();
            return(JsonConvert.DeserializeObject <LobbyDataWrapper>(await response.Content.ReadAsStringAsync()));
        }
        public Error CreateLobby(string userId, int slots, LobbyAccess access, out string gameId)
        {
            gameId = null;
            if (!access.IsDefined())
            {
                return(Error.Codes.E08InvalidLobbyAccessValue);
            }
            if (!Users.ContainsId(Id.Partial(userId)))
            {
                return(Error.Codes.E02UserNotFound, userId);
            }
            if (!GameLogic.SessionFactory.IsValid.PlayerCount(slots))
            {
                return(Error.Codes.E05InvalidSlotCount);
            }
            var lobby = new SetupPhase(userId, slots, access);
            var game  = new Game(lobby);

            gameId = Games.CreateGame(game).Encoded;
            return(Error.Codes.E00NoError);
        }
 public Error TryCreateLobby(string userId, int?slotCount, LobbyAccess access, out string gameId)
 => ludoService.CreateLobby(userId, slotCount ?? MaxSlots, access, out gameId);
Пример #6
0
        public async Task <LobbyDataWrapper> CreateAndAddLobbyAsync(int gameIdentifier, LobbyAccess access, string name)
        {
            var currentUser = identityService.GetCurrentUserName();

            if (lobbyStorage.GetLobbyOfUser(currentUser) != null)
            {
                throw new InvalidOperationException("To create a new lobby, leave your current lobby first.");
            }

            var lobbyType = gameTypeMapping.GetLobbyDataType(gameIdentifier);

            if (!lobbyType.IsSubclassOf(typeof(LobbyData)))
            {
                throw new ArgumentException("Invalid lobby type.");
            }

            var lobby = (LobbyData)Activator.CreateInstance(lobbyType) !;

            lobby.Host   = currentUser;
            lobby.Access = access;
            lobby.Name   = name;
            lobbyStorage.AddLobby(lobby);
            var wrapper = mapper.Map <LobbyDataWrapper>(lobby);

            await notificationService.NotifyAllExceptAsync(currentUser,
                                                           client => client.LobbyAdded(wrapper));

            return(wrapper);
        }
 // ASSUMES ownerId is a valid userId !!!
 public SetupPhase(string ownerId, int slotCount, LobbyAccess access)
 {
     GameLogic.SessionFactory.Validate.PlayerCount(slotCount);
     data   = new PhaseData(new UserReady[slotCount].Modify(0, new UserReady(ownerId)), Array.Empty <string>());
     Access = access;
 }