Example #1
0
        public HttpResponseMessage RegisterBattleProgress(BattleProgressRegistration progress)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            return(SaveBattleProgress(progress, playerId));
        }
Example #2
0
        public HttpResponseMessage StartBattleWithRigInDb(int battleSceneId)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            SpaceshipRig rig = SpaceshipRig.RigForBattle(playerId, battleSceneId);

            Battle battle = null;

            if (rig != null)
            {
                if (rig.Id == 0)
                {
                    rig.SaveData(playerId, "");
                }
            }
            else
            {
                rig = SpaceshipRig.RigForBattle(playerId, battleSceneId);
            }

            battle     = Battle.CreateBattle(playerId, battleSceneId, rig.Id, true);
            battle.Rig = rig;


            string serializedElement = JsonConvert.SerializeObject(battle);

            serializedElement = CommonFunctions.Compress(serializedElement);
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
        public HttpResponseMessage GetImage(int ImageId)
        {
            HttpResponseMessage response;

            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            if (playerId == 0)
            {
                response = new HttpResponseMessage(HttpStatusCode.Forbidden);
                return(response);
            }

            Story.RebelImageToTransfer curImage = Story.RebelImageToTransfer.ImageToTransferById(ImageId);
            if (curImage == null)
            {
                response = new HttpResponseMessage(HttpStatusCode.NotFound);
                return(response);
            }

            string serializedElement = JsonConvert.SerializeObject(curImage);

            response         = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new StringContent(serializedElement);
            return(response);
        }
        public HttpResponseMessage GetPlayerAsset()
        {
            string      steamId           = User.Identity.Name;
            int         playerId          = PlayerDataSql.PlayerId(steamId);
            PlayerAsset playerAsset       = PlayerDataSql.GetPlayerAsset(playerId);
            string      serializedElement = JsonConvert.SerializeObject(playerAsset);
            var         response          = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
        public HttpResponseMessage GetOfficerList()
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);
            List <Crew.CrewOfficer> officers = Crew.CrewOfficer.OfficersForPlayer(playerId);
            string serializedElement         = JsonConvert.SerializeObject(officers);
            var    response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
Example #6
0
        public HttpResponseMessage GetPlayerModules()
        {
            string            steamId           = User.Identity.Name;
            int               playerId          = PlayerDataSql.PlayerId(steamId);
            List <ShipModule> modules           = ShipModule.PlayerModules(playerId);
            string            serializedElement = JsonConvert.SerializeObject(modules);
            var               response          = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
        public HttpResponseMessage UpdateOfficerSkillsets(Crew.OfficerExperience officerExperience)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            //Внимание! Данные залетают в базу без какой-либо проверки.
            officerExperience.SaveData();

            var response = new HttpResponseMessage(HttpStatusCode.OK);

            return(response);
        }
Example #8
0
        public HttpResponseMessage BattleSceneList()
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            List <Battle> playerBattles     = Battle.BattlesForPlayer(playerId, true);
            string        serializedElement = JsonConvert.SerializeObject(playerBattles);
            var           response          = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
Example #9
0
        public HttpResponseMessage GetPlayerResources()
        {
            string          steamId         = User.Identity.Name;
            int             playerId        = PlayerDataSql.PlayerId(steamId);
            PlayerResources playerResources = new PlayerResources();

            playerResources.LoadData(PlayerResources.StorageType.MainWarehouse, 0, playerId);
            string serializedElement = JsonConvert.SerializeObject(playerResources);
            var    response          = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
Example #10
0
        public HttpResponseMessage RigForBattle(int BattleSceneId)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            var rig = SpaceshipRig.RigForBattle(playerId, BattleSceneId);

            string serializedElement = JsonConvert.SerializeObject(rig);
            var    response          = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
Example #11
0
        public HttpResponseMessage RegisterRigCompleted(SpaceshipRig rig)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            if (rig != null)
            {
                rig.SaveData(playerId, "");
            }

            var response = new HttpResponseMessage(HttpStatusCode.OK);

            return(response);
        }
        public HttpResponseMessage RegisterOfficerChanges(Crew.CrewOfficer officer)
        {
            string steamId            = User.Identity.Name;
            int    playerId           = PlayerDataSql.PlayerId(steamId);
            string statsEditingResult = Crew.CrewOfficer.RegisterOfficerStatsChanged(playerId, officer);

            if (string.IsNullOrEmpty(statsEditingResult))
            {
                var response = new HttpResponseMessage(HttpStatusCode.OK);
                return(response);
            }
            else
            {
                var response = new HttpResponseMessage(HttpStatusCode.BadRequest);
                response.ReasonPhrase = statsEditingResult;
                return(response);
            }
        }
Example #13
0
        public HttpResponseMessage RegisterBattleCompleted(BattleProgressRegistration progress)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            var response = SaveBattleProgress(progress, playerId);

            if (!response.IsSuccessStatusCode)
            {
                return(response);
            }

            Battle currentBattle = Battle.BattleByCode(progress.BattleCode);

            currentBattle.RegisterBattleCompleted(progress);

            return(response);
        }
Example #14
0
        public HttpResponseMessage ContinueBattle(int battleSceneId)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            Battle      battle  = Battle.BattleByTypeId(playerId, battleSceneId);
            BattleScene tBattle = new BattleScene(BattleSceneType.SceneById(battleSceneId));

            battle.battleScene = new UnityBattleScene(tBattle);
            battle.Rig         = SpaceshipRig.RigById(battle.RigId);

            string serializedElement = JsonConvert.SerializeObject(battle);

            serializedElement = CommonFunctions.Compress(serializedElement);
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }