Example #1
0
        public async Task AddWarpStart(AuthorizationTokenContainer tokenContainer, SelectedShipContainer selectedShipContainer)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success && playerByAccessTokenResponse.Player.IsAdmin == true)
            {
                GetShipsByPlayerIdResponse serviceResult = _gameService.GetShipByPlayerId(playerByAccessTokenResponse.Player.Id, selectedShipContainer.ShipId);
                if (serviceResult.Success)
                {
                    Ship ship = serviceResult.Ships.First();
                    CreateSpaceObjectResult spaceObjectResult = _objectService.SpawnWarpGate(ship.X, ship.Y, ship.Z);
                    if (spaceObjectResult.Success == true)
                    {
                        await Clients.Caller.ReceiveMessage("Space object #" + spaceObjectResult.SpaceObject.Id + " created.");
                    }
                    else
                    {
                        await Clients.Caller.ReceiveMessage("Space object could not be created.");
                    }
                }
                else
                {
                    await Clients.Caller.ReceiveError(new ErrorFromServer("Could not retrieve the ship you are piloting for object placement or selection purposes."));
                }
            }
            else
            {
                await Clients.Caller.ReceiveError(new ErrorFromServer("Warp start selection is only available to administrators."));
            }
        }
Example #2
0
        public async Task ScanShipLocationForLoot(AuthorizationTokenContainer tokenContainer, SelectedShipContainer selectedShipContainer)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success && playerByAccessTokenResponse.Player.IsAdmin == true)
            {
                GetShipsByPlayerIdResponse serviceResult = _gameService.GetShipByPlayerId(playerByAccessTokenResponse.Player.Id, selectedShipContainer.ShipId);
                if (serviceResult.Success)
                {
                    Ship             ship         = serviceResult.Ships.First();
                    List <SpaceLoot> loot         = _lootService.GetAllSpaceLoot(ship.X, ship.Y, ship.Z);
                    LootScanResponse scanResponse = new LootScanResponse();
                    scanResponse.X = ship.X;
                    scanResponse.Y = ship.Y;
                    scanResponse.Z = ship.Z;
                    if (loot.Count > 0)
                    {
                        scanResponse.SpaceLoots = loot;
                    }
                    else
                    {
                        scanResponse.SpaceLoots = null;
                    }
                    Clients.Caller.ReceiveLootScanResponse(scanResponse);
                }
                else
                {
                    await Clients.Caller.ReceiveError(new ErrorFromServer("Could not retrieve the ship you are piloting for object placement or selection purposes."));
                }
            }
            else
            {
                await Clients.Caller.ReceiveError(new ErrorFromServer("Loot spawning is is only available to administrators."));
            }
        }
Example #3
0
        public async Task AddWarpEnd(AuthorizationTokenContainer tokenContainer, SelectedShipContainer selectedShipContainer, SelectedWarpStartContainer selectedWarpStart)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success && playerByAccessTokenResponse.Player.IsAdmin == true)
            {
                GetShipsByPlayerIdResponse serviceResult = _gameService.GetShipByPlayerId(playerByAccessTokenResponse.Player.Id, selectedShipContainer.ShipId);
                if (serviceResult.Success)
                {
                    Ship ship = serviceResult.Ships.First();
                    ConnectWarpgateResult connectResult = _objectService.ConnectWarpGate(ship.X, ship.Y, ship.Z, selectedWarpStart.WarpStartId);
                    if (connectResult.Success == true)
                    {
                        await Clients.Caller.ReceiveMessage("Connected warpgates together: " + connectResult.SourceObjectId + " --> " + connectResult.DestinationObjectId);
                    }
                    else
                    {
                        await Clients.Caller.ReceiveMessage("Space object could not be created.");
                    }
                }
                else
                {
                    await Clients.Caller.ReceiveError(new ErrorFromServer("Could not retrieve the ship you are piloting for object placement or selection purposes."));
                }
            }
            else
            {
                await Clients.Caller.ReceiveError(new ErrorFromServer("Warp ending spot creation is only available to administrators."));
            }
        }
Example #4
0
        private static AuthorizationTokenContainer GetAuthorizationTokenContainer()
        {
            var ctr = new AuthorizationTokenContainer();

            ctr.Token = _accessToken.Content;
            return(ctr);
        }
