diff --git a/OshimaServers/Service/FunGameService.cs b/OshimaServers/Service/FunGameService.cs index f575206..b66a1de 100644 --- a/OshimaServers/Service/FunGameService.cs +++ b/OshimaServers/Service/FunGameService.cs @@ -1401,10 +1401,10 @@ namespace Oshima.FunGame.OshimaServers.Service int totalMinutes = (int)diff.TotalMinutes; // 每分钟经验 - int experiencePerMinute = 1; + int experiencePerMinute = 2; // 最大练级时间 - int dailyTrainingMinutes = 1440; + int dailyTrainingMinutes = 2880; // 计算总经验奖励 totalExperience = Math.Min(totalMinutes, dailyTrainingMinutes) * experiencePerMinute; @@ -1419,25 +1419,25 @@ namespace Oshima.FunGame.OshimaServers.Service if (trainingHours >= 8) { - smallBookCount = Math.Min(1, trainingHours); + smallBookCount = Math.Min(2, trainingHours); } if (trainingHours >= 16) { - mediumBookCount = Math.Min(1, (trainingHours - 16) / 1); + mediumBookCount = Math.Min(2, (trainingHours - 16) / 1); } if (trainingHours >= 24) { - largeBookCount = Math.Min(1, (trainingHours - 24) / 1); + largeBookCount = Math.Min(2, (trainingHours - 24) / 1); } - double TotalHR = Math.Min(character.MaxHP, character.HR * diff.TotalSeconds); - double TotalMR = Math.Min(character.MaxMP, character.MR * diff.TotalSeconds); + double TotalHR = Math.Min(character.MaxHP, character.HR * 60 * (int)diff.TotalMinutes); + double TotalMR = Math.Min(character.MaxMP, character.MR * 60 * (int)diff.TotalMinutes); return $"练级时长:{totalMinutes} 分钟,{(isPre ? "预计可" : "")}获得:{totalExperience} 点经验值,{smallBookCount} 本小经验书,{mediumBookCount} 本中经验书,{largeBookCount} 本大经验书。" + $"回复角色 {TotalHR:0.##} 点生命值和 {TotalMR:0.##} 点魔法值。" + - $"{(isPre ? "练级时间上限 1440 分钟(24小时),超时将不会再产生收益,请按时领取奖励!" : "")}"; + $"{(isPre ? "练级时间上限 2880 分钟(48小时),超时将不会再产生收益,请按时领取奖励!" : "")}"; } public static string GetSkillLevelUpNeedy(int level) diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index 56be816..05abf72 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -3271,7 +3271,7 @@ namespace Oshima.FunGame.WebAPI.Controllers user.LastTime = DateTime.Now; pc.Add("user", user); pc.SaveConfig(); - return $"角色 [{character}] 开始练级,请过一段时间后进行【练级结算】,时间越长奖励越丰盛!练级时间上限 1440 分钟(24小时),超时将不会再产生收益,请按时领取奖励!"; + return $"角色 [{character}] 开始练级,请过一段时间后进行【练级结算】,时间越长奖励越丰盛!练级时间上限 2880 分钟(48小时),超时将不会再产生收益,请按时领取奖励!练级结束时,角色将根据练级总分钟数获得生命回复和魔法回复。"; } else { @@ -3318,8 +3318,8 @@ namespace Oshima.FunGame.WebAPI.Controllers if (totalExperience > 0) { character.EXP += totalExperience; - character.HP += character.HR * diff.TotalSeconds; - character.MP += character.MR * diff.TotalSeconds; + character.HP += character.HR * 60 * (int)diff.TotalMinutes; + character.MP += character.MR * 60 * (int)diff.TotalMinutes; } for (int i = 0; i < smallBookCount; i++) diff --git a/OshimaWebAPI/OshimaWebAPI.cs b/OshimaWebAPI/OshimaWebAPI.cs index 1e37027..ccf1239 100644 --- a/OshimaWebAPI/OshimaWebAPI.cs +++ b/OshimaWebAPI/OshimaWebAPI.cs @@ -29,12 +29,54 @@ namespace Oshima.FunGame.WebAPI public override string Author => OshimaGameModuleConstant.Author; + private IServiceScopeFactory? _serviceScopeFactory = null; + public override void ProcessInput(string input) { - if (input == "test") + // RainBOT 测试 + using (IServiceScope? scope = _serviceScopeFactory?.CreateScope()) { - //FunGameController controller = new(new Logger(new LoggerFactory())); - //Controller.WriteLine(Controller.JSON.GetObject(controller.ShowDailyStore(1)) ?? "test"); + if (scope != null) + { + // 从作用域中获取 IServiceProvider + IServiceProvider serviceProvider = scope.ServiceProvider; + + try + { + if (input.Trim() != "") + { + // 获取 RainBOTService 实例 + RainBOTService bot = serviceProvider.GetRequiredService(); + Controller.WriteLine("成功获取 RainBOTService 实例!"); + ThirdPartyMessage message = new() + { + IsGroup = false, + AuthorOpenId = "1", + OpenId = "1", + Detail = input, + Id = "1", + Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + + bool result = bot.Handler(message).GetAwaiter().GetResult(); + + if (!result || message.IsCompleted) + { + Controller.WriteLine(message.Result); + } + } + + if (input == "test") + { + //FunGameController funGameController = serviceProvider.GetRequiredService(); + //Controller.WriteLine(Controller.JSON.GetObject(funGameController.ShowDailyStore(1)) ?? "test"); + } + } + catch (Exception e) + { + Controller.Error(e); + } + } } if (input == "testuser") @@ -189,6 +231,15 @@ namespace Oshima.FunGame.WebAPI WebAPIAuthenticator.WebAPICustomBearerTokenAuthenticator += CustomBearerTokenAuthenticator; } + public override void OnWebAPIStarted(params object[] objs) + { + if (objs.Length > 0 && objs[0] is WebApplication app) + { + _serviceScopeFactory = app.Services.GetRequiredService(); + Controller.WriteLine("获取到:IServiceScopeFactory"); + } + } + private string CustomBearerTokenAuthenticator(string token) { if (GeneralSettings.TokenList.Contains(token)) diff --git a/OshimaWebAPI/Services/RainBOTService.cs b/OshimaWebAPI/Services/RainBOTService.cs index 81e3819..f3e0e68 100644 --- a/OshimaWebAPI/Services/RainBOTService.cs +++ b/OshimaWebAPI/Services/RainBOTService.cs @@ -496,7 +496,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail.StartsWith("生成")) { e.UseNotice = false; - string pattern = @"生成\s*(\d+)\s*个\s*([\s\S]+)(?:\s*给\s*(\d+))"; + string pattern = @"生成\s*(\d+)\s*个\s*([\s\S]+)(?:\s*给\s*(\d+))?"; Regex regex = new(pattern, RegexOptions.IgnoreCase); Match match = regex.Match(e.Detail); @@ -522,7 +522,7 @@ namespace Oshima.FunGame.WebAPI.Services } else { - await SendAsync(e, "熟圣之力", "数量不能为0,请重新输入。"); + await SendAsync(e, "熟圣之力", "数量不能为 0,请重新输入。"); } return result; } @@ -1385,7 +1385,7 @@ namespace Oshima.FunGame.WebAPI.Services { string detail = e.Detail.Replace("使用", "").Trim(); char[] chars = [',', ' ', ',', ';', ';']; - string pattern = @"^\s*(?:(?\d+)|(?[^\d\s].*?))\s*(?:(?\d+)(?:\s+角色\s*(?[\d\s,,;;]*))?)?$"; + string pattern = @"^\s*(?:(?\d+)|(?[^\d\s].*?))(?:\s+(?\d+))?(?:\s*角色\s*(?[\d\s,,;;]*))?$"; Match match = Regex.Match(detail, pattern); if (match.Success) {