コード例 #1
0
        public async Task <JsonResult> DelGame(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user != null)
            {
                GameInfoModel gameInfoModel = this.dbContext.GameInfoModel.SingleOrDefault(item => item.Id == id);
                if (gameInfoModel != null)
                {
                    GaiaGame gaiaGame = GameMgr.GetGameByName(gameInfoModel.name);
                    foreach (string username in gaiaGame.Username)
                    {
                        //如果不是自己
                        if (username != user.UserName)
                        {
                            this.dbContext.GameDeleteModel.Add(new GameDeleteModel()
                            {
                                gameinfo_id   = gameInfoModel.Id,
                                gameinfo_name = gameInfoModel.name,
                                username      = username,
                                state         = 0,
                            });
                        }
                    }
                    gameInfoModel.isDelete = 1;
                    this.dbContext.SaveChanges();
                    jsonData.info.state = 200;
                }
            }
            return(new JsonResult(jsonData));
        }
コード例 #2
0
        public async Task <JsonResult> DelData(int id, string type)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            jsonData.info.state = 200;
            switch (type)
            {
            case "donate":
                DonateRecordModel donateRecordModel = this.dbContext.DonateRecordModel.SingleOrDefault(item => item.id == id);
                if (donateRecordModel != null)
                {
                    this.dbContext.DonateRecordModel.Remove(donateRecordModel);
                    this.dbContext.SaveChanges();
                    //查询捐赠记录是否为空
                    if (!this.dbContext.DonateRecordModel.Any(
                            item => item.donateuser == donateRecordModel.donateuser))
                    {
                        //取消用户等级
                        ApplicationUser applicationUser = this.dbContext.Users.SingleOrDefault(item => item.UserName == donateRecordModel.donateuser);
                        if (applicationUser != null)
                        {
                            applicationUser.paygrade = 0;
                            this.dbContext.Users.Update(applicationUser);
                            this.dbContext.SaveChanges();
                        }
                    }
                }
                break;
            }
            return(new JsonResult(jsonData));
        }
コード例 #3
0
        public async Task <JsonResult> AddUserFromGame(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            IQueryable <GameInfoModel> gameInfoModels = this.dbContext.GameInfoModel.Where(item => item.matchId == id);
            List <string> userList = new List <string>();

            foreach (GameInfoModel gameInfoModel in gameInfoModels)
            {
                string[] users = gameInfoModel.userlist.Split("|");
                foreach (string user in users)
                {
                    if (!userList.Contains(user))
                    {
                        userList.Add(user);
                    }
                }
            }
            if (userList.Count == 7)
            {
                userList.ForEach((user) =>
                {
                    AddUserToMatch(id, user);
                });
            }
            jsonData.info.state = 200;
            return(new JsonResult(jsonData));
        }
コード例 #4
0
        public async Task <JsonResult> DelFriend(UserFriend model)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user != null)
            {
                var userTo = await _userManager.FindByNameAsync(model.UserNameTo);

                //找不对对象用户
                if (userTo == null)
                {
                    jsonData.info.state   = 0;
                    jsonData.info.message = "找不到用户" + model.UserNameTo;
                }
                else
                {
                    var uf = dbContext.UserFriend.SingleOrDefault(
                        item => item.UserId == user.Id && item.UserNameTo == model.UserNameTo && item.Type == model.Type);
                    if (uf != null)
                    {
                        dbContext.UserFriend.Remove(uf);
                        jsonData.info.state = 200;
                        await dbContext.SaveChangesAsync();
                    }
                }
            }
            return(new JsonResult(jsonData));
        }
コード例 #5
0
        public async Task <JsonResult> SetJoin(int id, Int16 state)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            var matchInfoModel = this.dbContext.MatchInfoModel.SingleOrDefault(item => item.Id == id);

            matchInfoModel.State = (short)(matchInfoModel.State == 0 ? 1 : 0);
            this.dbContext.MatchInfoModel.Update(matchInfoModel);
            this.dbContext.SaveChanges();
            jsonData.info.state = 200;
            return(new JsonResult(jsonData));
        }