Example #5
0
        public async Task UpdateShipPosition(AuthorizationTokenContainer tokenContainer, ShipMovementContainer shipMovementContainer)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success)
            {
                GetShipsByPlayerIdResponse serviceResult = _gameService.GetShipByPlayerId(playerByAccessTokenResponse.Player.Id, shipMovementContainer.ShipId);
                if (serviceResult.Success)
                {
                    var timeSpan = (DateTime.UtcNow - serviceResult.Ships.First().LastMovementUtc);
                    // if the player is an administrator, don't apply a speed limit to them.
                    if ((playerByAccessTokenResponse.Player.IsAdmin == true) || timeSpan.TotalMilliseconds > 500 && shipMovementContainer.ChangeX < 2 && shipMovementContainer.ChangeY < 2)
                    {
                        _gameService.MoveShipRelative(shipMovementContainer.ShipId, shipMovementContainer.ChangeX, shipMovementContainer.ChangeY);
                        ShipMovementConfirmation confirmation = new ShipMovementConfirmation();
                        confirmation.ConfirmationId = shipMovementContainer.ConfirmationId;
                        await Clients.Caller.ReceiveShipMovementConfirmation(confirmation);
                    }
                    else
                    {
                        /// TODO: display error for exceeding speed limit.
                        await Clients.Caller.ReceiveMessage("Exceeded speed limit.");
                    }
                }
            }
        }
Example #6
0
        public async Task Ping(AuthorizationTokenContainer authorizationTokenCtr, PingRequest pingRequest)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(authorizationTokenCtr.Token);
            var result = new PingResponse();

            result.PingId  = pingRequest.PingId;
            result.Error   = null;
            result.Success = true;
            await Clients.Caller.ReceivePingResponse(result);
        }
Example #7
0
        public async Task GetPlayerCameraCoordinates(AuthorizationTokenContainer tokenContainer)
        {
            var result = new GetPlayerCameraCoordinatesResult();
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success)
            {
                result.X = playerByAccessTokenResponse.Player.CameraX;
                result.Y = playerByAccessTokenResponse.Player.CameraY;
                result.Z = playerByAccessTokenResponse.Player.CameraZ;
                await Clients.Caller.ReceivePlayerCameraCoordinates(result);
            }
        }
Example #8
0
        public async Task GetShipsForMenu(AuthorizationTokenContainer ctr)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(ctr.Token);

            if (playerByAccessTokenResponse.Success == true)
            {
                GetShipsByPlayerIdResponse getShipsByPlayerIdResponse = _gameService.GetShipsByPlayerId(playerByAccessTokenResponse.Player.Id);
                if (getShipsByPlayerIdResponse.Success)
                {
                    var result = new GetShipsForMenuResult(getShipsByPlayerIdResponse.Ships);
                    await Clients.Caller.ReceiveShipsForMenu(result);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Given a specific ship contained within the req object and owned by the player,
        /// vacuum up all the loot at the given ship's coordinates.
        /// </summary>
        /// <param name="ctr">A container containing authorization information</param>
        /// <param name="req">A request containing the ship id of the ship grabbing loot</param>
        public async Task TakeAllLoot(AuthorizationTokenContainer ctr, TakeAllLootRequest req)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(ctr.Token);

            if (playerByAccessTokenResponse.Success == true)
            {
                GetShipsByPlayerIdResponse getShipsByPlayerIdResponse = _gameService.GetShipsByPlayerId(playerByAccessTokenResponse.Player.Id);
                if (getShipsByPlayerIdResponse.Success)
                {
                    Ship ship = getShipsByPlayerIdResponse.Ships.Where(x => x.Id == req.ShipId).SingleOrDefault();
                    _lootService.TractorAllLoot(ship);
                    await Clients.Caller.ReceiveMessage("Looted all.");
                }
            }
        }
Example #10
0
        public async Task GetCharacterForManagement(AuthorizationTokenContainer tokenContainer, CharacterForManagementRequest characterForManagementRequest)
        {
            var result = new GetCharacterForManagementResult();
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success)
            {
                GetCharacterByPlayerIdAndCharacterIdResponse retrievedCharacter = _gameService.GetCharacterByPlayerIdAndCharacter(playerByAccessTokenResponse.Player.Id, characterForManagementRequest.CharacterId);
                if (retrievedCharacter.Success)
                {
                    result.Success   = true;
                    result.Character = retrievedCharacter.Character;
                    result.Error     = null;
                    await Clients.Caller.ReceiveCharacterForManagement(result);
                }
            }
        }
