public async Task <bool> CatchThief(int userId)
        {
            var response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Patch($"users/{userId}/catch"));

            return(response.IsSuccessful);
        }
        public async Task <Game> GetGame(int gameId)
        {
            HttpClientResponse response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Get($"games/{gameId}"));

            return(new GameJsonService().ToObject(response.ResponseContent));
        }
示例#3
0
        public async Task <bool> Create(string message, int gameId, int?userId)
        {
            var response = new HttpClientResponse();

            object parameters;

            if (userId == null)
            {
                parameters = new {
                    message = message,
                };
            }
            else
            {
                parameters = new {
                    message = message,
                    user_id = userId,
                }
            };

            await response.Convert(HttpClientRequestService.Create($"games/{gameId}/notifications", parameters));

            return(response.IsSuccessful);
        }
    }
示例#4
0
        public async Task <bool> TriggerAlarm(int playerId)
        {
            var response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Create($"users/{playerId}/trigger-alarm", new { }));

            return(response.IsSuccessful);
        }
        public async Task <bool> UpdatePoliceScore(int gameId, int score)
        {
            var response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Patch($"games/{gameId}/police-score/{score}"));

            return(response.IsSuccessful);
        }
示例#6
0
        public async Task <bool> UseGadget(int playerId, string gadgetName)
        {
            var response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Patch($"users/{playerId}/gadgets/{gadgetName}"));

            return(response.IsSuccessful);
        }
        public async Task <bool> Delete(int lootId)
        {
            var response = new HttpClientResponse();

            await response.Convert(HttpClientRequestService.Delete($"loot/{lootId}"));

            return(response.IsSuccessful);
        }
示例#8
0
 public async void Create(PusherException e)
 {
     var response = new HttpClientResponse();
     await response.Convert(HttpClientRequestService.Create("app-errors", new {
         error_id   = GetErrorId(e),
         message    = e.Message ?? DEFAULT_MESSAGE + " [PUSHER ERROR]",
         stacktrace = e.StackTrace ?? DEFAULT_STACKTRACE + " [PUSHER ERROR]"
     }));
 }
        public async Task <bool> Update(int userId, Location location)
        {
            var response = new HttpClientResponse();

            await response.Convert(HttpClientRequestService.Put($"users/{userId}", new {
                location = location.ToCsvString()
            }));

            return(response.ResponseContent != null);
        }
示例#10
0
        public async Task <Player> Create(Player player)
        {
            var response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Create("users", new {
                username   = player.UserName,
                invite_key = player.InviteKey.Value,
            }));

            Player newPlayer = new PlayerJsonService().ToObject(response.ResponseContent, player.InviteKey).ToPlayer();

            newPlayer.ErrorMessages = response.ErrorMessages;

            return(newPlayer);
        }
示例#11
0
        // Get all loot that is linked to a game
        public async Task <List <Loot> > GetAll(int gameId)
        {
            var response = new HttpClientResponse()
            {
                HasMultipleResults = true,
            };
            await response.Convert(HttpClientRequestService.Get($"games/{gameId}/loot"));

            var result = new List <Loot>(
                new LootJsonService().ToObjects(response.ResponseContent)
                );

            return(result);
        }
示例#12
0
        public async Task <List <PlayerBuilder> > GetAll(int gameId)
        {
            var response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.GetAll($"games/{gameId}/gadgets"));

            List <PlayerBuilder> playersWithGadgets = new List <PlayerBuilder>();

            foreach (PlayerBuilder player in new PlayerJsonService().ToObjects(response.ResponseContent))
            {
                playersWithGadgets.Add(player);
            }

            return(playersWithGadgets);
        }
        public async Task <List <Location> > GetAll(int gameId)
        {
            var response = new HttpClientResponse()
            {
                HasMultipleResults = true,
            };
            await response.Convert(HttpClientRequestService.GetAll($"games/{gameId}/border-markers"));

            List <Location> result = new List <Location>(
                new LocationJsonService().ToObjects(response.ResponseContent)
                );

            return(result);
        }
示例#14
0
        public async Task <Player> GetUser(int userId, int gameId)
        {
            HttpClientResponse response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Get($"users/{userId}"));

            if (response.Status == System.Net.HttpStatusCode.NotFound)
            {
                return(null);
            }

            var user = new PlayerJsonService().ToObject(response.ResponseContent);

            user.InviteKey.GameId = gameId;

            return(user.ToPlayer());
        }
示例#15
0
        // Get all users that are linked to a game
        public async Task <List <Player> > GetAll(int gameId)
        {
            var usersResponse = new HttpClientResponse()
            {
                HasMultipleResults = true,
            };

            await usersResponse.Convert(HttpClientRequestService.GetAll($"games/{gameId}/users-with-role"));

            var result = new List <Player>();

            foreach (var builder in new PlayerJsonService().ToObjects(usersResponse.ResponseContent))
            {
                result.Add(builder.ToPlayer());
            }

            return(result);
        }
        public async Task <List <InviteKey> > GetAll(int gameId)
        {
            var response = new HttpClientResponse();

            response.HasMultipleResults = true;

            await response.Convert(HttpClientRequestService.GetAll($"games/{gameId}/invite-keys"));

            List <InviteKey> inviteKeys = new List <InviteKey>();

            foreach (InviteKey inviteKey in new InviteKeyJsonService().ToObjects(response.ResponseContent))
            {
                inviteKey.GameId = gameId;
                inviteKeys.Add(inviteKey);
            }

            return(inviteKeys);
        }
        public async Task <List <InviteKey> > GetAll(string inviteCode)
        {
            var response = new HttpClientResponse();
            await response.Convert(HttpClientRequestService.Get($"invite-keys/{inviteCode}"));

            List <InviteKey> result = new List <InviteKey>();

            InviteKey key = new InviteKeyJsonService().ToObject(response.ResponseContent);

            key.Value = inviteCode;
            if (string.IsNullOrEmpty(key.Role))
            {
                key.ErrorMessages = response.ErrorMessages.Count() > 0 ? response.ErrorMessages : new Dictionary <string, string>()
                {
                    { "value", response.Status == HttpStatusCode.NotFound ? "De code is niet gevonden" : "Er is iets misgegaan" }
                };
            }

            result.Add(key);
            return(result);
        }
示例#18
0
        public string GetLogoUrl(int gameId)
        {
            var url = HttpClientRequestService.GetUrl($"games/{gameId}/logo");

            return(url);
        }