コード例 #6
0
        public async Task <JsonResult> DeleteDbGame(int id, bool isdel = false)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            bool flag = DeleteDbGame(id);

            if (flag)
            {
                jsonData.info.state = 200;
            }
            return(new JsonResult(jsonData));
        }
コード例 #7
0
        public async Task <JsonResult> JoinGame(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            GameInfoModel gameInfoModel = this.dbContext.GameInfoModel.SingleOrDefault(item => item.Id == id);

            if (gameInfoModel != null)
            {
                //如果包括自己
                if (this.User.Identity.Name == null)
                {
                    jsonData.info.state   = 400;
                    jsonData.info.message = "没有登陆";
                }
                else if (gameInfoModel.userlist.Contains(string.Format("|{0}|", this.User.Identity.Name)))
                {
                    jsonData.info.state   = 400;
                    jsonData.info.message = "已经加入";
                }
                else
                {
                    gameInfoModel.userlist = gameInfoModel.userlist + this.User.Identity.Name + "|";

                    //判断是否满足人数,正式开始游戏
                    string[] username = gameInfoModel.userlist.Trim('|').Split('|');
                    if (username.Length == gameInfoModel.UserCount)
                    {
                        gameInfoModel.round = 0;
                        NewGameViewModel newGameViewModel = new NewGameViewModel()
                        {
                            IsAllowLook   = gameInfoModel.IsAllowLook,
                            IsRandomOrder = gameInfoModel.IsRandomOrder,
                            IsRotatoMap   = gameInfoModel.IsRotatoMap,
                            IsTestGame    = gameInfoModel.IsTestGame == 1,
                            MapSelction   = gameInfoModel.MapSelction,
                            Name          = gameInfoModel.name,
                            jinzhiFaction = gameInfoModel.jinzhiFaction,
                        };
                        //创建游戏
                        GaiaGame gaiaGame;
                        this.CreateGame(username, newGameViewModel, out gaiaGame);
                    }
                    this.dbContext.GameInfoModel.Update(gameInfoModel);
                    this.dbContext.SaveChanges();

                    jsonData.info.state   = 200;
                    jsonData.info.message = "成功";
                }
            }

            return(new JsonResult(jsonData));
        }
コード例 #8
0
        public IActionResult ScoreAll()
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            //结束的变成2
            IQueryable <MatchInfoModel> matchInfoModels = this.dbContext.MatchInfoModel.Where(item => item.State != 2 && item.State == 1);

            foreach (MatchInfoModel matchInfoModel in matchInfoModels)
            {
                this.ScoreMatch(matchInfoModel);
            }
            this.dbContext.SaveChanges();
            return(View("Index", this.dbContext.MatchInfoModel.ToList().OrderByDescending(item => item.Id).ToList()));
        }
コード例 #9
0
        public async Task <JsonResult> AgreeDelGame(int id, int type)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            GameDeleteModel gameDeleteModel = this.dbContext.GameDeleteModel.SingleOrDefault(
                item => item.Id == id && item.username == User.Identity.Name);

            if (gameDeleteModel != null)
            {
                GameInfoModel gameInfoModel = this.dbContext.GameInfoModel.SingleOrDefault(item => item.Id == gameDeleteModel.gameinfo_id);
                //申请删除状态
                if (gameInfoModel.isDelete == 1)
                {
                    {
                        //同意删除
                        if (type == 1)
                        {
                            //删除同意记录
                            this.dbContext.GameDeleteModel.Remove(gameDeleteModel);
                            this.dbContext.SaveChanges();
                            //如果是最后一个同意的,则删除游戏
                            if (!this.dbContext.GameDeleteModel.Any(item => item.gameinfo_id == gameDeleteModel.gameinfo_id))
                            {
                                this.DeleteDbGame(gameDeleteModel.gameinfo_id);
                                jsonData.info.message = "全部玩家同意删除,已删除游戏";
                            }
                            else
                            {
                                jsonData.info.message = "继续等待其他玩家处理删除申请";
                            }
                        }
                        else//不同意删除
                        {
                            //移除全部的申请
                            this.dbContext.GameDeleteModel.RemoveRange(this.dbContext.GameDeleteModel.Where(item => item.gameinfo_id == gameDeleteModel.gameinfo_id));
                            //申请删除游戏恢复
                            GameInfoModel infoModel = this.dbContext.GameInfoModel.SingleOrDefault(item => item.Id == gameDeleteModel.gameinfo_id);
                            if (infoModel != null)
                            {
                                infoModel.isDelete = 0;
                                this.dbContext.GameInfoModel.Update(infoModel);
                                jsonData.info.message = "游戏已经恢复正常状态";
                            }
                        }
                        this.dbContext.SaveChanges();
                    }
                    jsonData.info.state = 200;
                }
            }

            return(new JsonResult(jsonData));
        }
