From da2f1fc23c6c7449a37eda5c298c87eee9e2caca Mon Sep 17 00:00:00 2001 From: milimoe Date: Sun, 13 Oct 2024 15:14:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20Oshima=20Core=20=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=20FunGame=20WebAPI=20=E6=8F=92=E4=BB=B6=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OshimaCore/Configs/BlackList.cs | 7 + OshimaCore/Configs/Daily.cs | 117 ++++ OshimaCore/Configs/GeneralSettings.cs | 52 ++ OshimaCore/Configs/Ignore.cs | 132 +++++ OshimaCore/Configs/OSMCore.cs | 24 + OshimaCore/Configs/QQOpenID.cs | 36 ++ OshimaCore/Configs/SayNo.cs | 244 ++++++++ OshimaCore/Constant/TypeEnum.cs | 13 + OshimaCore/Controllers/FunGameController.cs | 78 +++ OshimaCore/Controllers/QQController.cs | 40 ++ OshimaCore/Controllers/UserDailyController.cs | 61 ++ OshimaCore/Models/BindQQ.cs | 8 + OshimaCore/Models/UserDaily.cs | 9 + OshimaCore/OshimaCore.csproj | 33 ++ OshimaCore/OshimaWebAPI.cs | 41 ++ OshimaCore/Properties/launchSettings.json | 12 + OshimaCore/Utils/FunGameUtil.cs | 542 ++++++++++++++++++ OshimaCore/Utils/UserDailyUtil.cs | 67 +++ OshimaGameModule.sln | 10 +- OshimaModules/Modules/Constant.cs | 1 + 20 files changed, 1525 insertions(+), 2 deletions(-) create mode 100644 OshimaCore/Configs/BlackList.cs create mode 100644 OshimaCore/Configs/Daily.cs create mode 100644 OshimaCore/Configs/GeneralSettings.cs create mode 100644 OshimaCore/Configs/Ignore.cs create mode 100644 OshimaCore/Configs/OSMCore.cs create mode 100644 OshimaCore/Configs/QQOpenID.cs create mode 100644 OshimaCore/Configs/SayNo.cs create mode 100644 OshimaCore/Constant/TypeEnum.cs create mode 100644 OshimaCore/Controllers/FunGameController.cs create mode 100644 OshimaCore/Controllers/QQController.cs create mode 100644 OshimaCore/Controllers/UserDailyController.cs create mode 100644 OshimaCore/Models/BindQQ.cs create mode 100644 OshimaCore/Models/UserDaily.cs create mode 100644 OshimaCore/OshimaCore.csproj create mode 100644 OshimaCore/OshimaWebAPI.cs create mode 100644 OshimaCore/Properties/launchSettings.json create mode 100644 OshimaCore/Utils/FunGameUtil.cs create mode 100644 OshimaCore/Utils/UserDailyUtil.cs diff --git a/OshimaCore/Configs/BlackList.cs b/OshimaCore/Configs/BlackList.cs new file mode 100644 index 0000000..c817a65 --- /dev/null +++ b/OshimaCore/Configs/BlackList.cs @@ -0,0 +1,7 @@ +namespace Oshima.Core.Configs +{ + public class BlackList + { + public static Dictionary Times { get; } = []; + } +} diff --git a/OshimaCore/Configs/Daily.cs b/OshimaCore/Configs/Daily.cs new file mode 100644 index 0000000..d6ad633 --- /dev/null +++ b/OshimaCore/Configs/Daily.cs @@ -0,0 +1,117 @@ +using Milimoe.FunGame.Core.Api.Utility; +using Oshima.Core.Constant; + +namespace Oshima.Core.Configs +{ + public class Daily + { + public static bool DailyNews { get; set; } = false; + + public static bool ClearDailys { get; set; } = true; + + public static Dictionary UserDailys { get; } = []; + + public static List GreatFortune { get; set; } = []; + + public static List ModerateFortune { get; set; } = []; + + public static List GoodFortune { get; set; } = []; + + public static List MinorFortune { get; set; } = []; + + public static List Misfortune { get; set; } = []; + + public static List GreatMisfortune { get; set; } = []; + + public static List DailyTypes { get; set; } = []; + + public static PluginConfig DailyContent { get; set; } = new("rainbot", "daily"); + + public static PluginConfig Configs { get; set; } = new("rainbot", "userdaliys"); + + public static void InitDaily() + { + DailyContent.LoadConfig(); + if (DailyContent.TryGetValue("GreatFortune", out object? value) && value != null) + { + GreatFortune = (List)value; + } + if (DailyContent.TryGetValue("ModerateFortune", out value) && value != null) + { + ModerateFortune = (List)value; + } + if (DailyContent.TryGetValue("GoodFortune", out value) && value != null) + { + GoodFortune = (List)value; + } + if (DailyContent.TryGetValue("SmallFortune", out value) && value != null) + { + MinorFortune = (List)value; + } + if (DailyContent.TryGetValue("Misfortune", out value) && value != null) + { + Misfortune = (List)value; + } + if (DailyContent.TryGetValue("GreatMisfortune", out value) && value != null) + { + GreatMisfortune = (List)value; + } + + DailyTypes.Clear(); + if (GreatFortune.Count != 0) + { + DailyTypes.Add(DailyType.GreatFortune); + } + if (ModerateFortune.Count != 0) + { + DailyTypes.Add(DailyType.ModerateFortune); + } + if (GoodFortune.Count != 0) + { + DailyTypes.Add(DailyType.GoodFortune); + } + if (MinorFortune.Count != 0) + { + DailyTypes.Add(DailyType.MinorFortune); + } + if (Misfortune.Count != 0) + { + DailyTypes.Add(DailyType.Misfortune); + } + if (GreatMisfortune.Count != 0) + { + DailyTypes.Add(DailyType.GreatMisfortune); + } + + Configs.LoadConfig(); + foreach (string str in Configs.Keys) + { + if (long.TryParse(str, out long qq) && Configs.TryGetValue(str, out object? value2) && value2 != null && !UserDailys.ContainsKey(qq)) + { + UserDailys.Add(qq, value2.ToString() ?? ""); + if (UserDailys[qq] == "") UserDailys.Remove(qq); + } + } + SaveDaily(); + } + + public static void SaveDaily() + { + lock (Configs) + { + Configs.Clear(); + foreach (long qq in UserDailys.Keys) + { + Configs.Add(qq.ToString(), UserDailys[qq]); + } + Configs.SaveConfig(); + } + } + + public static void ClearDaily() + { + UserDailys.Clear(); + SaveDaily(); + } + } +} diff --git a/OshimaCore/Configs/GeneralSettings.cs b/OshimaCore/Configs/GeneralSettings.cs new file mode 100644 index 0000000..99e45e3 --- /dev/null +++ b/OshimaCore/Configs/GeneralSettings.cs @@ -0,0 +1,52 @@ +using Milimoe.FunGame.Core.Api.Utility; + +namespace Oshima.Core.Configs +{ + public class GeneralSettings + { + public static bool IsRun { get; set; } = true; + + public static long BotQQ { get; set; } = -1; + + public static long Master { get; set; } = -1; + + public static bool IsDebug { get; set; } = false; + + public static long BlackTimes { get; set; } = 5; + + public static int BlackFrozenTime { get; set; } = 150; + + public static PluginConfig Configs { get; set; } = new("rainbot", "config"); + + public static void LoadSetting() + { + PluginConfig configs = new("rainbot", "config"); + configs.LoadConfig(); + if (configs.TryGetValue("BotQQ", out object? value) && value != null) + { + BotQQ = (long)value; + } + if (configs.TryGetValue("Master", out value) && value != null) + { + Master = (long)value; + } + if (configs.TryGetValue("BlackTimes", out value) && value != null) + { + BlackTimes = (long)value; + } + if (configs.TryGetValue("BlackFrozenTime", out value) && value != null) + { + BlackFrozenTime = Convert.ToInt32((long)value); + } + } + + public static void SaveConfig() + { + Configs.Add("BotQQ", BotQQ); + Configs.Add("Master", Master); + Configs.Add("BlackTimes", BlackTimes); + Configs.Add("BlackFrozenTime", BlackFrozenTime); + Configs.SaveConfig(); + } + } +} diff --git a/OshimaCore/Configs/Ignore.cs b/OshimaCore/Configs/Ignore.cs new file mode 100644 index 0000000..887ada4 --- /dev/null +++ b/OshimaCore/Configs/Ignore.cs @@ -0,0 +1,132 @@ +using Milimoe.FunGame.Core.Api.Utility; + +namespace Oshima.Core.Configs +{ + public class Ignore + { + public static HashSet RepeatIgnore { get; set; } = []; + + public static List CallBrotherQQIgnore { get; set; } = []; + + /// + /// 这个属性暂时没用到 标记一下 + /// + public static List QQGroupIgnore { get; set; } = []; + + public static List RepeatQQIgnore { get; set; } = []; + + public static List ReverseAtIgnore { get; set; } = []; + + public static PluginConfig Configs { get; set; } = new("rainbot", "ignore"); + + public static void InitIgnore() + { + PluginConfig configs = new("rainbot", "ignore"); + configs.LoadConfig(); + if (configs.TryGetValue("RepeatIgnore", out object? value) && value != null) + { + RepeatIgnore = new HashSet((List)value); + } + if (configs.TryGetValue("CallBrotherQQIgnore", out value) && value != null) + { + CallBrotherQQIgnore = new List((List)value); + } + if (configs.TryGetValue("QQGroupIgnore", out value) && value != null) + { + QQGroupIgnore = (List)value; + } + if (configs.TryGetValue("RepeatQQIgnore", out value) && value != null) + { + RepeatQQIgnore = (List)value; + } + if (configs.TryGetValue("ReverseAtIgnore", out value) && value != null) + { + ReverseAtIgnore = (List)value; + } + } + + public static void SaveConfig() + { + Configs.Add("RepeatIgnore", RepeatIgnore); + Configs.Add("CallBrotherQQIgnore", CallBrotherQQIgnore); + Configs.Add("QQGroupIgnore", QQGroupIgnore); + Configs.Add("RepeatQQIgnore", RepeatQQIgnore); + Configs.Add("ReverseAtIgnore", ReverseAtIgnore); + Configs.SaveConfig(); + } + + public static bool AddValue(string part, bool isadd, object value) + { + try + { + string strv = value.ToString() ?? ""; + switch (part.ToLower()) + { + case "repeatignore": + if (isadd) RepeatIgnore.Add(strv); + else RepeatIgnore.Remove(strv); + break; + case "callbrotherqqignore": + if (long.TryParse(strv, out long lv)) + { + if (isadd) CallBrotherQQIgnore.Add(lv); + else CallBrotherQQIgnore.Remove(lv); + } + break; + case "qqgroupignore": + if (long.TryParse(strv, out lv)) + { + if (isadd) QQGroupIgnore.Add(lv); + else QQGroupIgnore.Remove(lv); + } + break; + case "repeatqqignore": + if (long.TryParse(strv, out lv)) + { + if (isadd) RepeatQQIgnore.Add(lv); + else RepeatQQIgnore.Remove(lv); + } + break; + case "reverseatignore": + if (long.TryParse(strv, out lv)) + { + if (isadd) ReverseAtIgnore.Add(lv); + else ReverseAtIgnore.Remove(lv); + } + break; + default: + return false; + } + } + catch + { + return false; + } + return true; + } + + public static string ShowList(string group) + { + List list = []; + switch (group.ToLower()) + { + case "repeatignore": + list = [.. RepeatIgnore]; + break; + case "callbrotherqqignore": + list = CallBrotherQQIgnore.Select(x => x.ToString()).ToList(); + break; + case "qqgroupignore": + list = QQGroupIgnore.Select(x => x.ToString()).ToList(); + break; + case "repeatqqignore": + list = RepeatQQIgnore.Select(x => x.ToString()).ToList(); + break; + case "reverseatignore": + list = ReverseAtIgnore.Select(x => x.ToString()).ToList(); + break; + } + return list.Count > 0 ? "列表" + group + "拥有以下成员:" + "\r\n" + string.Join("\r\n", list) : "此列表不存在或没有任何成员。"; + } + } +} diff --git a/OshimaCore/Configs/OSMCore.cs b/OshimaCore/Configs/OSMCore.cs new file mode 100644 index 0000000..aa1edef --- /dev/null +++ b/OshimaCore/Configs/OSMCore.cs @@ -0,0 +1,24 @@ +using System.Globalization; +using System.Reflection; + +namespace Oshima.Core.Configs +{ + public class OSMCore + { + public const string version = "v1.0"; + public const string version2 = "Beta4"; + + public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {GetBuiltTime(Assembly.GetExecutingAssembly().Location)}\r\nSee: https://github.com/milimoe"; + + public static string GetBuiltTime(string dll_name) + { + DateTime lastWriteTime = File.GetLastWriteTime(dll_name); + + string month = lastWriteTime.ToString("MMM", CultureInfo.InvariantCulture); + int day = lastWriteTime.Day; + string time = lastWriteTime.ToString("HH:mm:ss", CultureInfo.InvariantCulture); + + return $"{month}. {day}, {lastWriteTime.Year} {time}"; + } + } +} diff --git a/OshimaCore/Configs/QQOpenID.cs b/OshimaCore/Configs/QQOpenID.cs new file mode 100644 index 0000000..a27ddfd --- /dev/null +++ b/OshimaCore/Configs/QQOpenID.cs @@ -0,0 +1,36 @@ +using Milimoe.FunGame.Core.Api.Utility; + +namespace Oshima.Core.Configs +{ + public class QQOpenID + { + public static Dictionary QQAndOpenID { get; set; } = []; + + public static PluginConfig Configs { get; set; } = new("rainbot", "qqopenid"); + + public static void LoadConfig() + { + Configs.LoadConfig(); + foreach (string str in Configs.Keys) + { + if (Configs.TryGetValue(str, out object? value) && value is long qq && qq != 0) + { + QQAndOpenID.TryAdd(str, qq); + } + } + } + + public static void SaveConfig() + { + lock (Configs) + { + Configs.Clear(); + foreach (string openid in QQAndOpenID.Keys) + { + Configs.Add(openid, QQAndOpenID[openid]); + } + Configs.SaveConfig(); + } + } + } +} diff --git a/OshimaCore/Configs/SayNo.cs b/OshimaCore/Configs/SayNo.cs new file mode 100644 index 0000000..f41cb57 --- /dev/null +++ b/OshimaCore/Configs/SayNo.cs @@ -0,0 +1,244 @@ +using Milimoe.FunGame.Core.Api.Utility; + +namespace Oshima.Core.Configs +{ + public class SayNo + { + public static HashSet Trigger { get; set; } = []; + + public static HashSet TriggerBeforeNo { get; set; } = []; + + public static HashSet IgnoreTriggerAfterNo { get; set; } = []; + + public static HashSet IgnoreTriggerBeforeCan { get; set; } = []; + + public static HashSet TriggerAfterYes { get; set; } = []; + + public static HashSet WillNotSayNo { get; set; } = []; + + public static List SayNoWords { get; set; } = []; + + public static List SayDontHaveWords { get; set; } = []; + + public static List SayNotYesWords { get; set; } = []; + + public static List SayDontWords { get; set; } = []; + + public static List SayWantWords { get; set; } = []; + + public static List SayThinkWords { get; set; } = []; + + public static List SaySpecialNoWords { get; set; } = []; + + public static PluginConfig Configs { get; set; } = new("rainbot", "sayno"); + + public static void InitSayNo() + { + PluginConfig configs = new("rainbot", "sayno"); + configs.LoadConfig(); + foreach (string key in configs.Keys) + { + if (configs.TryGetValue(key, out object? value) && value != null) + { + switch (key) + { + case "Trigger": + Trigger = new HashSet((List)value); + break; + case "TriggerBeforeNo": + TriggerBeforeNo = new HashSet((List)value); + break; + case "IgnoreTriggerAfterNo": + IgnoreTriggerAfterNo = new HashSet((List)value); + break; + case "IgnoreTriggerBeforeCan": + IgnoreTriggerBeforeCan = new HashSet((List)value); + break; + case "TriggerAfterYes": + TriggerAfterYes = new HashSet((List)value); + break; + case "WillNotSayNo": + WillNotSayNo = new HashSet((List)value); + break; + case "SayNoWords": + SayNoWords = (List)value; + break; + case "SayDontHaveWords": + SayDontHaveWords = (List)value; + break; + case "SayNotYesWords": + SayNotYesWords = (List)value; + break; + case "SayDontWords": + SayDontWords = (List)value; + break; + case "SayWantWords": + SayWantWords = (List)value; + break; + case "SayThinkWords": + SayThinkWords = (List)value; + break; + case "SaySpecialNoWords": + SaySpecialNoWords = (List)value; + break; + } + } + } + } + + public static void SaveConfig() + { + Configs.Add("Trigger", Trigger); + Configs.Add("TriggerBeforeNo", TriggerBeforeNo); + Configs.Add("IgnoreTriggerAfterNo", IgnoreTriggerAfterNo); + Configs.Add("IgnoreTriggerBeforeCan", IgnoreTriggerBeforeCan); + Configs.Add("TriggerAfterYes", TriggerAfterYes); + Configs.Add("WillNotSayNo", WillNotSayNo); + Configs.Add("SayNoWords", SayNoWords); + Configs.Add("SayDontHaveWords", SayDontHaveWords); + Configs.Add("SayNotYesWords", SayNotYesWords); + Configs.Add("SayDontWords", SayDontWords); + Configs.Add("SayWantWords", SayWantWords); + Configs.Add("SayThinkWords", SayThinkWords); + Configs.Add("SaySpecialNoWords", SaySpecialNoWords); + Configs.SaveConfig(); + } + + public static bool AddWord(string part, bool isadd, string value) + { + HashSet set = []; + List list = []; + bool islist = false; + switch (part.ToLower()) + { + case "trigger": + set = Trigger; + break; + case "triggerbeforeno": + set = TriggerBeforeNo; + break; + case "ignoretriggerafterno": + set = IgnoreTriggerAfterNo; + break; + case "ignoretriggerbeforecan": + set = IgnoreTriggerBeforeCan; + break; + case "triggerafteryes": + set = TriggerAfterYes; + break; + case "willnotsayno": + set = WillNotSayNo; + break; + case "saynowords": + islist = true; + list = SayNoWords; + break; + case "saydonthavewords": + islist = true; + list = SayDontHaveWords; + break; + case "saynotyeswords": + islist = true; + list = SayNotYesWords; + break; + case "saydontwords": + islist = true; + list = SayDontWords; + break; + case "saywantwords": + islist = true; + list = SayWantWords; + break; + case "saythinkwords": + islist = true; + list = SayThinkWords; + break; + case "sayspecialnowords": + islist = true; + list = SaySpecialNoWords; + break; + default: + return false; + } + if (isadd) + { + if (islist) list.Add(value); + else set.Add(value); + } + else + { + if (islist) list.Remove(value); + else set.Remove(value); + } + return true; + } + + public static string ShowList(string part) + { + HashSet set = []; + List list = []; + bool islist = false; + switch (part.ToLower()) + { + case "trigger": + set = Trigger; + break; + case "triggerbeforeno": + set = TriggerBeforeNo; + break; + case "ignoretriggerafterno": + set = IgnoreTriggerAfterNo; + break; + case "ignoretriggerbeforecan": + set = IgnoreTriggerBeforeCan; + break; + case "triggerafteryes": + set = TriggerAfterYes; + break; + case "willnotsayno": + set = WillNotSayNo; + break; + case "saynowords": + islist = true; + list = SayNoWords; + break; + case "saydonthavewords": + islist = true; + list = SayDontHaveWords; + break; + case "saynotyeswords": + islist = true; + list = SayNotYesWords; + break; + case "saydontwords": + islist = true; + list = SayDontWords; + break; + case "saywantwords": + islist = true; + list = SayWantWords; + break; + case "saythinkwords": + islist = true; + list = SayThinkWords; + break; + case "sayspecialnowords": + islist = true; + list = SaySpecialNoWords; + break; + default: + break; + } + string msg; + if (islist) + { + msg = list.Count > 0 ? "列表" + part + "拥有以下成员:" + "\r\n" + string.Join("\r\n", list) : "此列表不存在或没有任何成员。"; + } + else + { + msg = set.Count > 0 ? "列表" + part + "拥有以下成员:" + "\r\n" + string.Join("\r\n", set) : "此列表不存在或没有任何成员。"; + } + return msg; + } + } +} \ No newline at end of file diff --git a/OshimaCore/Constant/TypeEnum.cs b/OshimaCore/Constant/TypeEnum.cs new file mode 100644 index 0000000..0b5042d --- /dev/null +++ b/OshimaCore/Constant/TypeEnum.cs @@ -0,0 +1,13 @@ +namespace Oshima.Core.Constant +{ + public enum DailyType + { + None, + GreatFortune, + ModerateFortune, + GoodFortune, + MinorFortune, + Misfortune, + GreatMisfortune + } +} diff --git a/OshimaCore/Controllers/FunGameController.cs b/OshimaCore/Controllers/FunGameController.cs new file mode 100644 index 0000000..1027cda --- /dev/null +++ b/OshimaCore/Controllers/FunGameController.cs @@ -0,0 +1,78 @@ +using System.Text; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; +using Oshima.Core.Utils; + +namespace Oshima.Core.Controllers +{ + [ApiController] + [Route("[controller]")] + public class FunGameController(ILogger logger) : ControllerBase + { + private readonly ILogger _logger = logger; + + [HttpGet("test")] + public List GetTest([FromQuery] bool? isweb = null) + { + if (isweb ?? true) + { + return FunGameSimulation.StartGame(false, true); + } + else + { + return FunGameSimulation.StartGame(false, false); + } + } + + [HttpGet("stats")] + public string GetStats([FromQuery] int? id = null) + { + if (id != null && id > 0 && id <= FunGameSimulation.Characters.Count) + { + Character character = FunGameSimulation.Characters[Convert.ToInt32(id) - 1]; + if (FunGameSimulation.CharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) + { + StringBuilder builder = new(); + + builder.AppendLine(character.ToString()); + builder.AppendLine($"ܼ˺{stats.TotalDamage:0.##} / {stats.AvgDamage:0.##}"); + builder.AppendLine($"ܼ˺{stats.TotalPhysicalDamage:0.##} / {stats.AvgPhysicalDamage:0.##}"); + builder.AppendLine($"ܼħ˺{stats.TotalMagicDamage:0.##} / {stats.AvgMagicDamage:0.##}"); + builder.AppendLine($"ܼʵ˺{stats.TotalRealDamage:0.##} / {stats.AvgRealDamage:0.##}"); + builder.AppendLine($"ܼƳ˺{stats.TotalTakenDamage:0.##} / {stats.AvgTakenDamage:0.##}"); + builder.AppendLine($"ܼƳ˺{stats.TotalTakenPhysicalDamage:0.##} / {stats.AvgTakenPhysicalDamage:0.##}"); + builder.AppendLine($"ܼƳħ˺{stats.TotalTakenMagicDamage:0.##} / {stats.AvgTakenMagicDamage:0.##}"); + builder.AppendLine($"ܼƳʵ˺{stats.TotalTakenRealDamage:0.##} / {stats.AvgTakenRealDamage:0.##}"); + builder.AppendLine($"ܼƴغ{stats.LiveRound} / {stats.AvgLiveRound}"); + builder.AppendLine($"ܼжغ{stats.ActionTurn} / {stats.AvgActionTurn}"); + builder.AppendLine($"ܼƴʱ{stats.LiveTime:0.##} / {stats.AvgLiveTime:0.##}"); + builder.AppendLine($"ܼ׬ȡǮ{stats.TotalEarnedMoney} / {stats.AvgEarnedMoney}"); + builder.AppendLine($"ÿغ˺{stats.DamagePerRound:0.##}"); + builder.AppendLine($"ÿжغ˺{stats.DamagePerTurn:0.##}"); + builder.AppendLine($"ÿ˺{stats.DamagePerSecond:0.##}"); + builder.AppendLine($"ܼƻɱ{stats.Kills}" + (stats.Plays != 0 ? $" / {(double)stats.Kills / stats.Plays:0.##}" : "")); + builder.AppendLine($"ܼ{stats.Deaths}" + (stats.Plays != 0 ? $" / {(double)stats.Deaths / stats.Plays:0.##}" : "")); + builder.AppendLine($"ܼ{stats.Assists}" + (stats.Plays != 0 ? $" / {(double)stats.Assists / stats.Plays:0.##}" : "")); + builder.AppendLine($"ܼƲ{stats.Plays}"); + builder.AppendLine($"ܼƹھ{stats.Wins}"); + builder.AppendLine($"ܼǰ{stats.Top3s}"); + builder.AppendLine($"ܼưܳ{stats.Loses}"); + builder.AppendLine($"ʤʣ{stats.Winrates * 100:0.##}%"); + builder.AppendLine($"ǰʣ{stats.Top3rates * 100:0.##}%"); + builder.AppendLine($"ϴ{stats.LastRank} / Σ{stats.AvgRank}"); + + return NetworkUtility.JsonSerialize(builder.ToString()); + } + } + return NetworkUtility.JsonSerialize(""); + } + + [HttpPost("post")] + public string PostName([FromBody] string name) + { + return NetworkUtility.JsonSerialize($"Your Name received successfully: {name}."); + } + } +} diff --git a/OshimaCore/Controllers/QQController.cs b/OshimaCore/Controllers/QQController.cs new file mode 100644 index 0000000..a1e0d2b --- /dev/null +++ b/OshimaCore/Controllers/QQController.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Milimoe.FunGame.Core.Api.Utility; +using Oshima.Core.Configs; +using Oshima.Core.Models; + +namespace Oshima.Core.Controllers +{ + [ApiController] + [Route("[controller]")] + public class QQController(ILogger logger) : ControllerBase + { + private readonly ILogger _logger = logger; + + [HttpPost("bind")] + public string Post([FromBody] BindQQ b) + { + if (QQOpenID.QQAndOpenID.Values.Any(qq => qq == b.QQ)) + { + return NetworkUtility.JsonSerialize($"QQѱ˰󶨣ǴQQˣϵͷ"); + } + + if (QQOpenID.QQAndOpenID.TryGetValue(b.Openid, out long bindqq) && bindqq != 0) + { + return NetworkUtility.JsonSerialize($"Ѿ󶨹{bindqq}󶨴ϵͷ"); + } + + if (QQOpenID.QQAndOpenID.TryAdd(b.Openid, b.QQ)) + { + QQOpenID.SaveConfig(); + } + else + { + return NetworkUtility.JsonSerialize($"ʧܣԺԣʧϵͷ"); + } + + return NetworkUtility.JsonSerialize("󶨳ɹ"); + } + } +} diff --git a/OshimaCore/Controllers/UserDailyController.cs b/OshimaCore/Controllers/UserDailyController.cs new file mode 100644 index 0000000..74d18c7 --- /dev/null +++ b/OshimaCore/Controllers/UserDailyController.cs @@ -0,0 +1,61 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Milimoe.FunGame.Core.Api.Utility; +using Oshima.Core.Configs; +using Oshima.Core.Models; +using Oshima.Core.Utils; + +namespace Oshima.Core.Controllers +{ + [ApiController] + [Route("[controller]")] + public class UserDailyController(ILogger logger) : ControllerBase + { + private readonly ILogger _logger = logger; + + [HttpGet("{user_id}", Name = "GetUserDaily")] + public UserDaily Get(long user_id) + { + return UserDailyUtil.GetUserDaily(user_id); + } + + [HttpGet("v/{user_id}", Name = "ViewUserDaily")] + public UserDaily View(long user_id) + { + return UserDailyUtil.ViewUserDaily(user_id); + } + + [HttpGet("open/{open_id}", Name = "GetOpenUserDaily")] + public UserDaily Open(string open_id) + { + if (QQOpenID.QQAndOpenID.TryGetValue(open_id, out long qq) && qq != 0) + { + return UserDailyUtil.GetUserDaily(qq); + } + return new(0, 0, "ƺûаQQأȷ͡+QQš磺123456789ʹŶ"); + } + + [HttpGet("r/{user_id}", Name = "RemoveUserDaily")] + public string Remove(long user_id) + { + return UserDailyUtil.RemoveDaily(user_id); + } + + [HttpGet("img/{type}", Name = "GetTypeImage")] + public string GetTypeImage(int type) + { + string img = $"{Request.Scheme}://{Request.Host}{Request.PathBase}/images/zi/"; + img += type switch + { + 1 => "dj" + (Random.Shared.Next(3) + 1) + ".png", + 2 => "zj" + (Random.Shared.Next(2) + 1) + ".png", + 3 => "j" + (Random.Shared.Next(4) + 1) + ".png", + 4 => "mj" + (Random.Shared.Next(2) + 1) + ".png", + 5 => "x" + (Random.Shared.Next(2) + 1) + ".png", + 6 => "dx" + (Random.Shared.Next(2) + 1) + ".png", + _ => "" + }; + return NetworkUtility.JsonSerialize(img); + } + } +} diff --git a/OshimaCore/Models/BindQQ.cs b/OshimaCore/Models/BindQQ.cs new file mode 100644 index 0000000..eecf7c6 --- /dev/null +++ b/OshimaCore/Models/BindQQ.cs @@ -0,0 +1,8 @@ +namespace Oshima.Core.Models +{ + public class BindQQ(string openid, long qq) + { + public string Openid { get; set; } = openid; + public long QQ { get; set; } = qq; + } +} diff --git a/OshimaCore/Models/UserDaily.cs b/OshimaCore/Models/UserDaily.cs new file mode 100644 index 0000000..0cce933 --- /dev/null +++ b/OshimaCore/Models/UserDaily.cs @@ -0,0 +1,9 @@ +namespace Oshima.Core.Models +{ + public class UserDaily(long user_id, long type, string daily) + { + public long user_id { get; set; } = user_id; + public long type { get; set; } = type; + public string daily { get; set; } = daily; + } +} diff --git a/OshimaCore/OshimaCore.csproj b/OshimaCore/OshimaCore.csproj new file mode 100644 index 0000000..4470065 --- /dev/null +++ b/OshimaCore/OshimaCore.csproj @@ -0,0 +1,33 @@ + + + + net8.0 + enable + enable + Oshima.Core + OshimaCore + ..\bin\ + + + + 1701;1702;IDE0130;CA1822;IDE1006 + + + + 1701;1702;IDE0130;CA1822;IDE1006 + + + + + + + + + + + + ..\..\FunGame.Core\bin\Debug\net8.0\FunGame.Core.dll + + + + diff --git a/OshimaCore/OshimaWebAPI.cs b/OshimaCore/OshimaWebAPI.cs new file mode 100644 index 0000000..c2e406b --- /dev/null +++ b/OshimaCore/OshimaWebAPI.cs @@ -0,0 +1,41 @@ +using Milimoe.FunGame.Core.Library.Common.Addon; +using Milimoe.FunGame.Core.Library.Exception; +using Oshima.FunGame.OshimaModules; + +namespace Oshima.Core.WebAPI +{ + public class OshimaWebAPI : WebAPIPlugin + { + public override string Name => OshimaGameModuleConstant.WebAPI; + + public override string Description => OshimaGameModuleConstant.Description; + + public override string Version => OshimaGameModuleConstant.Version; + + public override string Author => OshimaGameModuleConstant.Author; + + public override void AfterLoad(params object[] objs) + { + base.AfterLoad(objs); + } + + protected override bool BeforeLoad(params object[] objs) + { + if (objs.Length > 0 && objs[0] is Dictionary delegates) + { + if (delegates.TryGetValue("WriteLine", out object? value) && value is Action a) + { + WriteLine = a; + } + if (delegates.TryGetValue("Error", out value) && value is Action e) + { + Error = e; + } + } + return true; + } + + public Action WriteLine { get; set; } = new Action(Console.WriteLine); + public Action Error { get; set; } = new Action(e => Console.WriteLine(e.GetErrorInfo())); + } +} diff --git a/OshimaCore/Properties/launchSettings.json b/OshimaCore/Properties/launchSettings.json new file mode 100644 index 0000000..bc4c471 --- /dev/null +++ b/OshimaCore/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "WebAPIExtension": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:11108;http://localhost:11109" + } + } +} \ No newline at end of file diff --git a/OshimaCore/Utils/FunGameUtil.cs b/OshimaCore/Utils/FunGameUtil.cs new file mode 100644 index 0000000..a197495 --- /dev/null +++ b/OshimaCore/Utils/FunGameUtil.cs @@ -0,0 +1,542 @@ +using System.Text; +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Library.Constant; +using Oshima.FunGame.OshimaModules.Characters; +using Oshima.FunGame.OshimaModules.Items; +using Oshima.FunGame.OshimaModules.Skills; + +namespace Oshima.Core.Utils +{ + public class FunGameSimulation + { + public FunGameSimulation() + { + InitCharacter(); + + bool printout = true; + List strs = StartGame(printout); + if (printout == false) + { + foreach (string str in strs) + { + Console.WriteLine(str); + } + } + + Console.ReadKey(); + } + + public static List Characters { get; } = []; + public static Dictionary CharacterStatistics { get; } = []; + public static PluginConfig StatsConfig { get; } = new(nameof(FunGameSimulation), nameof(CharacterStatistics)); + public static bool IsRuning { get; set; } = false; + public static bool IsWeb { get; set; } = false; + public static bool PrintOut { get; set; } = false; + public static string Msg { get; set; } = ""; + + public static List StartGame(bool printout, bool isWeb = false) + { + PrintOut = printout; + IsWeb = isWeb; + try + { + if (IsRuning) return ["游戏正在模拟中,请勿重复请求!"]; + + List result = []; + int deaths = 0; + Msg = ""; + + IsRuning = true; + + // M = 0, W = 7, P1 = 1, P3 = 1 + // M = 1, W = 6, P1 = 2, P3 = 0 + // M = 2, W = 4, P1 = 0, P3 = 2 + // M = 2, W = 5, P1 = 0, P3 = 0 + // M = 3, W = 3, P1 = 1, P3 = 1 + // M = 4, W = 2, P1 = 2, P3 = 0 + // M = 5, W = 0, P1 = 0, P3 = 2 + // M = 5, W = 1, P1 = 0, P3 = 0 + + List list = new(Characters); + + if (list.Count > 11) + { + if (PrintOut) Console.WriteLine(); + if (PrintOut) Console.WriteLine("Start!!!"); + if (PrintOut) Console.WriteLine(); + + Character character1 = list[0].Copy(); + Character character2 = list[1].Copy(); + Character character3 = list[2].Copy(); + Character character4 = list[3].Copy(); + Character character5 = list[4].Copy(); + Character character6 = list[5].Copy(); + Character character7 = list[6].Copy(); + Character character8 = list[7].Copy(); + Character character9 = list[8].Copy(); + Character character10 = list[9].Copy(); + Character character11 = list[10].Copy(); + Character character12 = list[11].Copy(); + + List characters = [ + character1, character2, character3, character4, + character5, character6, character7, character8, + character9, character10, character11, character12 + ]; + + int clevel = 60; + int slevel = 6; + int mlevel = 8; + + // 升级和赋能 + for (int index = 0; index < characters.Count; index++) + { + Character c = characters[index]; + c.Level = clevel; + c.NormalAttack.Level = mlevel; + + Skill 冰霜攻击 = new 冰霜攻击(c) + { + Level = mlevel + }; + c.Skills.Add(冰霜攻击); + + Skill 疾风步 = new 疾风步(c) + { + Level = slevel + }; + c.Skills.Add(疾风步); + + if (c == character1) + { + Skill META马 = new META马(c) + { + Level = 1 + }; + c.Skills.Add(META马); + + Skill 力量爆发 = new 力量爆发(c) + { + Level = mlevel + }; + c.Skills.Add(力量爆发); + } + + if (c == character2) + { + Skill 心灵之火 = new 心灵之火(c) + { + Level = 1 + }; + c.Skills.Add(心灵之火); + + Skill 天赐之力 = new 天赐之力(c) + { + Level = slevel + }; + c.Skills.Add(天赐之力); + } + + if (c == character3) + { + Skill 魔法震荡 = new 魔法震荡(c) + { + Level = 1 + }; + c.Skills.Add(魔法震荡); + + Skill 魔法涌流 = new 魔法涌流(c) + { + Level = slevel + }; + c.Skills.Add(魔法涌流); + } + + if (c == character4) + { + Skill 灵能反射 = new 灵能反射(c) + { + Level = 1 + }; + c.Skills.Add(灵能反射); + + Skill 三重叠加 = new 三重叠加(c) + { + Level = slevel + }; + c.Skills.Add(三重叠加); + } + + if (c == character5) + { + Skill 智慧与力量 = new 智慧与力量(c) + { + Level = 1 + }; + c.Skills.Add(智慧与力量); + + Skill 变幻之心 = new 变幻之心(c) + { + Level = slevel + }; + c.Skills.Add(变幻之心); + } + + if (c == character6) + { + Skill 致命打击 = new 致命打击(c) + { + Level = 1 + }; + c.Skills.Add(致命打击); + + Skill 精准打击 = new 精准打击(c) + { + Level = slevel + }; + c.Skills.Add(精准打击); + } + + if (c == character7) + { + Skill 毁灭之势 = new 毁灭之势(c) + { + Level = 1 + }; + c.Skills.Add(毁灭之势); + + Skill 绝对领域 = new 绝对领域(c) + { + Level = slevel + }; + c.Skills.Add(绝对领域); + } + + if (c == character8) + { + Skill 枯竭打击 = new 枯竭打击(c) + { + Level = 1 + }; + c.Skills.Add(枯竭打击); + + Skill 能量毁灭 = new 能量毁灭(c) + { + Level = slevel + }; + c.Skills.Add(能量毁灭); + } + + if (c == character9) + { + Skill 玻璃大炮 = new 玻璃大炮(c) + { + Level = 1 + }; + c.Skills.Add(玻璃大炮); + + Skill 迅捷之势 = new 迅捷之势(c) + { + Level = slevel + }; + c.Skills.Add(迅捷之势); + } + + if (c == character10) + { + Skill 累积之压 = new 累积之压(c) + { + Level = 1 + }; + c.Skills.Add(累积之压); + + Skill 嗜血本能 = new 嗜血本能(c) + { + Level = slevel + }; + c.Skills.Add(嗜血本能); + } + + if (c == character11) + { + Skill 敏捷之刃 = new 敏捷之刃(c) + { + Level = 1 + }; + c.Skills.Add(敏捷之刃); + + Skill 平衡强化 = new 平衡强化(c) + { + Level = slevel + }; + c.Skills.Add(平衡强化); + } + + if (c == character12) + { + Skill 弱者猎手 = new 弱者猎手(c) + { + Level = 1 + }; + c.Skills.Add(弱者猎手); + + Skill 血之狂欢 = new 血之狂欢(c) + { + Level = slevel + }; + c.Skills.Add(血之狂欢); + } + } + + // 显示角色信息 + if (PrintOut) characters.ForEach(c => Console.WriteLine(c.GetInfo())); + + // 创建顺序表并排序 + ActionQueue actionQueue = new(characters, WriteLine); + if (PrintOut) Console.WriteLine(); + + // 显示初始顺序表 + actionQueue.DisplayQueue(); + if (PrintOut) Console.WriteLine(); + + // 总游戏时长 + double totalTime = 0; + + // 开始空投 + Msg = ""; + 空投(actionQueue, totalTime); + if (isWeb) result.Add("=== 空投 ===\r\n" + Msg); + + // 总回合数 + int i = 1; + while (i < 999) + { + Msg = ""; + if (i == 998) + { + WriteLine($"=== 终局审判 ==="); + Dictionary 他们的血量百分比 = []; + foreach (Character c in characters) + { + 他们的血量百分比.TryAdd(c, Calculation.Round4Digits(c.HP / c.MaxHP)); + } + double max = 他们的血量百分比.Values.Max(); + Character winner = 他们的血量百分比.Keys.Where(c => 他们的血量百分比[c] == max).First(); + WriteLine("[ " + winner + " ] 成为了天选之人!!"); + foreach (Character c in characters.Where(c => c != winner && c.HP > 0)) + { + WriteLine("[ " + winner + " ] 对 [ " + c + " ] 造成了 99999999999 点真实伤害。"); + actionQueue.DeathCalculation(winner, c); + } + actionQueue.EndGameInfo(winner); + result.Add(Msg); + break; + } + + // 检查是否有角色可以行动 + Character? characterToAct = actionQueue.NextCharacter(); + + // 处理回合 + if (characterToAct != null) + { + WriteLine($"=== Round {i++} ==="); + WriteLine("现在是 [ " + characterToAct + " ] 的回合!"); + + bool isGameEnd = actionQueue.ProcessTurn(characterToAct); + if (isGameEnd) + { + result.Add(Msg); + break; + } + + actionQueue.DisplayQueue(); + WriteLine(""); + } + + // 模拟时间流逝 + totalTime += actionQueue.TimeLapse(); + + if (actionQueue.Eliminated.Count > deaths) + { + deaths = actionQueue.Eliminated.Count; + if (!isWeb) + { + string roundMsg = Msg; + string[] strs = roundMsg.Split("==== 角色状态 ===="); + if (strs.Length > 0) + { + roundMsg = strs[0]; + } + result.Add(roundMsg); + } + else result.Add(Msg); + } + } + + if (PrintOut) + { + Console.WriteLine("--- End ---"); + Console.WriteLine("总游戏时长:" + Calculation.Round2Digits(totalTime)); + Console.WriteLine(""); + } + + // 赛后统计 + WriteLine("=== 伤害排行榜 ==="); + int top = isWeb ? 12 : 6; + Msg = $"=== 伤害排行榜 TOP{top} ===\r\n"; + int count = 1; + foreach (Character character in actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.TotalDamage).Select(d => d.Key)) + { + StringBuilder builder = new(); + CharacterStatistics stats = actionQueue.CharacterStatistics[character]; + builder.AppendLine($"{count}. [ {character.ToStringWithLevel()} ] ({stats.Kills} / {stats.Assists})"); + builder.AppendLine($"存活时长:{stats.LiveTime} / 存活回合数:{stats.LiveRound} / 行动回合数:{stats.ActionTurn}"); + builder.AppendLine($"总计伤害:{stats.TotalDamage} / 总计物理伤害:{stats.TotalPhysicalDamage} / 总计魔法伤害:{stats.TotalMagicDamage}"); + builder.AppendLine($"总承受伤害:{stats.TotalTakenDamage} / 总承受物理伤害:{stats.TotalTakenPhysicalDamage} / 总承受魔法伤害:{stats.TotalTakenMagicDamage}"); + builder.Append($"每秒伤害:{stats.DamagePerSecond} / 每回合伤害:{stats.DamagePerTurn}"); + if (count++ <= top) + { + WriteLine(builder.ToString()); + } + else + { + if (PrintOut) Console.WriteLine(builder.ToString()); + } + + CharacterStatistics? totalStats = CharacterStatistics.Where(kv => kv.Key.GetName() == character.GetName()).Select(kv => kv.Value).FirstOrDefault(); + if (totalStats != null) + { + // 统计此角色的所有数据 + totalStats.TotalDamage = Calculation.Round2Digits(totalStats.TotalDamage + stats.TotalDamage); + totalStats.TotalPhysicalDamage = Calculation.Round2Digits(totalStats.TotalPhysicalDamage + stats.TotalPhysicalDamage); + totalStats.TotalMagicDamage = Calculation.Round2Digits(totalStats.TotalMagicDamage + stats.TotalMagicDamage); + totalStats.TotalRealDamage = Calculation.Round2Digits(totalStats.TotalRealDamage + stats.TotalRealDamage); + totalStats.TotalTakenDamage = Calculation.Round2Digits(totalStats.TotalTakenDamage + stats.TotalTakenDamage); + totalStats.TotalTakenPhysicalDamage = Calculation.Round2Digits(totalStats.TotalTakenPhysicalDamage + stats.TotalTakenPhysicalDamage); + totalStats.TotalTakenMagicDamage = Calculation.Round2Digits(totalStats.TotalTakenMagicDamage + stats.TotalTakenMagicDamage); + totalStats.TotalTakenRealDamage = Calculation.Round2Digits(totalStats.TotalTakenRealDamage + stats.TotalTakenRealDamage); + totalStats.LiveRound += stats.LiveRound; + totalStats.ActionTurn += stats.ActionTurn; + totalStats.LiveTime = Calculation.Round2Digits(totalStats.LiveTime + stats.LiveTime); + totalStats.TotalEarnedMoney += stats.TotalEarnedMoney; + totalStats.Kills += stats.Kills; + totalStats.Deaths += stats.Deaths; + totalStats.Assists += stats.Assists; + totalStats.LastRank = stats.LastRank; + double totalRank = totalStats.AvgRank * totalStats.Plays + totalStats.LastRank; + totalStats.Plays += stats.Plays; + if (totalStats.Plays != 0) totalStats.AvgRank = Calculation.Round2Digits(totalRank / totalStats.Plays); + totalStats.Wins += stats.Wins; + totalStats.Top3s += stats.Top3s; + totalStats.Loses += stats.Loses; + if (totalStats.Plays != 0) + { + totalStats.AvgDamage = Calculation.Round2Digits(totalStats.TotalDamage / totalStats.Plays); + totalStats.AvgPhysicalDamage = Calculation.Round2Digits(totalStats.TotalPhysicalDamage / totalStats.Plays); + totalStats.AvgMagicDamage = Calculation.Round2Digits(totalStats.TotalMagicDamage / totalStats.Plays); + totalStats.AvgRealDamage = Calculation.Round2Digits(totalStats.TotalRealDamage / totalStats.Plays); + totalStats.AvgTakenDamage = Calculation.Round2Digits(totalStats.TotalTakenDamage / totalStats.Plays); + totalStats.AvgTakenPhysicalDamage = Calculation.Round2Digits(totalStats.TotalTakenPhysicalDamage / totalStats.Plays); + totalStats.AvgTakenMagicDamage = Calculation.Round2Digits(totalStats.TotalTakenMagicDamage / totalStats.Plays); + totalStats.AvgTakenRealDamage = Calculation.Round2Digits(totalStats.TotalTakenRealDamage / totalStats.Plays); + totalStats.AvgLiveRound = totalStats.LiveRound / totalStats.Plays; + totalStats.AvgActionTurn = totalStats.ActionTurn / totalStats.Plays; + totalStats.AvgLiveTime = Calculation.Round2Digits(totalStats.LiveTime / totalStats.Plays); + totalStats.AvgEarnedMoney = totalStats.TotalEarnedMoney / totalStats.Plays; + totalStats.Winrates = Calculation.Round4Digits(Convert.ToDouble(totalStats.Wins) / Convert.ToDouble(totalStats.Plays)); + totalStats.Top3rates = Calculation.Round4Digits(Convert.ToDouble(totalStats.Top3s) / Convert.ToDouble(totalStats.Plays)); + } + if (totalStats.LiveRound != 0) totalStats.DamagePerRound = Calculation.Round2Digits(totalStats.TotalDamage / totalStats.LiveRound); + if (totalStats.ActionTurn != 0) totalStats.DamagePerTurn = Calculation.Round2Digits(totalStats.TotalDamage / totalStats.ActionTurn); + if (totalStats.LiveTime != 0) totalStats.DamagePerSecond = Calculation.Round2Digits(totalStats.TotalDamage / totalStats.LiveTime); + } + } + result.Add(Msg); + + // 显示每个角色的信息 + if (isWeb) + { + for (i = actionQueue.Eliminated.Count - 1; i >= 0; i--) + { + Character character = actionQueue.Eliminated[i]; + result.Add($"=== 角色 [ {character} ] ===\r\n{character.GetInfo()}"); + } + } + + lock (StatsConfig) + { + foreach (Character c in CharacterStatistics.Keys) + { + StatsConfig.Add(c.ToStringWithOutUser(), CharacterStatistics[c]); + } + StatsConfig.SaveConfig(); + } + + IsRuning = false; + } + + return result; + } + catch (Exception ex) + { + IsRuning = false; + Console.WriteLine(ex); + return [ex.ToString()]; + } + } + + public static void WriteLine(string str) + { + Msg += str + "\r\n"; + if (PrintOut) Console.WriteLine(str); + } + + public static void 空投(ActionQueue queue, double totalTime) + { + Item[] 这次发放的空投; + if (totalTime == 0) + { + WriteLine("社区送温暖了,现在向所有人发放 [ 攻击之爪 +50 ]!!"); + foreach (Character character in queue.Queue) + { + 这次发放的空投 = [new 攻击之爪50()]; + foreach (Item item in 这次发放的空投) + { + queue.Equip(character, EquipItemToSlot.Accessory1, item); + } + } + } + } + + public static void InitCharacter() + { + Characters.Add(new OshimaShiya()); + Characters.Add(new XinYin()); + Characters.Add(new Yang()); + Characters.Add(new NanGanYu()); + Characters.Add(new NiuNan()); + Characters.Add(new DokyoMayor()); + Characters.Add(new MagicalGirl()); + Characters.Add(new QingXiang()); + Characters.Add(new QWQAQW()); + Characters.Add(new ColdBlue()); + Characters.Add(new dddovo()); + Characters.Add(new Quduoduo()); + + foreach (Character c in Characters) + { + CharacterStatistics.Add(c, new()); + } + + StatsConfig.LoadConfig(); + foreach (Character character in CharacterStatistics.Keys) + { + if (StatsConfig.ContainsKey(character.ToStringWithOutUser())) + { + CharacterStatistics[character] = StatsConfig.Get(character.ToStringWithOutUser()) ?? CharacterStatistics[character]; + } + } + } + } +} diff --git a/OshimaCore/Utils/UserDailyUtil.cs b/OshimaCore/Utils/UserDailyUtil.cs new file mode 100644 index 0000000..4ae3487 --- /dev/null +++ b/OshimaCore/Utils/UserDailyUtil.cs @@ -0,0 +1,67 @@ +using Milimoe.FunGame.Core.Api.Utility; +using Oshima.Core.Configs; +using Oshima.Core.Constant; +using Oshima.Core.Models; + +namespace Oshima.Core.Utils +{ + public class UserDailyUtil + { + public static UserDaily GetUserDaily(long user_id) + { + if (Daily.UserDailys.TryGetValue(user_id, out string? value) && value != null && value.Trim() != "") + { + string daily = "你已看过你的今日运势:\r\n" + value; + return new UserDaily(user_id, 0, daily); + } + else + { + if (Daily.GreatFortune.Count == 0 && Daily.ModerateFortune.Count == 0 && Daily.GoodFortune.Count == 0 && + Daily.MinorFortune.Count == 0 && Daily.Misfortune.Count == 0 && Daily.GreatMisfortune.Count == 0) + { + return new UserDaily(0, 0, "今日运势列表为空,请联系管理员设定。"); + } + + // 抽个运势 + DailyType type = Daily.DailyTypes[Random.Shared.Next(Daily.DailyTypes.Count)]; + string text = type switch + { + DailyType.GreatFortune => Daily.GreatFortune[Random.Shared.Next(Daily.GreatFortune.Count)], + DailyType.ModerateFortune => Daily.ModerateFortune[Random.Shared.Next(Daily.ModerateFortune.Count)], + DailyType.GoodFortune => Daily.GoodFortune[Random.Shared.Next(Daily.GoodFortune.Count)], + DailyType.MinorFortune => Daily.MinorFortune[Random.Shared.Next(Daily.MinorFortune.Count)], + DailyType.Misfortune => Daily.Misfortune[Random.Shared.Next(Daily.Misfortune.Count)], + DailyType.GreatMisfortune => Daily.GreatMisfortune[Random.Shared.Next(Daily.GreatMisfortune.Count)], + _ => "", + }; + if (text != "") + { + Daily.UserDailys.Add(user_id, text); + string daily = "你的今日运势是:\r\n" + text; + Daily.SaveDaily(); + return new UserDaily(user_id, (int)type, daily); + } + return new UserDaily(0, 0, "今日运势列表为空,请联系管理员设定。"); + } + } + + public static UserDaily ViewUserDaily(long user_id) + { + if (Daily.UserDailys.TryGetValue(user_id, out string? value) && value != null && value.Trim() != "") + { + return new UserDaily(user_id, 0, "TA今天的运势是:\r\n" + value); + } + else + { + return new UserDaily(0, 0, "TA还没有抽取今日运势哦,快去提醒TA发送【我的运势】抽取运势吧!"); + } + } + + public static string RemoveDaily(long user_id) + { + Daily.UserDailys.Remove(user_id); + Daily.SaveDaily(); + return NetworkUtility.JsonSerialize("你的今日运势已重置。"); + } + } +} diff --git a/OshimaGameModule.sln b/OshimaGameModule.sln index f4103b8..d1951a2 100644 --- a/OshimaGameModule.sln +++ b/OshimaGameModule.sln @@ -7,9 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OshimaModules", "OshimaModu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OshimaMaps", "OshimaMaps\OshimaMaps.csproj", "{27847422-7671-4DF8-95EC-975A2E2F5631}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OshimaModes", "OshimaModes\OshimaModes.csproj", "{74922E11-458E-4A91-8D11-BEC9F7758EEB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OshimaModes", "OshimaModes\OshimaModes.csproj", "{74922E11-458E-4A91-8D11-BEC9F7758EEB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OshimaServers", "OshimaServers\OshimaServers.csproj", "{E8C696E0-96E4-45C3-8CB4-A02145179590}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OshimaServers", "OshimaServers\OshimaServers.csproj", "{E8C696E0-96E4-45C3-8CB4-A02145179590}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OshimaCore", "OshimaCore\OshimaCore.csproj", "{978B06DE-2AD8-4DC4-B53A-D744781FDEA1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {E8C696E0-96E4-45C3-8CB4-A02145179590}.Debug|Any CPU.Build.0 = Debug|Any CPU {E8C696E0-96E4-45C3-8CB4-A02145179590}.Release|Any CPU.ActiveCfg = Release|Any CPU {E8C696E0-96E4-45C3-8CB4-A02145179590}.Release|Any CPU.Build.0 = Release|Any CPU + {978B06DE-2AD8-4DC4-B53A-D744781FDEA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {978B06DE-2AD8-4DC4-B53A-D744781FDEA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {978B06DE-2AD8-4DC4-B53A-D744781FDEA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {978B06DE-2AD8-4DC4-B53A-D744781FDEA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OshimaModules/Modules/Constant.cs b/OshimaModules/Modules/Constant.cs index 589203d..b98cf32 100644 --- a/OshimaModules/Modules/Constant.cs +++ b/OshimaModules/Modules/Constant.cs @@ -5,6 +5,7 @@ namespace Oshima.FunGame.OshimaModules public class OshimaGameModuleConstant { public const string General = "oshima-studios"; + public const string WebAPI = "oshima.fungame.webapi"; public const string FastAuto = "oshima.fungame.fastauto"; public const string Character = "oshima.fungame.characters"; public const string Skill = "oshima.fungame.skills";