Example #11
0
        public async Task GetShipForConsole(AuthorizationTokenContainer ctr, ShipForConsoleRequest req)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(ctr.Token);

            if (playerByAccessTokenResponse.Success == true)
            {
                GetShipsByPlayerIdResponse getShipsByPlayerIdResponse = _gameService.GetShipsByPlayerId(playerByAccessTokenResponse.Player.Id);
                if (getShipsByPlayerIdResponse.Success)
                {
                    Ship ship = getShipsByPlayerIdResponse.Ships.Where(x => x.Id == req.ShipId).SingleOrDefault();
                    if (ship != null)
                    {
                        await Clients.Caller.ReceiveShipForConsole(ship);
                    }
                }
            }
        }
Example #12
0
        public async Task GetMapAtShip(AuthorizationTokenContainer tokenContainer, MapAtShipRequest mapAtShipRequestContainer)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success)
            {
                GetShipsByPlayerIdResponse serviceResult = _gameService.GetShipByPlayerId(playerByAccessTokenResponse.Player.Id, mapAtShipRequestContainer.ShipId);
                if (serviceResult.Success)
                {
                    Ship ship = serviceResult.Ships.First();
                    GetMapAtShipByShipIdResponse map = _mapService.GetMapAtShipByShipId(ship.Id, mapAtShipRequestContainer.ViewWidth, mapAtShipRequestContainer.ViewHeight);
                    if (map.Success)
                    {
                        await Clients.Caller.ReceiveMapData(map.MapDataResult);
                    }
                }
            }
        }
Example #13
0
        /// <summary>
        /// Given a specific ship contained within the req object and owned by the player,
        /// vacuum up all the loot at the given ship's coordinates.
        /// </summary>
        /// <param name="ctr">A container containing authorization information</param>
        /// <param name="req">A request containing the ship id of the ship grabbing loot and the ID of the loot object such as module being looted</param>
        public async Task TakeSpecificLoot(AuthorizationTokenContainer ctr, TakeSpecificLootRequest req)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(ctr.Token);

            if (playerByAccessTokenResponse.Success == true)
            {
                GetShipsByPlayerIdResponse getShipsByPlayerIdResponse = _gameService.GetShipsByPlayerId(playerByAccessTokenResponse.Player.Id);
                if (getShipsByPlayerIdResponse.Success)
                {
                    Ship ship = getShipsByPlayerIdResponse.Ships.Where(x => x.Id == req.ShipId).SingleOrDefault();
                    if (_lootService.TractorSpecificLoot(ship, req.ItemType, req.ItemId))
                    {
                        await Clients.Caller.ReceiveMessage("Looted specific item.");
                    }
                    else
                    {
                        await Clients.Caller.ReceiveMessage("Could not loot item there.");
                    }
                }
            }
        }
Example #14
0
        public async Task AddShipModule(AuthorizationTokenContainer tokenContainer, SelectedShipContainer selectedShipContainer)
        {
            GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token);

            if (playerByAccessTokenResponse.Success && playerByAccessTokenResponse.Player.IsAdmin == true)
            {
                GetShipsByPlayerIdResponse serviceResult = _gameService.GetShipByPlayerId(playerByAccessTokenResponse.Player.Id, selectedShipContainer.ShipId);
                if (serviceResult.Success)
                {
                    Ship ship = serviceResult.Ships.First();
                    _lootService.SpawnRandomModule(ship.X, ship.Y, ship.Z);
                    Clients.Caller.ReceiveMessage("Random module spawned!");
                }
                else
                {
                    await Clients.Caller.ReceiveError(new ErrorFromServer("Could not retrieve the ship you are piloting for object placement or selection purposes."));
                }
            }
            else
            {
                await Clients.Caller.ReceiveError(new ErrorFromServer("Loot spawning is is only available to administrators."));
            }
        }