コード例 #10
0
        public async Task <JsonResult> DelMatch(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            MatchInfoModel matchInfoModel = this.dbContext.MatchInfoModel.SingleOrDefault(item => item.Id == id);

            if (matchInfoModel != null)
            {
                this.dbContext.MatchInfoModel.Remove(matchInfoModel);
                this.dbContext.SaveChanges();
                jsonData.info.state = 200;
            }
            return(new JsonResult(jsonData));
        }
コード例 #11
0
        public async Task <JsonResult> ExitMatch(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            //比赛信息
            MatchInfoModel matchInfoModel = this.dbContext.MatchInfoModel.SingleOrDefault(item => item.Id == id);

            if (matchInfoModel != null)
            {
                if (matchInfoModel.RegistrationEndTime < DateTime.Now)
                {
                    jsonData.info.state   = 0;
                    jsonData.info.message = "报名时间截止";
                }
                else if (matchInfoModel.State != 0)
                {
                    jsonData.info.state   = 0;
                    jsonData.info.message = "已经开始,无法退出";
                }
                else
                {
                    MatchJoinModel matchJoinModel =
                        this.dbContext.MatchJoinModel.SingleOrDefault(item => item.matchInfo_id == matchInfoModel.Id &&
                                                                      item.username == HttpContext.User.Identity
                                                                      .Name);
                    if (matchJoinModel != null)
                    {
                        //删除
                        this.dbContext.MatchJoinModel.Remove(matchJoinModel);
                        //报名人数-1
                        matchInfoModel.NumberNow--;
                        this.dbContext.MatchInfoModel.Update(matchInfoModel);

                        this.dbContext.SaveChanges();

                        jsonData.info.state = 200;
                    }
                    else
                    {
                        jsonData.info.state   = 0;
                        jsonData.info.message = "没有报名";
                    }
                }
            }

            return(new JsonResult(jsonData));
        }
コード例 #12
0
        public async Task <JsonResult> AddUserToMatch(int id, string username)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            var matchInfoModel = this.dbContext.MatchInfoModel.SingleOrDefault(item => item.Id == id);

            if (matchInfoModel != null)
            {
                ApplicationUser applicationUser = this.dbContext.Users.SingleOrDefault(item => item.UserName == username);
                if (applicationUser != null)
                {
                    MatchJoinModel matchJoinModel = new MatchJoinModel();
                    matchJoinModel.matchInfo_id = id;                  //id
                    matchJoinModel.Name         = matchInfoModel.Name; //name

                    matchJoinModel.AddTime  = DateTime.Now;            //时间
                    matchJoinModel.username = applicationUser.UserName;
                    matchJoinModel.userid   = applicationUser.Id;

                    matchJoinModel.Rank  = 0;
                    matchJoinModel.Score = 0;


                    //用户数量
                    matchInfoModel.NumberNow++;
                    this.dbContext.MatchInfoModel.Update(matchInfoModel);

                    this.dbContext.MatchJoinModel.Add(matchJoinModel);
                    this.dbContext.SaveChanges();

                    this.AutoCreateMatch(matchInfoModel);
                    jsonData.info.state = 200;
                    return(new JsonResult(jsonData));
                }
                else
                {
                    jsonData.info.message = "用户不存在";
                }
            }
            else
            {
                jsonData.info.message = "比赛不存在";
            }
            jsonData.info.state = 0;
            return(new JsonResult(jsonData));
        }
