From 8d3d19737cb4900ab6a562295381bb21a39f9b74 Mon Sep 17 00:00:00 2001 From: milimoe Date: Tue, 20 Jan 2026 01:56:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=92=8C=E9=92=A9=E5=AD=90=EF=BC=9B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20OnSkillCasted=20=E5=89=8D=E8=87=AA=E5=8A=A8=E8=B1=81?= =?UTF-8?q?=E5=85=8D=EF=BC=9B=E5=AE=8C=E5=96=84=E9=AD=94=E6=B3=95=E6=95=88?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Skill/Effect.cs | 15 +++++++- Entity/Skill/Skill.cs | 18 ++++++++- Interface/Base/IGamingQueue.cs | 3 +- Model/EquilibriumConstant.cs | 6 +-- Model/GamingQueue.cs | 67 +++++++++++++++++++++++++++------- 5 files changed, 90 insertions(+), 19 deletions(-) diff --git a/Entity/Skill/Effect.cs b/Entity/Skill/Effect.cs index 7b87ec0..b99565f 100644 --- a/Entity/Skill/Effect.cs +++ b/Entity/Skill/Effect.cs @@ -179,6 +179,11 @@ namespace Milimoe.FunGame.Core.Entity /// public virtual bool ExemptDuration { get; set; } = false; + /// + /// 魔法效能% [ 来自技能 ] + /// + public double MagicEfficacy => Skill.MagicEfficacy; + /// /// 效果描述 /// @@ -256,6 +261,14 @@ namespace Milimoe.FunGame.Core.Entity } + /// + /// 游戏开始时触发(第一回合开始前) + /// + public virtual void OnGameStart() + { + + } + /// /// 在伤害计算前修改伤害类型 /// @@ -1004,7 +1017,7 @@ namespace Milimoe.FunGame.Core.Entity /// public void HealToTarget(Character actor, Character target, double heal, bool canRespawn = false, bool triggerEffects = true) { - GamingQueue?.HealToTarget(actor, target, heal, canRespawn, triggerEffects); + GamingQueue?.HealToTarget(actor, target, heal, canRespawn, triggerEffects, Skill); } /// diff --git a/Entity/Skill/Skill.cs b/Entity/Skill/Skill.cs index 2d51983..0b14d1b 100644 --- a/Entity/Skill/Skill.cs +++ b/Entity/Skill/Skill.cs @@ -266,7 +266,7 @@ namespace Milimoe.FunGame.Core.Entity public virtual double CD { get; set; } = 0; /// - /// 剩余冷却时间 [ 建议配合 属性使用 ] + /// 剩余冷却时间 [ 和 属性配合使用 ] /// public double CurrentCD { get; set; } = 0; @@ -345,6 +345,11 @@ namespace Milimoe.FunGame.Core.Entity /// public Item? Item { get; set; } = null; + /// + /// 设置该属性可以由框架自动进行豁免检定 + /// + public virtual Effect? EffectForExemptionCheck { get; set; } = null; + /// /// 继承此类实现时,调用基类的构造函数 /// @@ -696,6 +701,17 @@ namespace Milimoe.FunGame.Core.Entity public void OnSkillCasted(IGamingQueue queue, Character caster, List targets, List grids) { GamingQueue = queue; + if (EffectForExemptionCheck != null) + { + Character[] exemptionTargets = [.. targets]; + foreach (Character target in exemptionTargets) + { + if (!GamingQueue.CheckExemption(target, caster, EffectForExemptionCheck, true)) + { + targets.Remove(target); + } + } + } Character[] characters = [caster, .. targets]; foreach (Character target in characters) { diff --git a/Interface/Base/IGamingQueue.cs b/Interface/Base/IGamingQueue.cs index c8f562a..d104b1c 100644 --- a/Interface/Base/IGamingQueue.cs +++ b/Interface/Base/IGamingQueue.cs @@ -114,7 +114,8 @@ namespace Milimoe.FunGame.Core.Interface.Base /// /// /// - public void HealToTarget(Character actor, Character target, double heal, bool canRespawn = false, bool triggerEffects = true); + /// + public void HealToTarget(Character actor, Character target, double heal, bool canRespawn = false, bool triggerEffects = true, Skill? skill = null); /// /// 计算物理伤害 diff --git a/Model/EquilibriumConstant.cs b/Model/EquilibriumConstant.cs index 57e0df7..a931d35 100644 --- a/Model/EquilibriumConstant.cs +++ b/Model/EquilibriumConstant.cs @@ -213,12 +213,12 @@ namespace Milimoe.FunGame.Core.Model /// /// 每 1 点力量增加生命值 /// - public double STRtoHPFactor { get; set; } = 9; + public double STRtoHPFactor { get; set; } = 13; /// /// 每 1 点力量增加生命回复力 /// - public double STRtoHRFactor { get; set; } = 0.1; + public double STRtoHRFactor { get; set; } = 0.15; /// /// 每 1 点力量增加物理护甲 @@ -248,7 +248,7 @@ namespace Milimoe.FunGame.Core.Model /// /// 每 1 点智力增加魔法回复力 /// - public double INTtoMRFactor { get; set; } = 0.04; + public double INTtoMRFactor { get; set; } = 0.1; /// /// 每 1 点智力减少魔法消耗 diff --git a/Model/GamingQueue.cs b/Model/GamingQueue.cs index 4b9f2e7..e2c6d30 100644 --- a/Model/GamingQueue.cs +++ b/Model/GamingQueue.cs @@ -703,14 +703,25 @@ namespace Milimoe.FunGame.Core.Model if (character != null) { - _queue.Remove(character); - _cutCount.Remove(character); - // 进入下一回合 TotalRound++; LastRound = new(TotalRound); Rounds.Add(LastRound); + if (TotalRound == 1) + { + // 触发游戏开始事件 + OnGameStartEvent(); + Effect[] effects = [.. _queue.SelectMany(c => c.Effects).Where(e => e.IsInEffect)]; + foreach (Effect effect in effects) + { + effect.OnGameStart(); + } + } + + _queue.Remove(character); + _cutCount.Remove(character); + return character; } else @@ -817,13 +828,18 @@ namespace Milimoe.FunGame.Core.Model } // 减少所有技能的冷却时间 - foreach (Skill skill in character.Skills) + List skills = [.. character.Skills.Union(character.Items.Where(i => i.Skills.Active != null).Select(i => i.Skills.Active!))]; + AddCharacterEquipSlotSkills(character, skills); + foreach (Skill skill in skills) { - skill.CurrentCD -= timeToReduce; - if (skill.CurrentCD <= 0) + if (skill.CurrentCD > 0) { - skill.CurrentCD = 0; - skill.Enable = true; + skill.CurrentCD -= timeToReduce; + if (skill.CurrentCD <= 0) + { + skill.CurrentCD = 0; + skill.Enable = true; + } } } @@ -2691,7 +2707,8 @@ namespace Milimoe.FunGame.Core.Model /// /// /// - public void HealToTarget(Character actor, Character target, double heal, bool canRespawn = false, bool triggerEffects = true) + /// + public void HealToTarget(Character actor, Character target, double heal, bool canRespawn = false, bool triggerEffects = true, Skill? skill = null) { // 死人怎么能对自己治疗呢? if (actor.HP <= 0) @@ -2720,7 +2737,8 @@ namespace Milimoe.FunGame.Core.Model } bool isDead = target.HP <= 0; - string healString = $"【{heal:0.##}(基础)"; + List healStrings = []; + healStrings.Add($"{heal:0.##}(基础)"); if (triggerEffects) { @@ -2737,13 +2755,22 @@ namespace Milimoe.FunGame.Core.Model if (healBonus != 0) { totalHealBonus[effect]= healBonus; - healString += $"{(healBonus > 0 ? " + " : " - ")}{Math.Abs(healBonus):0.##}({effect.Name})"; + healStrings.Add($"{(healBonus > 0 ? " + " : " - ")}{Math.Abs(healBonus):0.##}({effect.Name})"); } } heal += totalHealBonus.Sum(kv => kv.Value); } - healString += $" = {heal:0.##} 点生命值】"; - if (!IsDebug) healString = ""; + + if (skill != null && skill.MagicBottleneck > 0) + { + double efficacyHeal = heal * (skill.MagicEfficacy - 1); + heal *= skill.MagicEfficacy; + healStrings.Add($"{(efficacyHeal >= 0 ? " + " : " - ")}{Math.Abs(efficacyHeal):0.##}(魔法效能:{skill.MagicEfficacy * 100:0.##}%)"); + } + + healStrings.Add($" = {heal:0.##} 点生命值"); + if (!IsDebug) healStrings.Clear(); + string healString = $"【{string.Join("", healStrings)}】"; if (target.HP > 0 || (isDead && canRespawn)) { @@ -4887,6 +4914,20 @@ namespace Milimoe.FunGame.Core.Model CharacterMoveEvent?.Invoke(this, actor, dp, grid); } + public delegate void GameStartEventHandler(GamingQueue queue); + /// + /// 游戏开始事件 + /// + public event GameStartEventHandler? GameStartEvent; + /// + /// 游戏开始事件 + /// + /// + protected void OnGameStartEvent() + { + GameStartEvent?.Invoke(this); + } + public delegate bool GameEndEventHandler(GamingQueue queue, Character winner); /// /// 游戏结束事件