public IActionResult LeechPower(string name, FactionName factionName, int power, FactionName leechFactionName, bool isLeech, bool?isPwFirst)
        {
            if (ServerStatus.IsStopSyntax == true)
            {
                return(Redirect("/home/serverdown"));
            }
            var task = _userManager.GetUserAsync(HttpContext.User);

            Task[] taskarray = new Task[] { task };
            Task.WaitAll(taskarray, millisecondsTimeout: 1000);
            var faction = GameMgr.GetGameByName(name).FactionList.Find(x => x.FactionName.ToString().Equals(name));
            var leech   = isLeech ? "leech" : "decline";

            var syntax = string.Format("{0}:{1} {2} from {3}", factionName, leech, power, leechFactionName);

            if (isPwFirst.HasValue)
            {
                var pwFirst = isPwFirst.GetValueOrDefault() ? "pw" : "pwt";
                syntax = syntax + " " + pwFirst;
            }
            GaiaGame gaiaGame = GameMgr.GetGameByName(name);

            try
            {
                //GameMgr.WriteUserActionLog(syntax, task.Result.UserName);
            }
            catch { }
            gaiaGame.Syntax(syntax, out string log, dbContext: this.dbContext);
            //如果是即时制游戏,进行通知
            if (gaiaGame.IsSocket)
            {
                NoticeWebSocketMiddleware.GameActive(gaiaGame, HttpContext.User);
            }
            return(Redirect("/home/viewgame/" + System.Net.WebUtility.UrlEncode(name)));
        }
Beispiel #2
0
        public string Syntax(string name, string syntax, string factionName)
        {
            if (ServerStatus.IsStopSyntax == true)
            {
                return("error:" + "服务器维护中");
            }

            var task = _userManager.GetUserAsync(HttpContext.User);

            Task[] taskarray = new Task[] { task };
            Task.WaitAll(taskarray, millisecondsTimeout: 1000);
            if (task.Result != null)
            {
                if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(syntax))
                {
                    return("error:空语句");
                }
                else if (syntax.Contains("drop"))
                {
                    return("error:系统命令");
                }

                if (!string.IsNullOrEmpty(factionName))
                {
                    syntax = string.Format("{0}:{1}", factionName, syntax);
                }
                //游戏结束,发送邮件赋值,
                GaiaCore.Gaia.Game.DbGameSave._emailSender = this._emailSender;
                //执行命令
                GaiaGame gaiaGame = GameMgr.GetGameByName(name);
                try
                {
                    GameMgr.WriteUserActionLog(syntax, task.Result.UserName);
                }
                catch {
                    _logger.LogInformation(syntax);
                }
                gaiaGame.Syntax(syntax, out string log, task.Result.UserName, dbContext: this.dbContext);
                if (!string.IsNullOrEmpty(log))
                {
                    return("error:" + log);
                }
                else
                {
                    //如果是即时制游戏,进行通知
                    if (gaiaGame.IsSocket)
                    {
                        NoticeWebSocketMiddleware.GameActive(gaiaGame, HttpContext.User);
                    }
                    return("ok");
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, "没有获取到用户名");
                return("error:未登入用户");
            }
        }