コード例 #13
0
        public async Task <JsonResult> SetMatch(string id, int state)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            ApplicationUser user = this._userManager.FindByIdAsync(id).Result;

            if (user != null)
            {
                user.isallowmatch = state;
                this.dbContext.Users.Update(user);
                this.dbContext.SaveChanges();

                //int a = 1;
                jsonData.info.state   = 200;
                jsonData.info.message = "Succeeded";
            }
            return(new JsonResult(jsonData));
        }
コード例 #14
0
        public async Task <JsonResult> ExitGame(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            GameInfoModel gameInfoModel = this.dbContext.GameInfoModel.SingleOrDefault(item => item.Id == id);

            if (gameInfoModel != null)
            {
                string username = this.User.Identity.Name;
                //如果不包括自己
                if (!gameInfoModel.userlist.Contains(username))
                {
                    jsonData.info.state   = 400;
                    jsonData.info.message = "没有加入,无法取消";
                }
                else
                {
                    if (gameInfoModel.username == username)
                    {
                        jsonData.info.state   = 400;
                        jsonData.info.message = "创建人暂时无法退出";
                    }
                    else
                    {
                        gameInfoModel.userlist = gameInfoModel.userlist.Replace("|" + username + "|", "");
                        //判断结尾和开头
                        if (!gameInfoModel.userlist.StartsWith("|"))
                        {
                            gameInfoModel.userlist = "|" + gameInfoModel.userlist;
                        }
                        if (!gameInfoModel.userlist.EndsWith("|"))
                        {
                            gameInfoModel.userlist = gameInfoModel.userlist + "|";
                        }

                        this.dbContext.GameInfoModel.Update(gameInfoModel);
                        this.dbContext.SaveChanges();
                        jsonData.info.state   = 200;
                        jsonData.info.message = "成功";
                    }
                }
            }

            return(new JsonResult(jsonData));
        }
コード例 #15
0
        public async Task <JsonResult> DeleteHallGame(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            GameInfoModel gameInfoModel = this.dbContext.GameInfoModel.SingleOrDefault(item => item.Id == id);

            if (gameInfoModel != null)
            {
                string username = this.User.Identity.Name;

                //是自己创建的 或者管理员
                if (username == gameInfoModel.username || (_userManager.GetUserAsync(User).Result != null && _userManager.GetUserAsync(User).Result.groupid == 1))
                {
                    this.dbContext.GameInfoModel.Remove(gameInfoModel);
                    this.dbContext.SaveChanges();
                    jsonData.info.state = 200;
                }
            }

            return(new JsonResult(jsonData));
        }
コード例 #16
0
        public async Task <JsonResult> ResetPwd(string id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            var user = this._userManager.FindByIdAsync(id);

            if (user != null)
            {
                var result = user.Result;
                //_userManager.ResetPasswordAsync(result,)
                var code = await _userManager.GeneratePasswordResetTokenAsync(result);

                var newuser = await _userManager.ResetPasswordAsync(result, code, "12345678");

                //int a = 1;
                jsonData.info.state   = 200;
                jsonData.info.message = newuser.ToString();
            }
            return(new JsonResult(jsonData));
        }
コード例 #17
0
        public async Task <JsonResult> ScoreMatch(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            //主要信息
            var matchInfoModel = this.dbContext.MatchInfoModel.SingleOrDefault(item => item.Id == id);

            if (matchInfoModel == null)
            {
            }
            else
            {
                this.ScoreMatch(matchInfoModel);
                this.dbContext.SaveChanges();
                jsonData.info.state = 200;
            }
            return(new JsonResult(jsonData));

            return(null);
        }
コード例 #18
0
        public async Task <JsonResult> SaveRemark(string id, string remark, bool isTishi)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            GaiaGame gaiaGame = GameMgr.GetGameByName(id);

            if (gaiaGame != null)
            {
                UserGameModel userGameModel = gaiaGame.UserGameModels.Find(x => x.username.ToString() == HttpContext.User.Identity.Name);
                //备忘
                userGameModel.remark  = remark;
                userGameModel.isTishi = isTishi;
                jsonData.info.state   = 200;
            }
            else
            {
                jsonData.info.state   = 0;
                jsonData.info.message = "保存失败";
            }

            return(new JsonResult(jsonData));
        }
