From d3d49079557d5e14357d4aa5f0d3acb3b69451c5 Mon Sep 17 00:00:00 2001 From: milimoe Date: Fri, 15 Nov 2024 20:13:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Service=EF=BC=8C=E5=92=8C?= =?UTF-8?q?=E5=B1=80=E5=86=85=E6=A8=A1=E6=8B=9F=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OshimaCore/Controllers/FunGameController.cs | 197 ++++---- OshimaCore/OshimaCore.csproj | 2 +- OshimaCore/OshimaWebAPI.cs | 1 + OshimaCore/Utils/FunGameService.cs | 475 ++++++++++++++++++ .../{FunGameUtil.cs => FunGameSimulation.cs} | 431 +--------------- OshimaMaps/OshimaMaps.csproj | 2 +- OshimaModes/OshimaModes.csproj | 2 +- OshimaModules/OshimaModules.csproj | 2 +- OshimaServers/OshimaServers.csproj | 2 +- 9 files changed, 596 insertions(+), 518 deletions(-) create mode 100644 OshimaCore/Utils/FunGameService.cs rename OshimaCore/Utils/{FunGameUtil.cs => FunGameSimulation.cs} (72%) diff --git a/OshimaCore/Controllers/FunGameController.cs b/OshimaCore/Controllers/FunGameController.cs index 2b6663c..05f7642 100644 --- a/OshimaCore/Controllers/FunGameController.cs +++ b/OshimaCore/Controllers/FunGameController.cs @@ -29,9 +29,9 @@ namespace Oshima.Core.Controllers [HttpGet("stats")] public string GetStats([FromQuery] int? id = null) { - if (id != null && id > 0 && id <= FunGameSimulation.Characters.Count) + if (id != null && id > 0 && id <= FunGameService.Characters.Count) { - Character character = FunGameSimulation.Characters[Convert.ToInt32(id) - 1]; + Character character = FunGameService.Characters[Convert.ToInt32(id) - 1]; if (FunGameSimulation.CharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) { StringBuilder builder = new(); @@ -83,9 +83,9 @@ namespace Oshima.Core.Controllers [HttpGet("teamstats")] public string GetTeamStats([FromQuery] int? id = null) { - if (id != null && id > 0 && id <= FunGameSimulation.Characters.Count) + if (id != null && id > 0 && id <= FunGameService.Characters.Count) { - Character character = FunGameSimulation.Characters[Convert.ToInt32(id) - 1]; + Character character = FunGameService.Characters[Convert.ToInt32(id) - 1]; if (FunGameSimulation.TeamCharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) { StringBuilder builder = new(); @@ -220,9 +220,9 @@ namespace Oshima.Core.Controllers [HttpGet("cjs")] public string GetCharacterIntroduce([FromQuery] int? id = null) { - if (id != null && id > 0 && id <= FunGameSimulation.Characters.Count) + if (id != null && id > 0 && id <= FunGameService.Characters.Count) { - Character c = FunGameSimulation.Characters[Convert.ToInt32(id) - 1].Copy(); + Character c = FunGameService.Characters[Convert.ToInt32(id) - 1].Copy(); c.Level = General.GameplayEquilibriumConstant.MaxLevel; c.NormalAttack.Level = General.GameplayEquilibriumConstant.MaxNormalAttackLevel; @@ -414,11 +414,11 @@ namespace Oshima.Core.Controllers [HttpGet("cjn")] public string GetSkillInfo([FromQuery] long? id = null) { - IEnumerable skills = FunGameSimulation.Skills.Union(FunGameSimulation.Magics); - if (id != null && FunGameSimulation.Characters.Count > 1) + IEnumerable skills = FunGameService.Skills.Union(FunGameService.Magics); + if (id != null && FunGameService.Characters.Count > 1) { List msg = []; - Character c = FunGameSimulation.Characters[1].Copy(); + Character c = FunGameService.Characters[1].Copy(); Skill? s = skills.Where(s => s.Id == id).FirstOrDefault()?.Copy(); if (s != null) { @@ -440,7 +440,7 @@ namespace Oshima.Core.Controllers [HttpGet("cwp")] public string GetItemInfo([FromQuery] long? id = null) { - IEnumerable items = FunGameSimulation.Equipment; + IEnumerable items = FunGameService.Equipment; if (id != null) { List msg = []; @@ -459,14 +459,14 @@ namespace Oshima.Core.Controllers [HttpGet("mfk")] public string GenerateMagicCard() { - Item i = FunGameSimulation.GenerateMagicCard(); + Item i = FunGameService.GenerateMagicCard(); return NetworkUtility.JsonSerialize(i.ToString(false, true)); } [HttpGet("mfkb")] public string GenerateMagicCardPack() { - Item? i = FunGameSimulation.GenerateMagicCardPack(3); + Item? i = FunGameService.GenerateMagicCardPack(3); if (i != null) { return NetworkUtility.JsonSerialize(i.ToString(false, true)); @@ -479,42 +479,41 @@ namespace Oshima.Core.Controllers { long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); string username = name ?? "Unknown"; - string filepath = $@"{AppDomain.CurrentDomain.BaseDirectory}configs/saved/{userid}.json"; - if (System.IO.File.Exists(filepath)) + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + if (pc.Count == 0) + { + User user = Factory.GetUser(userid, username, DateTime.Now, DateTime.Now, userid + "@qq.com", username); + user.Inventory.Credits = 100; + pc.Add("user", user); + pc.SaveConfig(); + return NetworkUtility.JsonSerialize($"创建存档成功!你的用户名是【{username}】。"); + } + else { return NetworkUtility.JsonSerialize("你已经创建过存档!"); } - User user = Factory.GetUser(userid, username, DateTime.Now, DateTime.Now, userid + "@qq.com", username); - user.Inventory.Credits = 100; - PluginConfig pc = new("saved", userid.ToString()); - pc.LoadConfig(); - pc.Add("user", user); - pc.SaveConfig(); - return NetworkUtility.JsonSerialize($"创建存档成功!你的用户名是【{username}】。"); } [HttpPost("ckkc")] public string GetInventoryInfo([FromQuery] long? qq = null) { long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); - string filepath = $@"{AppDomain.CurrentDomain.BaseDirectory}configs/saved/{userid}.json"; - if (!System.IO.File.Exists(filepath)) - { - return NetworkUtility.JsonSerialize("你还没有创建存档!请发送【创建存档】创建。"); - } PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); if (pc.Count > 0) { - User user = FunGameSimulation.GetUser(pc); + User user = FunGameService.GetUser(pc); return NetworkUtility.JsonSerialize(user.Inventory.ToString(false)); } else { - return NetworkUtility.JsonSerialize($"你好像一无所有……"); + return NetworkUtility.JsonSerialize("你还没有创建存档!请发送【创建存档】创建。"); } } @@ -522,82 +521,93 @@ namespace Oshima.Core.Controllers public string DrawCards([FromQuery] long? qq = null) { long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); - string filepath = $@"{AppDomain.CurrentDomain.BaseDirectory}configs/saved/{userid}.json"; - if (!System.IO.File.Exists(filepath)) - { - return NetworkUtility.JsonSerialize("你还没有创建存档!请发送【创建存档】创建。"); - } PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); - User user = FunGameSimulation.GetUser(pc); - double dice = Random.Shared.NextDouble(); - if (dice > 0.8) + if (pc.Count > 0) { - string msg = "恭喜你抽到了:【"; - int r = Random.Shared.Next(7); - switch (r) + User user = FunGameService.GetUser(pc); + + double dice = Random.Shared.NextDouble(); + if (dice > 0.8) { - case 1: - Item[] 武器 = FunGameSimulation.Equipment.Where(i => i.Id.ToString().StartsWith("11")).ToArray(); - Item a = 武器[Random.Shared.Next(武器.Length)].Copy(); - user.Inventory.Items.Add(a); - msg += a.Name; - break; + string msg = "恭喜你抽到了:"; + int r = Random.Shared.Next(7); + switch (r) + { + case 1: + Item[] 武器 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("11")).ToArray(); + Item a = 武器[Random.Shared.Next(武器.Length)].Copy(); + user.Inventory.Items.Add(a); + msg += ItemSet.GetQualityTypeName(a.QualityType) + ItemSet.GetItemTypeName(a.ItemType) + "【" + a.Name + "】!"; + break; - case 2: - Item[] 防具 = FunGameSimulation.Equipment.Where(i => i.Id.ToString().StartsWith("12")).ToArray(); - Item b = 防具[Random.Shared.Next(防具.Length)].Copy(); - user.Inventory.Items.Add(b); - msg += b.Name; - break; - - case 3: - Item[] 鞋子 = FunGameSimulation.Equipment.Where(i => i.Id.ToString().StartsWith("13")).ToArray(); - Item c = 鞋子[Random.Shared.Next(鞋子.Length)].Copy(); - user.Inventory.Items.Add(c); - msg += c.Name; - break; - - case 4: - Item[] 饰品 = FunGameSimulation.Equipment.Where(i => i.Id.ToString().StartsWith("14")).ToArray(); - Item d = 饰品[Random.Shared.Next(饰品.Length)].Copy(); - user.Inventory.Items.Add(d); - msg += d.Name; - break; - - case 5: - Character character = FunGameSimulation.Characters[Random.Shared.Next(FunGameSimulation.Characters.Count)].Copy(); - user.Inventory.Characters.Add(character); - msg += character.ToStringWithOutUser(); - break; - - case 6: - Item mfk = FunGameSimulation.GenerateMagicCard(); - user.Inventory.Items.Add(mfk); - msg += mfk.Name; - break; + case 2: + Item[] 防具 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("12")).ToArray(); + Item b = 防具[Random.Shared.Next(防具.Length)].Copy(); + user.Inventory.Items.Add(b); + msg += ItemSet.GetQualityTypeName(b.QualityType) + ItemSet.GetItemTypeName(b.ItemType) + "【" + b.Name + "】!"; + break; - case 0: - default: - Item? mfkb = FunGameSimulation.GenerateMagicCardPack(3); - if (mfkb != null) - { - mfkb.IsTradable = false; - mfkb.NextTradableTime = DateTimeUtility.GetTradableTime(); - user.Inventory.Items.Add(mfkb); - msg += mfkb.Name; - } - break; + case 3: + Item[] 鞋子 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("13")).ToArray(); + Item c = 鞋子[Random.Shared.Next(鞋子.Length)].Copy(); + user.Inventory.Items.Add(c); + msg += ItemSet.GetQualityTypeName(c.QualityType) + ItemSet.GetItemTypeName(c.ItemType) + "【" + c.Name + "】!"; + break; + + case 4: + Item[] 饰品 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("14")).ToArray(); + Item d = 饰品[Random.Shared.Next(饰品.Length)].Copy(); + user.Inventory.Items.Add(d); + msg += ItemSet.GetQualityTypeName(d.QualityType) + ItemSet.GetItemTypeName(d.ItemType) + "【" + d.Name + "】!"; + break; + + case 5: + Character character = FunGameService.Characters[Random.Shared.Next(FunGameService.Characters.Count)].Copy(); + if (user.Inventory.Characters.Any(c => c.Id == character.Id)) + { + user.Inventory.Materials += 50; + msg += "【" + character.ToStringWithOutUser() + "】!但是你已经拥有此角色,转换为【50】" + General.GameplayEquilibriumConstant.InGameMaterial + "!"; + } + else + { + user.Inventory.Characters.Add(character); + msg += "【" + character.ToStringWithOutUser() + "】!"; + } + break; + + case 6: + Item mfk = FunGameService.GenerateMagicCard(); + user.Inventory.Items.Add(mfk); + msg += ItemSet.GetQualityTypeName(mfk.QualityType) + ItemSet.GetItemTypeName(mfk.ItemType) + "【" + mfk.Name + "】!"; + break; + + case 0: + default: + Item? mfkb = FunGameService.GenerateMagicCardPack(3); + if (mfkb != null) + { + mfkb.IsTradable = false; + mfkb.NextTradableTime = DateTimeUtility.GetTradableTime(); + user.Inventory.Items.Add(mfkb); + msg += ItemSet.GetQualityTypeName(mfkb.QualityType) + ItemSet.GetItemTypeName(mfkb.ItemType) + "【" + mfkb.Name + "】!"; + } + break; + } + pc.Add("user", user); + pc.SaveConfig(); + return NetworkUtility.JsonSerialize(msg); + } + else + { + return NetworkUtility.JsonSerialize("你什么也没抽中……"); } - pc.Add("user", user); - pc.SaveConfig(); - return NetworkUtility.JsonSerialize(msg + "】!"); } else { - return NetworkUtility.JsonSerialize("你什么也没抽中……"); + return NetworkUtility.JsonSerialize("你还没有创建存档!请发送【创建存档】创建。"); } } @@ -606,7 +616,8 @@ namespace Oshima.Core.Controllers { if (master != null && master == GeneralSettings.Master) { - FunGameSimulation.Reload(); + FunGameService.Reload(); + FunGameSimulation.InitFunGame(); return NetworkUtility.JsonSerialize("FunGame已重新加载。"); } return NetworkUtility.JsonSerialize("提供的参数不正确。"); diff --git a/OshimaCore/OshimaCore.csproj b/OshimaCore/OshimaCore.csproj index a4aa4f6..6e1ff8c 100644 --- a/OshimaCore/OshimaCore.csproj +++ b/OshimaCore/OshimaCore.csproj @@ -27,7 +27,7 @@ - ..\..\FunGame.Core\bin\Release\net9.0\FunGame.Core.dll + ..\..\FunGame.Core\bin\Debug\net9.0\FunGame.Core.dll diff --git a/OshimaCore/OshimaWebAPI.cs b/OshimaCore/OshimaWebAPI.cs index 8a7d2ef..12e1f3a 100644 --- a/OshimaCore/OshimaWebAPI.cs +++ b/OshimaCore/OshimaWebAPI.cs @@ -42,6 +42,7 @@ namespace Oshima.Core.WebAPI Daily.InitDaily(); SayNo.InitSayNo(); Ignore.InitIgnore(); + FunGameService.InitFunGame(); FunGameSimulation.InitFunGame(); Task taskTime = Task.Factory.StartNew(async () => { diff --git a/OshimaCore/Utils/FunGameService.cs b/OshimaCore/Utils/FunGameService.cs new file mode 100644 index 0000000..4341bf3 --- /dev/null +++ b/OshimaCore/Utils/FunGameService.cs @@ -0,0 +1,475 @@ +锘縰sing System.Text; +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Library.Constant; +using Oshima.FunGame.OshimaModules; +using Oshima.FunGame.OshimaModules.Characters; +using Oshima.FunGame.OshimaModules.Effects.OpenEffects; +using Oshima.FunGame.OshimaModules.Items; +using Oshima.FunGame.OshimaModules.Skills; + +namespace Oshima.Core.Utils +{ + public class FunGameService + { + public static List Characters { get; } = []; + public static List Skills { get; } = []; + public static List Magics { get; } = []; + public static List Equipment { get; } = []; + public static List Items { get; } = []; + + public static void InitFunGame() + { + 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()); + + Dictionary exItems = Factory.GetGameModuleInstances(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Item); + Equipment.AddRange(exItems.Values.Where(i => (int)i.ItemType >= 0 && (int)i.ItemType < 5)); + Equipment.AddRange([new 鏀诲嚮涔嬬埅10(), new 鏀诲嚮涔嬬埅30(), new 鏀诲嚮涔嬬埅50()]); + + Items.AddRange(exItems.Values.Where(i => (int)i.ItemType > 4)); + + Skills.AddRange([new 鐤鹃姝()]); + + Magics.AddRange([new 鍐伴湝鏀诲嚮(), new 鐏箣鐭(), new 姘翠箣鐭(), new 椋庝箣杞(), new 鐭充箣閿(), new 蹇冪伒涔嬮湠(), new 娆″厓涓婂崌(), new 鏆楃墿璐(), new 鍥炲鏈(), new 娌绘剤鏈()]); + } + + public static List GenerateMagicCards(int count, QualityType? qualityType = null) + { + List items = []; + + for (int i = 0; i < count; i++) + { + items.Add(GenerateMagicCard(qualityType)); + } + + return items; + } + + public static Item GenerateMagicCard(QualityType? qualityType = null) + { + Item item = Factory.GetItem(); + item.Id = Convert.ToInt64("16" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 8)); + item.Name = GenerateRandomChineseName(); + item.ItemType = ItemType.MagicCard; + + int total; + if (qualityType != null) + { + total = qualityType switch + { + QualityType.Green => Random.Shared.Next(7, 13), + QualityType.Blue => Random.Shared.Next(13, 19), + QualityType.Purple => Random.Shared.Next(19, 25), + QualityType.Orange => Random.Shared.Next(25, 31), + _ => Random.Shared.Next(1, 7) + }; + item.QualityType = (QualityType)qualityType; + } + else + { + total = Random.Shared.Next(1, 31); + if (total > 6 && total <= 12) + { + item.QualityType = QualityType.Green; + } + else if (total > 12 && total <= 18) + { + item.QualityType = QualityType.Blue; + } + else if (total > 18 && total <= 24) + { + item.QualityType = QualityType.Purple; + } + else if (total > 24 && total <= 30) + { + item.QualityType = QualityType.Orange; + } + } + + GenerateAndAddSkillToMagicCard(item, total); + + return item; + } + + public static void GenerateAndAddSkillToMagicCard(Item item, int total) + { + Skill magic = Magics[Random.Shared.Next(Magics.Count)].Copy(); + magic.Guid = item.Guid; + magic.Level = (int)item.QualityType switch + { + 2 => 2, + 4 => 3, + 6 => 4, + _ => 1 + }; + item.Skills.Active = magic; + + // 鍒濆鍖栧睘鎬у + int str = 0, agi = 0, intelligence = 0; + + // 闅忔満鍐冲畾灏嗗灏戜釜灞炴ц祴缁欏叾涓竴涓睘鎬э紝纭繚鑷冲皯涓涓笉涓洪浂 + int nonZeroAttributes = Random.Shared.Next(1, Math.Min(4, total + 1)); // 闅忔満鍐冲畾闈為浂灞炴х殑鏁伴噺锛岀‘淇濆湪 total = 1 鏃舵渶澶氬彧鏈1涓潪闆跺睘鎬 + + // 鏍规嵁闈為浂灞炴ф暟閲忓垎閰嶅睘鎬х偣 + if (nonZeroAttributes == 1) + { + // 鍙湁涓涓睘鎬т笉涓洪浂 + int attribute = Random.Shared.Next(0, 3); + if (attribute == 0) str = total; + else if (attribute == 1) agi = total; + else intelligence = total; + } + else if (nonZeroAttributes == 2 && total >= 2) + { + // 涓や釜灞炴т笉涓洪浂 + int first = Random.Shared.Next(1, total); // 绗竴涓睘鎬х殑鍊 + int second = total - first; // 绗簩涓睘鎬х殑鍊 + + int attribute = Random.Shared.Next(0, 3); + if (attribute == 0) + { + str = first; + } + else if (attribute == 1) + { + agi = first; + } + else + { + intelligence = first; + } + + attribute = Random.Shared.Next(0, 3); + while ((attribute == 0 && str > 0) || (attribute == 1 && agi > 0) || (attribute == 2 && intelligence > 0)) + { + attribute = Random.Shared.Next(0, 3); + } + + if (attribute == 0) + { + str = second; + } + else if (attribute == 1) + { + agi = second; + } + else + { + intelligence = second; + } + } + else if (total >= 3) + { + // 涓変釜灞炴ч兘涓嶄负闆 + str = Random.Shared.Next(1, total - 1); // 绗竴涓睘鎬х殑鍊 + agi = Random.Shared.Next(1, total - str); // 绗簩涓睘鎬х殑鍊 + intelligence = total - str - agi; // 鍓╀笅鐨勫肩粰绗笁涓睘鎬 + } + + Skill skill = Factory.OpenFactory.GetInstance(item.Id, item.Name, []); + GenerateAndAddEffectsToMagicCard(skill, str, agi, intelligence); + + if (magic.Level > 1) item.Name += $" +{magic.Level - 1}"; + skill.Level = 1; + List strings = []; + if (str > 0) strings.Add($"{str:0.##} 鐐瑰姏閲"); + if (agi > 0) strings.Add($"{agi:0.##} 鐐规晱鎹"); + if (intelligence > 0) strings.Add($"{intelligence:0.##} 鐐规櫤鍔"); + item.Description = $"鍖呭惈榄旀硶锛歿item.Skills.Active.Name}\r\n" + + $"澧炲姞瑙掕壊灞炴э細{string.Join("锛", strings)}"; + item.Skills.Passives.Add(skill); + } + + public static void GenerateAndAddEffectsToMagicCard(Skill skill, int str, int agi, int intelligence) + { + if (str > 0) + { + skill.Effects.Add(Factory.OpenFactory.GetInstance((long)EffectID.ExSTR, "", new() + { + { "skill", skill }, + { + "values", new Dictionary() + { + { "exstr", str } + } + } + })); + } + + if (agi > 0) + { + skill.Effects.Add(Factory.OpenFactory.GetInstance((long)EffectID.ExAGI, "", new() + { + { "skill", skill }, + { + "values", new Dictionary() + { + { "exagi", agi } + } + } + })); + } + + if (intelligence > 0) + { + skill.Effects.Add(Factory.OpenFactory.GetInstance((long)EffectID.ExINT, "", new() + { + { "skill", skill }, + { + "values", new Dictionary() + { + { "exint", intelligence } + } + } + })); + } + } + + public static Item? ConflateMagicCardPack(IEnumerable magicCards) + { + if (magicCards.Any()) + { + List magics = [.. magicCards.Where(i => i.Skills.Active != null).Select(i => i.Skills.Active)]; + List passives = [.. magicCards.SelectMany(i => i.Skills.Passives)]; + Item item = Factory.GetItem(); + item.Id = Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 8)); + item.Name = GenerateRandomChineseName(); + item.ItemType = ItemType.MagicCardPack; + double str = 0, agi = 0, intelligence = 0; + foreach (Skill skill in passives) + { + Skill newSkill = skill.Copy(); + foreach (Effect effect in newSkill.Effects) + { + switch ((EffectID)effect.Id) + { + case EffectID.ExSTR: + if (effect is ExSTR exstr) + { + str += exstr.Value; + } + break; + case EffectID.ExAGI: + if (effect is ExAGI exagi) + { + agi += exagi.Value; + } + break; + case EffectID.ExINT: + if (effect is ExINT exint) + { + intelligence += exint.Value; + } + break; + } + } + newSkill.Level = skill.Level; + item.Skills.Passives.Add(newSkill); + } + List strings = []; + if (str > 0) strings.Add($"{str:0.##} 鐐瑰姏閲"); + if (agi > 0) strings.Add($"{agi:0.##} 鐐规晱鎹"); + if (intelligence > 0) strings.Add($"{intelligence:0.##} 鐐规櫤鍔"); + foreach (Skill skill in magics) + { + IEnumerable has = item.Skills.Magics.Where(m => m.Id == skill.Id); + if (has.Any() && has.First() is Skill s) + { + s.Level += skill.Level; + if (s.Level > 1) s.Name = s.Name.Split(' ')[0] + $" +{s.Level - 1}"; + } + else + { + Skill magic = skill.Copy(); + magic.Guid = item.Guid; + magic.Level = skill.Level; + item.Skills.Magics.Add(magic); + } + } + item.Description = $"鍖呭惈榄旀硶锛歿string.Join("锛", item.Skills.Magics.Select(m => m.Name + (m.Level > 1 ? $" +{m.Level - 1}" : "")))}\r\n" + + $"澧炲姞瑙掕壊灞炴э細{string.Join("锛", strings)}"; + double total = str + agi + intelligence; + if (total > 18 && total <= 36) + { + item.QualityType = QualityType.Green; + } + else if (total > 36 && total <= 54) + { + item.QualityType = QualityType.Blue; + } + else if (total > 54 && total <= 72) + { + item.QualityType = QualityType.Purple; + } + else if (total > 72 && total <= 90) + { + item.QualityType = QualityType.Orange; + } + return item; + } + return null; + } + + public static Item? GenerateMagicCardPack(int magicCardCount, QualityType? qualityType = null) + { + List magicCards = GenerateMagicCards(magicCardCount, qualityType); + Item? magicCardPack = ConflateMagicCardPack(magicCards); + return magicCardPack; + } + + public static void Reload() + { + Characters.Clear(); + Equipment.Clear(); + Skills.Clear(); + Magics.Clear(); + + InitFunGame(); + } + + public static string GenerateRandomChineseName() + { + // 瀹氫箟涓涓寘鍚父鐢ㄦ眽瀛楃殑瀛楃涓 + string commonChineseCharacters = "浜戞槦瀹濈伒姊﹂緳鑺遍洦椋庡彾灞卞窛鏈堢煶缇芥按绔归噾" + + "鐜夋捣鐏浄鍏夊ぉ鍦板嚖铏庤櫣鐝犲崕闇為箯闆摱娌欐澗妗冨叞闈掗湝楦垮悍楠忔尝娉夋渤婀栨睙娉芥磱鏋楁灚" + + "姊呮妯辨鏅撮煹鍑岃嫢鎮犵ⅶ娑涙笂澹佸墤褰遍湒鐜勬壙鐝嶉泤鑰鐟為工鐑熺嚂闇忕考缈旂拑缁罕缁唬閿" + + "鐟滅惣鐟剧拠鐠х惓鐞懚鐟涜姖鏉忚寽鑽疯帀鑾硅彙鑾茶瘲鐟扮繝妞掓姒嗘Э鏌辨ⅶ鏇滄洐鏅舵殩鏅虹厡鐔欓湏" + + "鐔犲槈鐞存浖鑿佽搲鑿叉窇濡欐儬绉嬫兜鏄犲阀鎱ц尮鑽h彵鏇﹀鑺幉婢滄竻婀樻緞娉撴鼎鐝烘櫒缈犳稛娲佹偁" + + "闇忔窇缁鼎涓滃崡瑗垮寳浜戝北宸濋鏈堟邯闆洦闆峰ぉ浜戞捣闇滄煆鑺虫槬绉嬪鍐俯鏅瘨鍜岀闃虫邯" + + "婧椋庡嘲闃"; + + // 闅忔満鐢熸垚鍚嶅瓧闀垮害锛2鍒5涓瓧 + int nameLength = Random.Shared.Next(2, 6); + StringBuilder name = new(); + + for (int i = 0; i < nameLength; i++) + { + // 浠庡父鐢ㄦ眽瀛楅泦涓殢鏈洪夋嫨涓涓眽瀛 + char chineseCharacter = commonChineseCharacters[Random.Shared.Next(commonChineseCharacters.Length)]; + name.Append(chineseCharacter); + } + + return name.ToString(); + } + + public static string GenerateRandomChineseUserName() + { + string[] commonSurnames = [ + "椤", "娌", "闄", "妤", "鐧", "鑻", "鍙", "钀", "鑾", "鍙搁┈", "娆ч槼", + "涓婂畼", "鎱曞", "灏夎繜", "鍙稿緬", "杞╄緯", "绔湪", "鍗楀", "闀垮瓩", "鐧鹃噷", + "涓滄柟", "瑗块棬", "鐙", "鍏瓩", "浠ょ嫄", "瀹囨枃", "澶忎警", "璧繛", "鐨囩敨", + "鍖楀爞", "瀹夐櫟", "涓滅", "鑺卞", "澶", "鏌", "浜", "鍑", "瀵", "榫", + "鍑", "钃", "鍐", "鍗", "钃濆", "鍙跺崡", "澧", "鍚", "鏈", "瀛愯溅", + "婢瑰彴", "閽熺", "鍏緤", "闂句笜", "浠插瓩", "鍙哥┖", "缇婅垖", "浜撳畼", "鍏喍", + "婵槼", "鐙湀", "鍗楅", "鍑ゆ爾", "鍗楅棬", "濮", "闂讳汉", "鑺辨", "鑻", + "绱", "鍗", "寰", "娓", "鏄", "鏈堝崕", "闇", "鍏", "宀", "璇", "闆", + "澶滈槕", "姊", "娲", "姹", "榛", "澶滃寳", "鍞", "姘", "闊", "搴", + "澶滈洩", "澶滃噷", "鍚涗复", "闈掑啣", "婕犵劧", "鏋", "闈", "宀", "瀹", + "澧", "鏌", "瀹", "鏅", "灏", "鍗", "杞", "绔", "鏅", "妗", "鏅", + "鐟", "婧", "姹", "娌", "鐜", "姹", "褰", "缇", "棰", "杈", "鐞", + "鑺", "灏", "鏂", "鍘", "瀛", "灏", "鑽", "鍗", "绠", "妞", "鍌", + "鍙", "閽", "鏂", "璋" + ]; + + // 瀹氫箟涓涓寘鍚父鐢ㄦ眽瀛楃殑瀛楃涓 + string commonChineseCharacters = "浜戞槦瀹濈伒姊﹂緳鑺遍洦椋庡彾灞卞窛鏈堢煶缇芥按绔归噾" + + "鐜夋捣鐏浄鍏夊ぉ鍦板嚖铏庤櫣鐝犲崕闇為箯闆摱娌欐澗妗冨叞闈掗湝楦垮悍楠忔尝娉夋渤婀栨睙娉芥磱鏋楁灚" + + "姊呮妯辨鏅撮煹鍑岃嫢鎮犵ⅶ娑涙笂澹佸墤褰遍湒鐜勬壙鐝嶉泤鑰鐟為工鐑熺嚂闇忕考缈旂拑缁罕缁唬閿" + + "鐟滅惣鐟剧拠鐠х惓鐞懚鐟涜姖鏉忚寽鑽疯帀鑾硅彙鑾茶瘲鐟扮繝妞掓姒嗘Э鏌辨ⅶ鏇滄洐鏅舵殩鏅虹厡鐔欓湏" + + "鐔犲槈鐞存浖鑿佽搲鑿叉窇濡欐儬绉嬫兜鏄犲阀鎱ц尮鑽h彵鏇﹀鑺幉婢滄竻婀樻緞娉撴鼎鐝烘櫒娑熸磥涓滃崡" + + "瑗垮寳婧宄伴槼榫勪竴浜屼笁鍥涗簲鍏竷鍗"; + + StringBuilder name = new(); + + // 闅忔満濮 + string lastname = commonSurnames[Random.Shared.Next(commonSurnames.Length)]; + name.Append(lastname); + + // 闅忔満鐢熸垚鍚嶅瓧闀垮害锛2鍒5涓瓧 + int nameLength = Random.Shared.Next(1, 2); + + for (int i = 0; i < nameLength; i++) + { + // 浠庡父鐢ㄦ眽瀛楅泦涓殢鏈洪夋嫨涓涓眽瀛 + char chineseCharacter = commonChineseCharacters[Random.Shared.Next(commonChineseCharacters.Length)]; + name.Append(chineseCharacter); + } + + return name.ToString(); + } + + public static User GetUser(PluginConfig pc) + { + User user = pc.Get("user") ?? Factory.GetUser(); + + List characters = new(user.Inventory.Characters); + List items = new(user.Inventory.Items); + user.Inventory.Characters.Clear(); + user.Inventory.Items.Clear(); + + foreach (Character inventoryCharacter in characters) + { + Character realCharacter = CharacterBuilder.Build(inventoryCharacter, false); + realCharacter.User = user; + user.Inventory.Characters.Add(realCharacter); + } + + foreach (Item inventoryItem in items) + { + Item realItem = inventoryItem.Copy(true, true); + if (realItem.IsEquipment) + { + IEnumerable has = user.Inventory.Characters.Where(character => + { + if (realItem.ItemType == ItemType.MagicCardPack && character.EquipSlot.MagicCardPack != null && realItem.Guid == character.EquipSlot.MagicCardPack.Guid) + { + return true; + } + if (realItem.ItemType == ItemType.Weapon && character.EquipSlot.Weapon != null && realItem.Guid == character.EquipSlot.Weapon.Guid) + { + return true; + } + if (realItem.ItemType == ItemType.Armor && character.EquipSlot.Armor != null && realItem.Guid == character.EquipSlot.Armor.Guid) + { + return true; + } + if (realItem.ItemType == ItemType.Shoes && character.EquipSlot.Shoes != null && realItem.Guid == character.EquipSlot.Shoes.Guid) + { + return true; + } + if (realItem.ItemType == ItemType.Accessory) + { + if (character.EquipSlot.Accessory1 != null && realItem.Guid == character.EquipSlot.Accessory1.Guid) + { + return true; + } + else if (character.EquipSlot.Accessory2 != null && realItem.Guid == character.EquipSlot.Accessory2.Guid) + { + return true; + } + } + return false; + }); + if (has.Any() && has.First() is Character character) + { + realItem.Character = character; + } + } + user.Inventory.Items.Add(realItem); + } + + return user; + } + } +} diff --git a/OshimaCore/Utils/FunGameUtil.cs b/OshimaCore/Utils/FunGameSimulation.cs similarity index 72% rename from OshimaCore/Utils/FunGameUtil.cs rename to OshimaCore/Utils/FunGameSimulation.cs index 4554045..3fa14a0 100644 --- a/OshimaCore/Utils/FunGameUtil.cs +++ b/OshimaCore/Utils/FunGameSimulation.cs @@ -13,11 +13,6 @@ namespace Oshima.Core.Utils { public class FunGameSimulation { - public static List Characters { get; } = []; - public static List Skills { get; } = []; - public static List Magics { get; } = []; - public static List Equipment { get; } = []; - public static List Items { get; } = []; public static Dictionary CharacterStatistics { get; } = []; public static Dictionary TeamCharacterStatistics { get; } = []; public static PluginConfig StatsConfig { get; } = new(nameof(FunGameSimulation), nameof(CharacterStatistics)); @@ -30,20 +25,10 @@ namespace Oshima.Core.Utils public static void InitFunGame() { - 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()); + CharacterStatistics.Clear(); + TeamCharacterStatistics.Clear(); - foreach (Character c in Characters) + foreach (Character c in FunGameService.Characters) { CharacterStatistics.Add(c, new()); } @@ -57,7 +42,7 @@ namespace Oshima.Core.Utils } } - foreach (Character c in Characters) + foreach (Character c in FunGameService.Characters) { TeamCharacterStatistics.Add(c, new()); } @@ -70,16 +55,6 @@ namespace Oshima.Core.Utils TeamCharacterStatistics[character] = TeamStatsConfig.Get(character.ToStringWithOutUser()) ?? TeamCharacterStatistics[character]; } } - - Dictionary exItems = Factory.GetGameModuleInstances(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Item); - Equipment.AddRange(exItems.Values.Where(i => (int)i.ItemType >= 0 && (int)i.ItemType < 5)); - Equipment.AddRange([new 鏀诲嚮涔嬬埅10(), new 鏀诲嚮涔嬬埅30(), new 鏀诲嚮涔嬬埅50()]); - - Items.AddRange(exItems.Values.Where(i => (int)i.ItemType > 4)); - - Skills.AddRange([new 鐤鹃姝()]); - - Magics.AddRange([new 鍐伴湝鏀诲嚮(), new 鐏箣鐭(), new 姘翠箣鐭(), new 椋庝箣杞(), new 鐭充箣閿(), new 蹇冪伒涔嬮湠(), new 娆″厓涓婂崌(), new 鏆楃墿璐(), new 鍥炲鏈(), new 娌绘剤鏈()]); } public static List StartGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false) @@ -105,7 +80,7 @@ namespace Oshima.Core.Utils // M = 5, W = 0, P1 = 0, P3 = 2 // M = 5, W = 1, P1 = 0, P3 = 0 - List list = new(Characters); + List list = new(FunGameService.Characters); if (list.Count > 11) { @@ -551,7 +526,7 @@ namespace Oshima.Core.Utils roundMsg = Msg; if (!deathMatchRoundDetail) { - roundMsg = actionQueue.LastRound.ToString(); + roundMsg = actionQueue.LastRound.ToString().Trim() + $"\r\n{(isTeam ? $"姣斿垎锛歿string.Join(" / ", actionQueue.Teams.Values.Select(t => $"{t.Name}({t.Score})"))}锛屽嚮鏉鏉ヨ嚜{actionQueue.GetTeam(actionQueue.LastRound.Actor)}" : "")}\r\n"; } Msg = ""; } @@ -792,10 +767,10 @@ namespace Oshima.Core.Utils WriteLine($"绀惧尯閫佹俯鏆栦簡锛岀幇鍦ㄩ殢鏈哄彂鏀剧┖鎶曪紒锛"); foreach (Character character in queue.Queue) { - Item[] 姝﹀櫒 = Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == wQuality).ToArray(); - Item[] 闃插叿 = Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == aQuality).ToArray(); - Item[] 闉嬪瓙 = Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == sQuality).ToArray(); - Item[] 楗板搧 = Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == acQuality).ToArray(); + Item[] 姝﹀櫒 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == wQuality).ToArray(); + Item[] 闃插叿 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == aQuality).ToArray(); + Item[] 闉嬪瓙 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == sQuality).ToArray(); + Item[] 楗板搧 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == acQuality).ToArray(); Item? a = null, b = null, c = null, d = null; if (姝﹀櫒.Length > 0) { @@ -818,7 +793,7 @@ namespace Oshima.Core.Utils if (b != null) 杩欐鍙戞斁鐨勭┖鎶.Add(b); if (c != null) 杩欐鍙戞斁鐨勭┖鎶.Add(c); if (d != null) 杩欐鍙戞斁鐨勭┖鎶.Add(d); - Item? 榄旀硶鍗″寘 = GenerateMagicCardPack(3, (QualityType)mQuality); + Item? 榄旀硶鍗″寘 = FunGameService.GenerateMagicCardPack(3, (QualityType)mQuality); if (榄旀硶鍗″寘 != null) { foreach (Skill magic in 榄旀硶鍗″寘.Skills.Magics) @@ -838,302 +813,6 @@ namespace Oshima.Core.Utils WriteLine(""); } - public static List GenerateMagicCards(int count, QualityType? qualityType = null) - { - List items = []; - - for (int i = 0; i < count; i++) - { - items.Add(GenerateMagicCard(qualityType)); - } - - return items; - } - - public static Item GenerateMagicCard(QualityType? qualityType = null) - { - Item item = Factory.GetItem(); - item.Id = Convert.ToInt64("16" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 8)); - item.Name = GenerateRandomChineseName(); - item.ItemType = ItemType.MagicCard; - - int total; - if (qualityType != null) - { - total = qualityType switch - { - QualityType.Green => Random.Shared.Next(7, 13), - QualityType.Blue => Random.Shared.Next(13, 19), - QualityType.Purple => Random.Shared.Next(19, 25), - QualityType.Orange => Random.Shared.Next(25, 31), - _ => Random.Shared.Next(1, 7) - }; - item.QualityType = (QualityType)qualityType; - } - else - { - total = Random.Shared.Next(1, 31); - if (total > 6 && total <= 12) - { - item.QualityType = QualityType.Green; - } - else if (total > 12 && total <= 18) - { - item.QualityType = QualityType.Blue; - } - else if (total > 18 && total <= 24) - { - item.QualityType = QualityType.Purple; - } - else if (total > 24 && total <= 30) - { - item.QualityType = QualityType.Orange; - } - } - - GenerateAndAddSkillToMagicCard(item, total); - - return item; - } - - public static void GenerateAndAddSkillToMagicCard(Item item, int total) - { - Skill magic = Magics[Random.Shared.Next(Magics.Count)].Copy(); - magic.Guid = item.Guid; - magic.Level = (int)item.QualityType switch - { - 2 => 2, - 4 => 3, - 6 => 4, - _ => 1 - }; - item.Skills.Active = magic; - - // 鍒濆鍖栧睘鎬у - int str = 0, agi = 0, intelligence = 0; - - // 闅忔満鍐冲畾灏嗗灏戜釜灞炴ц祴缁欏叾涓竴涓睘鎬э紝纭繚鑷冲皯涓涓笉涓洪浂 - int nonZeroAttributes = Random.Shared.Next(1, Math.Min(4, total + 1)); // 闅忔満鍐冲畾闈為浂灞炴х殑鏁伴噺锛岀‘淇濆湪 total = 1 鏃舵渶澶氬彧鏈1涓潪闆跺睘鎬 - - // 鏍规嵁闈為浂灞炴ф暟閲忓垎閰嶅睘鎬х偣 - if (nonZeroAttributes == 1) - { - // 鍙湁涓涓睘鎬т笉涓洪浂 - int attribute = Random.Shared.Next(0, 3); - if (attribute == 0) str = total; - else if (attribute == 1) agi = total; - else intelligence = total; - } - else if (nonZeroAttributes == 2 && total >= 2) - { - // 涓や釜灞炴т笉涓洪浂 - int first = Random.Shared.Next(1, total); // 绗竴涓睘鎬х殑鍊 - int second = total - first; // 绗簩涓睘鎬х殑鍊 - - int attribute = Random.Shared.Next(0, 3); - if (attribute == 0) - { - str = first; - } - else if (attribute == 1) - { - agi = first; - } - else - { - intelligence = first; - } - - attribute = Random.Shared.Next(0, 3); - while ((attribute == 0 && str > 0) || (attribute == 1 && agi > 0) || (attribute == 2 && intelligence > 0)) - { - attribute = Random.Shared.Next(0, 3); - } - - if (attribute == 0) - { - str = second; - } - else if (attribute == 1) - { - agi = second; - } - else - { - intelligence = second; - } - } - else if (total >= 3) - { - // 涓変釜灞炴ч兘涓嶄负闆 - str = Random.Shared.Next(1, total - 1); // 绗竴涓睘鎬х殑鍊 - agi = Random.Shared.Next(1, total - str); // 绗簩涓睘鎬х殑鍊 - intelligence = total - str - agi; // 鍓╀笅鐨勫肩粰绗笁涓睘鎬 - } - - Skill skill = Factory.OpenFactory.GetInstance(item.Id, item.Name, []); - GenerateAndAddEffectsToMagicCard(skill, str, agi, intelligence); - - if (magic.Level > 1) item.Name += $" +{magic.Level - 1}"; - skill.Level = 1; - List strings = []; - if (str > 0) strings.Add($"{str:0.##} 鐐瑰姏閲"); - if (agi > 0) strings.Add($"{agi:0.##} 鐐规晱鎹"); - if (intelligence > 0) strings.Add($"{intelligence:0.##} 鐐规櫤鍔"); - item.Description = $"鍖呭惈榄旀硶锛歿item.Skills.Active.Name}\r\n" + - $"澧炲姞瑙掕壊灞炴э細{string.Join("锛", strings)}"; - item.Skills.Passives.Add(skill); - } - - public static void GenerateAndAddEffectsToMagicCard(Skill skill, int str, int agi, int intelligence) - { - if (str > 0) - { - skill.Effects.Add(Factory.OpenFactory.GetInstance((long)EffectID.ExSTR, "", new() - { - { "skill", skill }, - { - "values", new Dictionary() - { - { "exstr", str } - } - } - })); - } - - if (agi > 0) - { - skill.Effects.Add(Factory.OpenFactory.GetInstance((long)EffectID.ExAGI, "", new() - { - { "skill", skill }, - { - "values", new Dictionary() - { - { "exagi", agi } - } - } - })); - } - - if (intelligence > 0) - { - skill.Effects.Add(Factory.OpenFactory.GetInstance((long)EffectID.ExINT, "", new() - { - { "skill", skill }, - { - "values", new Dictionary() - { - { "exint", intelligence } - } - } - })); - } - } - - public static Item? ConflateMagicCardPack(IEnumerable magicCards) - { - if (magicCards.Any()) - { - List magics = [.. magicCards.Where(i => i.Skills.Active != null).Select(i => i.Skills.Active)]; - List passives = [.. magicCards.SelectMany(i => i.Skills.Passives)]; - Item item = Factory.GetItem(); - item.Id = Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 8)); - item.Name = GenerateRandomChineseName(); - item.ItemType = ItemType.MagicCardPack; - double str = 0, agi = 0, intelligence = 0; - foreach (Skill skill in passives) - { - Skill newSkill = skill.Copy(); - foreach (Effect effect in newSkill.Effects) - { - switch ((EffectID)effect.Id) - { - case EffectID.ExSTR: - if (effect is ExSTR exstr) - { - str += exstr.Value; - } - break; - case EffectID.ExAGI: - if (effect is ExAGI exagi) - { - agi += exagi.Value; - } - break; - case EffectID.ExINT: - if (effect is ExINT exint) - { - intelligence += exint.Value; - } - break; - } - } - newSkill.Level = skill.Level; - item.Skills.Passives.Add(newSkill); - } - List strings = []; - if (str > 0) strings.Add($"{str:0.##} 鐐瑰姏閲"); - if (agi > 0) strings.Add($"{agi:0.##} 鐐规晱鎹"); - if (intelligence > 0) strings.Add($"{intelligence:0.##} 鐐规櫤鍔"); - foreach (Skill skill in magics) - { - IEnumerable has = item.Skills.Magics.Where(m => m.Id == skill.Id); - if (has.Any() && has.First() is Skill s) - { - s.Level += skill.Level; - if (s.Level > 1) s.Name = s.Name.Split(' ')[0] + $" +{s.Level - 1}"; - } - else - { - Skill magic = skill.Copy(); - magic.Guid = item.Guid; - magic.Level = skill.Level; - item.Skills.Magics.Add(magic); - } - } - item.Description = $"鍖呭惈榄旀硶锛歿string.Join("锛", item.Skills.Magics.Select(m => m.Name + (m.Level > 1 ? $" +{m.Level - 1}" : "")))}\r\n" + - $"澧炲姞瑙掕壊灞炴э細{string.Join("锛", strings)}"; - double total = str + agi + intelligence; - if (total > 18 && total <= 36) - { - item.QualityType = QualityType.Green; - } - else if (total > 36 && total <= 54) - { - item.QualityType = QualityType.Blue; - } - else if (total > 54 && total <= 72) - { - item.QualityType = QualityType.Purple; - } - else if (total > 72 && total <= 90) - { - item.QualityType = QualityType.Orange; - } - return item; - } - return null; - } - - public static Item? GenerateMagicCardPack(int magicCardCount, QualityType? qualityType = null) - { - List magicCards = GenerateMagicCards(magicCardCount, qualityType); - Item? magicCardPack = ConflateMagicCardPack(magicCards); - return magicCardPack; - } - - public static void Reload() - { - Characters.Clear(); - CharacterStatistics.Clear(); - TeamCharacterStatistics.Clear(); - Equipment.Clear(); - Skills.Clear(); - Magics.Clear(); - - InitFunGame(); - } - public static Dictionary> RoundRewards { get @@ -1344,93 +1023,5 @@ namespace Oshima.Core.Utils // 纭繚璇勫垎鍦ㄥ悎鐞嗚寖鍥村唴 return Math.Max(0.01, rating); } - - public static string GenerateRandomChineseName() - { - // 瀹氫箟涓涓寘鍚父鐢ㄦ眽瀛楃殑瀛楃涓 - string commonChineseCharacters = "浜戞槦瀹濈伒姊﹂緳鑺遍洦椋庡彾灞卞窛鏈堢煶缇芥按绔归噾" + - "鐜夋捣鐏浄鍏夊ぉ鍦颁簯鍑よ檸铏圭彔鍗庨湠楣忛洩閾舵矙鏉炬鍏扮闈掗湝楦垮悍榫欓獜娉㈡硥娌虫箹姹熸辰" + - "娲嬫灄鏋妗傛ū妗愮鏅撮煹鍑屽叞鑻ユ偁纰ф稕娓婇闆峰鐭冲墤褰遍湒鐜勬壙鐝嶉泤鑰鏄熺憺榫欓工鐑" + - "褰卞嚖鐕曢湉缈肩窘缈旂拑缁罕缁唬閿︾憸鐞肩懢鐠囩挧鐞崇惇鐞崇懚鐟涜姖鏉忚寽鑽疯帀鑾硅彙鑾茶瘲缇界弽" + - "鐟扮繝妞掓姒嗘Э鏌辨ⅶ妗愭洔鏇欐櫠鏆栨櫤鐓岀啓鐏甸湏鐝犵啝鐕曠喒鐔犵ⅶ鐟剁惓鍢夌惇鐟剁惔鐟剁惔纰ф浖" + - "鑿佽搲鑿茬懢娣戝鎯犲槈鍗庣娑垫櫤鏄犲阀鎱ц尮鐟滅懚鑽h彵闇忔洣瀹硅姮鐜茬憶鐞憸婢滅ⅶ褰卞噷娓呮稕" + - "婀樻辰婢勬硴娉撶繝婢滄鼎鐠囩徍婀樻櫒鏇︽櫠缈犵懢婢滄稛娑︽窇娲佹偁闆呯繝闇忔兜娣戠弽缁繝娑"; - - // 闅忔満鐢熸垚鍚嶅瓧闀垮害锛2鍒5涓瓧 - int nameLength = Random.Shared.Next(2, 6); - StringBuilder name = new(); - - for (int i = 0; i < nameLength; i++) - { - // 浠庡父鐢ㄦ眽瀛楅泦涓殢鏈洪夋嫨涓涓眽瀛 - char chineseCharacter = commonChineseCharacters[Random.Shared.Next(commonChineseCharacters.Length)]; - name.Append(chineseCharacter); - } - - return name.ToString(); - } - - public static User GetUser(PluginConfig pc) - { - User user = pc.Get("user") ?? Factory.GetUser(); - - List characters = new(user.Inventory.Characters); - List items = new(user.Inventory.Items); - user.Inventory.Characters.Clear(); - user.Inventory.Items.Clear(); - - foreach (Character inventoryCharacter in characters) - { - Character realCharacter = CharacterBuilder.Build(inventoryCharacter, false); - realCharacter.User = user; - user.Inventory.Characters.Add(realCharacter); - } - - foreach (Item inventoryItem in items) - { - Item realItem = inventoryItem.Copy(true, true); - if (realItem.IsEquipment) - { - IEnumerable has = user.Inventory.Characters.Where(character => - { - if (realItem.ItemType == ItemType.MagicCardPack && character.EquipSlot.MagicCardPack != null && realItem.Guid == character.EquipSlot.MagicCardPack.Guid) - { - return true; - } - if (realItem.ItemType == ItemType.Weapon && character.EquipSlot.Weapon != null && realItem.Guid == character.EquipSlot.Weapon.Guid) - { - return true; - } - if (realItem.ItemType == ItemType.Armor && character.EquipSlot.Armor != null && realItem.Guid == character.EquipSlot.Armor.Guid) - { - return true; - } - if (realItem.ItemType == ItemType.Shoes && character.EquipSlot.Shoes != null && realItem.Guid == character.EquipSlot.Shoes.Guid) - { - return true; - } - if (realItem.ItemType == ItemType.Accessory) - { - if (character.EquipSlot.Accessory1 != null && realItem.Guid == character.EquipSlot.Accessory1.Guid) - { - return true; - } - else if (character.EquipSlot.Accessory2 != null && realItem.Guid == character.EquipSlot.Accessory2.Guid) - { - return true; - } - } - return false; - }); - if (has.Any() && has.First() is Character character) - { - realItem.Character = character; - } - } - user.Inventory.Items.Add(realItem); - } - - return user; - } } } diff --git a/OshimaMaps/OshimaMaps.csproj b/OshimaMaps/OshimaMaps.csproj index 2961f66..099fcfb 100644 --- a/OshimaMaps/OshimaMaps.csproj +++ b/OshimaMaps/OshimaMaps.csproj @@ -24,7 +24,7 @@ - ..\..\FunGame.Core\bin\Release\net9.0\FunGame.Core.dll + ..\..\FunGame.Core\bin\Debug\net9.0\FunGame.Core.dll diff --git a/OshimaModes/OshimaModes.csproj b/OshimaModes/OshimaModes.csproj index 8f43196..3416465 100644 --- a/OshimaModes/OshimaModes.csproj +++ b/OshimaModes/OshimaModes.csproj @@ -27,7 +27,7 @@ - ..\..\FunGame.Core\bin\Release\net9.0\FunGame.Core.dll + ..\..\FunGame.Core\bin\Debug\net9.0\FunGame.Core.dll ..\..\FunGame.Desktop\bin\Debug\net8.0-windows\FunGame.Desktop.dll diff --git a/OshimaModules/OshimaModules.csproj b/OshimaModules/OshimaModules.csproj index d118c40..6119995 100644 --- a/OshimaModules/OshimaModules.csproj +++ b/OshimaModules/OshimaModules.csproj @@ -24,7 +24,7 @@ - ..\..\FunGame.Core\bin\Release\net9.0\FunGame.Core.dll + ..\..\FunGame.Core\bin\Debug\net9.0\FunGame.Core.dll diff --git a/OshimaServers/OshimaServers.csproj b/OshimaServers/OshimaServers.csproj index 63b7a61..0996f54 100644 --- a/OshimaServers/OshimaServers.csproj +++ b/OshimaServers/OshimaServers.csproj @@ -23,7 +23,7 @@ - ..\..\FunGame.Core\bin\Release\net9.0\FunGame.Core.dll + ..\..\FunGame.Core\bin\Debug\net9.0\FunGame.Core.dll