From 4d0e44afd813f49c0497b752f28aa260e5e844d1 Mon Sep 17 00:00:00 2001 From: milimoe Date: Mon, 28 Apr 2025 00:24:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AD=BB=E4=BA=A1=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Effects/SkillEffects/提升友方行动速度.cs | 2 +- .../Effects/SkillEffects/造成封技.cs | 2 - .../Effects/SkillEffects/降低敌方行动速度.cs | 2 +- OshimaServers/Service/FunGameService.cs | 49 ++++++------ OshimaServers/Service/FunGameSimulation.cs | 6 ++ OshimaWebAPI/Controllers/FunGameController.cs | 79 +++++++++++++++++++ 6 files changed, 114 insertions(+), 26 deletions(-) diff --git a/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs b/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs index a89d8ff..a0500e1 100644 --- a/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs +++ b/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs @@ -32,7 +32,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects { foreach (Character target in targets) { - WriteLine($"[ {target} ] 的行动速度提升了 {SPD:0.##} !持续时间:{持续时间} {GameplayEquilibriumConstant.InGameTime}!"); + WriteLine($"[ {target} ] 的行动速度提升了 {SPD:0.##} !持续时间:{持续时间}!"); ExSPD e = new(Skill, new Dictionary() { { "exspd", SPD } diff --git a/OshimaModules/Effects/SkillEffects/造成封技.cs b/OshimaModules/Effects/SkillEffects/造成封技.cs index 3415c68..243fa39 100644 --- a/OshimaModules/Effects/SkillEffects/造成封技.cs +++ b/OshimaModules/Effects/SkillEffects/造成封技.cs @@ -1,5 +1,4 @@ using Milimoe.FunGame.Core.Entity; -using Milimoe.FunGame.Core.Library.Constant; using Oshima.FunGame.OshimaModules.Effects.PassiveEffects; namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects @@ -9,7 +8,6 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects public override long Id => Skill.Id; public override string Name => Skill.Name; public override string Description => $"对目标{(Skill.CanSelectTargetCount > 1 ? $"至多 {Skill.CanSelectTargetCount} 个" : "")}敌人造成封技 {封技时间},无法使用技能(魔法、战技和爆发技),并打断当前施法。"; - public override DispelledType DispelledType => DispelledType.Strong; private string 封技时间 => _durative && _duration > 0 ? 实际封技时间 + $" {GameplayEquilibriumConstant.InGameTime}" : (!_durative && _durationTurn > 0 ? 实际封技时间 + " 回合" : $"0 {GameplayEquilibriumConstant.InGameTime}"); private double 实际封技时间 => _durative && _duration > 0 ? _duration + _levelGrowth * (Level - 1) : (!_durative && _durationTurn > 0 ? _durationTurn + _levelGrowth * (Level - 1) : 0); diff --git a/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs b/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs index 839f12c..993ce83 100644 --- a/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs +++ b/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs @@ -32,7 +32,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects { foreach (Character target in targets) { - WriteLine($"[ {target} ] 的行动速度降低了 {-SPD:0.##} !持续时间:{持续时间} {GameplayEquilibriumConstant.InGameTime}!"); + WriteLine($"[ {target} ] 的行动速度降低了 {-SPD:0.##} !持续时间:{持续时间}!"); ExSPD e = new(Skill, new Dictionary() { { "exspd", SPD } diff --git a/OshimaServers/Service/FunGameService.cs b/OshimaServers/Service/FunGameService.cs index 5690043..7ff68ba 100644 --- a/OshimaServers/Service/FunGameService.cs +++ b/OshimaServers/Service/FunGameService.cs @@ -317,6 +317,7 @@ namespace Oshima.FunGame.OshimaServers.Service } } newSkill.Level = skill.Level; + newSkill.Item = item; item.Skills.Passives.Add(newSkill); } List strings = []; @@ -428,8 +429,8 @@ namespace Oshima.FunGame.OshimaServers.Service { User user = pc.Get("user") ?? Factory.GetUser(); - List characters = new(user.Inventory.Characters); - List items = new(user.Inventory.Items); + List characters = [.. user.Inventory.Characters]; + List items = [.. user.Inventory.Items]; Character mc = user.Inventory.MainCharacter; List squad = [.. user.Inventory.Squad]; Dictionary training = user.Inventory.Training.ToDictionary(kv => kv.Key, kv => kv.Value); @@ -468,12 +469,16 @@ namespace Oshima.FunGame.OshimaServers.Service // 自动回血 DateTime now = DateTime.Now; int seconds = (int)(now - user.LastTime).TotalSeconds; - double recoveryHP = realCharacter.HR * seconds; - double recoveryMP = realCharacter.MR * seconds; - double recoveryEP = realCharacter.ER * seconds; - realCharacter.HP += recoveryHP; - realCharacter.MP += recoveryMP; - realCharacter.EP += recoveryEP; + // 死了不回,要去治疗 + if (realCharacter.HP > 0) + { + double recoveryHP = realCharacter.HR * seconds; + double recoveryMP = realCharacter.MR * seconds; + double recoveryEP = realCharacter.ER * seconds; + realCharacter.HP += recoveryHP; + realCharacter.MP += recoveryMP; + realCharacter.EP += recoveryEP; + } // 减少所有技能的冷却时间 foreach (Skill skill in realCharacter.Skills) { @@ -485,7 +490,7 @@ namespace Oshima.FunGame.OshimaServers.Service } } // 移除到时间的特效 - List effects = realCharacter.Effects.Where(e => e.Level > 0).ToList(); + List effects = [.. realCharacter.Effects]; foreach (Effect effect in effects) { if (effect.Level == 0) @@ -541,7 +546,7 @@ namespace Oshima.FunGame.OshimaServers.Service public static IEnumerable GetPage(IEnumerable list, int showPage, int pageSize) { - return list.Skip((showPage - 1) * pageSize).Take(pageSize).ToList(); + return [.. list.Skip((showPage - 1) * pageSize).Take(pageSize)]; } public static string GetDrawCardResult(int reduce, User user, bool isMulti = false, int multiCount = 1) @@ -568,7 +573,7 @@ namespace Oshima.FunGame.OshimaServers.Service { case 1: if ((int)type > (int)QualityType.Orange) type = QualityType.Orange; - Item[] 武器 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type).ToArray(); + Item[] 武器 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type)]; Item a = 武器[Random.Shared.Next(武器.Length)].Copy(); SetSellAndTradeTime(a); user.Inventory.Items.Add(a); @@ -577,7 +582,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 2: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 防具 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type).ToArray(); + Item[] 防具 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type)]; Item b = 防具[Random.Shared.Next(防具.Length)].Copy(); SetSellAndTradeTime(b); user.Inventory.Items.Add(b); @@ -586,7 +591,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 3: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 鞋子 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type).ToArray(); + Item[] 鞋子 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type)]; Item c = 鞋子[Random.Shared.Next(鞋子.Length)].Copy(); SetSellAndTradeTime(c); user.Inventory.Items.Add(c); @@ -595,7 +600,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 4: if ((int)type > (int)QualityType.Purple) type = QualityType.Purple; - Item[] 饰品 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type).ToArray(); + Item[] 饰品 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type)]; Item d = 饰品[Random.Shared.Next(饰品.Length)].Copy(); SetSellAndTradeTime(d); user.Inventory.Items.Add(d); @@ -684,7 +689,7 @@ namespace Oshima.FunGame.OshimaServers.Service { case 1: if ((int)type > (int)QualityType.Orange) type = QualityType.Orange; - Item[] 武器 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type).ToArray(); + Item[] 武器 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type)]; Item a = 武器[Random.Shared.Next(武器.Length)].Copy(); SetSellAndTradeTime(a); user.Inventory.Items.Add(a); @@ -693,7 +698,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 2: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 防具 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type).ToArray(); + Item[] 防具 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type)]; Item b = 防具[Random.Shared.Next(防具.Length)].Copy(); SetSellAndTradeTime(b); user.Inventory.Items.Add(b); @@ -702,7 +707,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 3: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 鞋子 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type).ToArray(); + Item[] 鞋子 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type)]; Item c = 鞋子[Random.Shared.Next(鞋子.Length)].Copy(); SetSellAndTradeTime(c); user.Inventory.Items.Add(c); @@ -711,7 +716,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 4: if ((int)type > (int)QualityType.Purple) type = QualityType.Purple; - Item[] 饰品 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type).ToArray(); + Item[] 饰品 = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type)]; Item d = 饰品[Random.Shared.Next(饰品.Length)].Copy(); SetSellAndTradeTime(d); user.Inventory.Items.Add(d); @@ -1295,10 +1300,10 @@ namespace Oshima.FunGame.OshimaServers.Service boss.Level = cLevel; boss.NormalAttack.Level = naLevel; boss.NormalAttack.HardnessTime = 6; - Item[] weapons = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == 4).ToArray(); - Item[] armors = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == 1).ToArray(); - Item[] shoes = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == 1).ToArray(); - Item[] accessory = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == 3).ToArray(); + Item[] weapons = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == 4)]; + Item[] armors = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == 1)]; + Item[] shoes = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == 1)]; + Item[] accessory = [.. FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == 3)]; Item? a = null, b = null, c = null, d = null, d2 = null; if (weapons.Length > 0) { diff --git a/OshimaServers/Service/FunGameSimulation.cs b/OshimaServers/Service/FunGameSimulation.cs index dcf3717..a6ecc96 100644 --- a/OshimaServers/Service/FunGameSimulation.cs +++ b/OshimaServers/Service/FunGameSimulation.cs @@ -4,6 +4,7 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Model; using Oshima.FunGame.OshimaModules.Effects.OpenEffects; +using Oshima.FunGame.OshimaModules.Skills; namespace Oshima.FunGame.OshimaServers.Service { @@ -114,6 +115,11 @@ namespace Oshima.FunGame.OshimaServers.Service c.Level = clevel; c.NormalAttack.Level = mlevel; FunGameService.AddCharacterSkills(c, 1, slevel, slevel); + Skill 疾风步 = new 疾风步(c) + { + Level = slevel + }; + c.Skills.Add(疾风步); } // 创建顺序表并排序 diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index d637f7d..a59182e 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -5151,6 +5151,85 @@ namespace Oshima.FunGame.WebAPI.Controllers } } + [HttpPost("springoflife")] + public string SpringOfLife([FromQuery] long? uid = null) + { + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + string msg = ""; + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + + int dead = user.Inventory.Characters.Count(c => c.HP <= 0); + int halfdown = user.Inventory.Characters.Count(c => (c.HP / c.MaxHP) < 0.5 && c.HP > 0); + int halfup = user.Inventory.Characters.Count(c => (c.HP / c.MaxHP) >= 0.5); + + double deadNeed = 10000 * dead; + double halfdownNeed = 6000 * halfdown; + double halfupNeed = 2000 * halfup; + double total = deadNeed + halfdownNeed + halfupNeed; + + if (user.Inventory.Credits >= total) + { + user.Inventory.Credits -= total; + foreach (Character character in user.Inventory.Characters) + { + character.Recovery(); + } + + msg = $"感谢使用生命之泉服务!你已消费:{total} {General.GameplayEquilibriumConstant.InGameCurrency}。"; + + user.LastTime = DateTime.Now; + pc.Add("user", user); + pc.SaveConfig(); + } + else + { + msg = $"你的 {General.GameplayEquilibriumConstant.InGameCurrency} 不足 {total} 呢!无法饮用生命之泉!"; + } + + msg += $"({dead} 个死亡角色,{halfdown} 个 50% 以下的角色,{halfup} 个 50% 以上的角色)\r\n" + + $"收费标准:\r\n10000 {General.GameplayEquilibriumConstant.InGameCurrency} / 死亡角色\r\n" + + $"6000 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以下的角色\r\n" + + $"2000 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以上的角色"; + + return msg; + } + else + { + return noSaved; + } + } + + [HttpPost("template")] + public string Template([FromQuery] long? uid = null) + { + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + string msg = ""; + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + + user.LastTime = DateTime.Now; + pc.Add("user", user); + pc.SaveConfig(); + + return msg; + } + else + { + return noSaved; + } + } + [HttpGet("reload")] public string Relaod([FromQuery] long? master = null) {