コード例 #19
0
        public async Task <JsonResult> AddGameToMatch(int id, string gameid)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            //比赛信息
            GameInfoModel gameInfoModel = this.dbContext.GameInfoModel.SingleOrDefault(item => item.Id == int.Parse(gameid));

            if (gameInfoModel != null)
            {
                gameInfoModel.matchId = id;
                this.dbContext.GameInfoModel.Update(gameInfoModel);

                this.dbContext.SaveChanges();
                jsonData.info.state = 200;
            }
            else
            {
                jsonData.info.state   = 0;
                jsonData.info.message = "没有报名";
            }
            return(new JsonResult(jsonData));
        }
コード例 #20
0
        public async Task <JsonResult> ShowInfo(int id)
        {
            //主要信息
            var matchInfoModel = this.dbContext.MatchInfoModel.SingleOrDefault(item => item.Id == id);

            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            //jsonData.data = matchInfoModel;
            //查询当前报名人
            List <MatchJoinModel> matchJoinModels = this.dbContext.MatchJoinModel.Where(item => item.matchInfo_id == matchInfoModel.Id).ToList();

            //查询当前比赛
            //List<GameInfoModel> gameInfoModels = this.dbContext.GameInfoModel.Where(item => item.matchId == matchInfoModel.Id).ToList();

            jsonData.data = new
            {
                matchInfoModel  = matchInfoModel,
                matchJoinModels = matchJoinModels,
                //gameInfoModels = gameInfoModels,
            };
            jsonData.info.state = 200;
            return(new JsonResult(jsonData));
        }
コード例 #21
0
        public async Task <JsonResult> AddFriend(UserFriend model)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user != null)
            {
                var userTo = await _userManager.FindByNameAsync(model.UserNameTo);

                //找不对对象用户
                if (userTo == null)
                {
                    jsonData.info.state   = 0;
                    jsonData.info.message = "找不到用户" + model.UserNameTo;
                }
                else
                {
                    model.UserId   = user.Id;
                    model.UserName = user.UserName;
                    var list = dbContext.UserFriend.Where(item => item.UserId == model.UserId && item.UserNameTo == model.UserNameTo && item.Type == model.Type).ToList();
                    //已经存在
                    if (list.Count > 0)
                    {
                        jsonData.info.state   = 0;
                        jsonData.info.message = "无需重复添加";
                    }
                    else
                    {
                        var result = await dbContext.UserFriend.AddAsync(model);

                        jsonData.info.state = 200;
                        await dbContext.SaveChangesAsync();
                    }
                }
            }
            return(new JsonResult(jsonData));
        }
コード例 #22
0
        public async Task <JsonResult> SetTishi(string type)
        {
            var list = GameMgr.GetAllGame(User.Identity.Name);

            foreach (KeyValuePair <string, GaiaGame> keyValuePair in list)
            {
                UserGameModel singleOrDefault = keyValuePair.Value.UserGameModels.Find(item => item.username == User.Identity.Name);
                if (singleOrDefault != null)
                {
                    if (type == "open")
                    {
                        singleOrDefault.isTishi = true;
                    }
                    else
                    {
                        singleOrDefault.isTishi = false;
                    }
                }
            }

            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            jsonData.info.state = 200;
            return(new JsonResult(jsonData));
        }
コード例 #23
0
        public async Task <JsonResult> JoinMatch(int id)
        {
            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user.isallowmatch != 1)
            {
                jsonData.info.state   = 0;
                jsonData.info.message = "你被禁止参加群联赛,请联系管理员查询原因!";
            }
            else
            {
                var matchInfoModel = this.dbContext.MatchInfoModel.SingleOrDefault(item => item.Id == id);
                //比赛信息不为空
                if (matchInfoModel != null)
                {
                    if (this.dbContext.MatchJoinModel.Any(
                            item => item.matchInfo_id == matchInfoModel.Id && item.username == user.UserName))
                    {
                        jsonData.info.state   = 0;
                        jsonData.info.message = "已经报名";
                    }
                    else
                    {
                        //是否已经满足报名
                        if (matchInfoModel.NumberMax != 0 && matchInfoModel.NumberNow == matchInfoModel.NumberMax)
                        {
                            jsonData.info.state   = 0;
                            jsonData.info.message = "报名人员已满";
                        }
                        else if (matchInfoModel.RegistrationEndTime < DateTime.Now)
                        {
                            jsonData.info.state   = 0;
                            jsonData.info.message = "报名时间截止";
                        }
                        else
                        {
                            //报名人数+1
                            matchInfoModel.NumberNow++;
                            this.dbContext.MatchInfoModel.Update(matchInfoModel);
                            //报名信息
                            MatchJoinModel matchJoinModel = new MatchJoinModel();
                            matchJoinModel.matchInfo_id = id;                  //id
                            matchJoinModel.Name         = matchInfoModel.Name; //name

                            matchJoinModel.AddTime  = DateTime.Now;            //时间
                            matchJoinModel.username = user.UserName;
                            matchJoinModel.userid   = user.Id;

                            matchJoinModel.Rank  = 0;
                            matchJoinModel.Score = 0;

                            this.dbContext.MatchJoinModel.Add(matchJoinModel);
                            this.dbContext.SaveChanges();

                            jsonData.info.state = 200;

                            this.AutoCreateMatch(matchInfoModel);
                        }
                    }
                }
            }

            return(new JsonResult(jsonData));
        }
コード例 #24
0
        public async Task <JsonResult> CalShipDistanceNeed(string id, string pos, string factionName, int tempship = 0, int TerraFormNumber = 0)
        {
            GaiaGame gaiaGame = GameMgr.GetGameByName(id);
            Faction  faction  = gaiaGame.FactionList.Find(x => x.FactionName.ToString() == factionName);

            Models.Data.UserFriendController.JsonData jsonData = new Models.Data.UserFriendController.JsonData();

            //Faction faction=null;
            if (!string.IsNullOrEmpty(pos))
            {
                pos = pos.ToLower();

                ConvertPosToRowCol(pos, out int row, out int col);
                //距离
                int distanceNeed = gaiaGame.Map.CalShipDistanceNeed(row, col, faction.FactionName);
                distanceNeed = distanceNeed - tempship;
                //需要的Q
                int QSHIP = Math.Max((distanceNeed - faction.GetShipDistance + 1) / 2, 0);

                //
                string message = null;
                //需要工人
                int Ore    = Faction.m_MineOreCost;
                int Credit = Faction.m_MineCreditCost;
                jsonData.info.state = 200;

                if (gaiaGame.Map.HexArray[row, col] == null)
                {
                    message             = "出界了兄弟";
                    jsonData.info.state = 0;
                }
                else if (gaiaGame.Map.HexArray[row, col].TFTerrain == Terrain.Purple)
                {
                    Ore    = 0;
                    Credit = 0;
                    //message = "不能在紫色星球上建造";
                }
//                else if (gaiaGame.Map.HexArray[row, col].TFTerrain == Terrain.Empty)
//                {
//                    message = "你必须在星球上进行建造";
//                }
                //如果是盖亚星球不计算等级
                else if (gaiaGame.Map.HexArray[row, col].TFTerrain == Terrain.Green)
                {
                }
                else
                {
                    //改造等级
                    int transNumNeed = Math.Min(7 - Math.Abs(gaiaGame.Map.HexArray[row, col].OGTerrain - faction.OGTerrain), Math.Abs(gaiaGame.Map.HexArray[row, col].OGTerrain - faction.OGTerrain));
                    //需要工人 faction.TerraFormNumber:临时铲子
                    Ore = Faction.m_MineOreCost + Math.Max((transNumNeed - TerraFormNumber), 0) * faction.GetTransformCost;
                    //int Credit = Faction.m_MineCreditCost;
                }

                jsonData.info.message = message;
                jsonData.data         = new
                {
                    QSHIP  = QSHIP,
                    Ore    = Ore,
                    Credit = Credit,
                };
            }
            return(new JsonResult(jsonData));
        }