diff --git a/Entity/BaseEntity.cs b/Entity/BaseEntity.cs index f6f8824..ed444e4 100644 --- a/Entity/BaseEntity.cs +++ b/Entity/BaseEntity.cs @@ -1,5 +1,6 @@ using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Library.Constant; +using Milimoe.FunGame.Core.Model; namespace Milimoe.FunGame.Core.Entity { @@ -25,6 +26,11 @@ namespace Milimoe.FunGame.Core.Entity /// public EntityState EntityState { get; set; } = EntityState.Unchanged; + /// + /// 实体所用的游戏平衡常数 + /// + public EquilibriumConstant GameplayEquilibriumConstant { get; set; } = General.GameplayEquilibriumConstant; + /// /// 比较两个实体是否相同 /// diff --git a/Entity/Character/Character.cs b/Entity/Character/Character.cs index 945ad09..3c31303 100644 --- a/Entity/Character/Character.cs +++ b/Entity/Character/Character.cs @@ -73,31 +73,31 @@ namespace Milimoe.FunGame.Core.Entity { get { - if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["S"]) + if (Promotion > GameplayEquilibriumConstant.PromotionsUpperLimit["S"]) { return RoleRating.X; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["A+"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["S"]) + else if (Promotion > GameplayEquilibriumConstant.PromotionsUpperLimit["A+"] && Promotion <= GameplayEquilibriumConstant.PromotionsUpperLimit["S"]) { return RoleRating.S; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["A"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["A+"]) + else if (Promotion > GameplayEquilibriumConstant.PromotionsUpperLimit["A"] && Promotion <= GameplayEquilibriumConstant.PromotionsUpperLimit["A+"]) { return RoleRating.APlus; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["B"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["A"]) + else if (Promotion > GameplayEquilibriumConstant.PromotionsUpperLimit["B"] && Promotion <= GameplayEquilibriumConstant.PromotionsUpperLimit["A"]) { return RoleRating.A; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["C"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["B"]) + else if (Promotion > GameplayEquilibriumConstant.PromotionsUpperLimit["C"] && Promotion <= GameplayEquilibriumConstant.PromotionsUpperLimit["B"]) { return RoleRating.B; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["D"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["C"]) + else if (Promotion > GameplayEquilibriumConstant.PromotionsUpperLimit["D"] && Promotion <= GameplayEquilibriumConstant.PromotionsUpperLimit["C"]) { return RoleRating.C; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["E"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["D"]) + else if (Promotion > GameplayEquilibriumConstant.PromotionsUpperLimit["E"] && Promotion <= GameplayEquilibriumConstant.PromotionsUpperLimit["D"]) { return RoleRating.D; } @@ -129,7 +129,7 @@ namespace Milimoe.FunGame.Core.Entity } set { - _Level = Math.Min(Math.Max(1, value), General.GameplayEquilibriumConstant.MaxLevel); + _Level = Math.Min(Math.Max(1, value), GameplayEquilibriumConstant.MaxLevel); OnAttributeChanged(); Recovery(); } @@ -174,17 +174,17 @@ namespace Milimoe.FunGame.Core.Entity /// 初始生命值 [ 初始设定 ] /// [InitRequired] - public double InitialHP { get; set; } = General.GameplayEquilibriumConstant.InitialHP; + public double InitialHP { get; set; } = 0; /// /// 基础生命值 [ 与初始设定和等级相关 ] [ 与基础力量相关 ] /// - public double BaseHP => InitialHP + (Level - 1) * (General.GameplayEquilibriumConstant.LevelToHPFactor + General.GameplayEquilibriumConstant.HPGrowthFactor * InitialHP) + BaseSTR * General.GameplayEquilibriumConstant.STRtoHPFactor; + public double BaseHP => InitialHP + (Level - 1) * (GameplayEquilibriumConstant.LevelToHPFactor + GameplayEquilibriumConstant.HPGrowthFactor * InitialHP) + BaseSTR * GameplayEquilibriumConstant.STRtoHPFactor; /// /// 额外生命值 [ 与额外力量相关 ] /// - public double ExHP => ExSTR * General.GameplayEquilibriumConstant.STRtoHPFactor; + public double ExHP => ExSTR * GameplayEquilibriumConstant.STRtoHPFactor; /// /// 额外生命值2 [ 与技能和物品相关 ] @@ -227,17 +227,17 @@ namespace Milimoe.FunGame.Core.Entity /// 初始魔法值 [ 初始设定 ] /// [InitRequired] - public double InitialMP { get; set; } = General.GameplayEquilibriumConstant.InitialMP; + public double InitialMP { get; set; } = 0; /// /// 基础魔法值 [ 与初始设定和等级相关 ] [ 与基础智力相关 ] /// - public double BaseMP => InitialMP + (Level - 1) * (General.GameplayEquilibriumConstant.LevelToMPFactor + General.GameplayEquilibriumConstant.MPGrowthFactor * InitialMP) + BaseINT * General.GameplayEquilibriumConstant.INTtoMPFactor; + public double BaseMP => InitialMP + (Level - 1) * (GameplayEquilibriumConstant.LevelToMPFactor + GameplayEquilibriumConstant.MPGrowthFactor * InitialMP) + BaseINT * GameplayEquilibriumConstant.INTtoMPFactor; /// /// 额外魔法值 [ 与额外智力相关 ] /// - public double ExMP => ExINT * General.GameplayEquilibriumConstant.INTtoMPFactor; + public double ExMP => ExINT * GameplayEquilibriumConstant.INTtoMPFactor; /// /// 额外魔法值2 [ 与技能和物品相关 ] @@ -283,12 +283,12 @@ namespace Milimoe.FunGame.Core.Entity { get { - return _EP < 0 ? 0 : (_EP > General.GameplayEquilibriumConstant.MaxEP ? General.GameplayEquilibriumConstant.MaxEP : _EP); + return _EP < 0 ? 0 : (_EP > GameplayEquilibriumConstant.MaxEP ? GameplayEquilibriumConstant.MaxEP : _EP); } set { _EP = value; - if (_EP > General.GameplayEquilibriumConstant.MaxEP) _EP = General.GameplayEquilibriumConstant.MaxEP; + if (_EP > GameplayEquilibriumConstant.MaxEP) _EP = GameplayEquilibriumConstant.MaxEP; else if (_EP < 0) _EP = 0; } } @@ -297,7 +297,7 @@ namespace Milimoe.FunGame.Core.Entity /// 初始攻击力 [ 初始设定 ] /// [InitRequired] - public double InitialATK { get; set; } = General.GameplayEquilibriumConstant.InitialATK; + public double InitialATK { get; set; } = 0; /// /// 基础攻击力 [ 与初始设定和等级相关 ] [ 与核心属性相关 ] @@ -306,7 +306,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - double atk = InitialATK + (Level - 1) * (General.GameplayEquilibriumConstant.LevelToATKFactor + General.GameplayEquilibriumConstant.ATKGrowthFactor * InitialATK); + double atk = InitialATK + (Level - 1) * (GameplayEquilibriumConstant.LevelToATKFactor + GameplayEquilibriumConstant.ATKGrowthFactor * InitialATK); if (PrimaryAttribute == PrimaryAttribute.AGI) { return atk + BaseAGI; @@ -368,17 +368,17 @@ namespace Milimoe.FunGame.Core.Entity /// 初始物理护甲 [ 初始设定 ] /// [InitRequired] - public double InitialDEF { get; set; } = General.GameplayEquilibriumConstant.InitialDEF; + public double InitialDEF { get; set; } = 0; /// /// 基础物理护甲 [ 与初始设定相关 ] [ 与基础力量相关 ] /// - public double BaseDEF => InitialDEF + BaseSTR * General.GameplayEquilibriumConstant.STRtoDEFFactor; + public double BaseDEF => InitialDEF + BaseSTR * GameplayEquilibriumConstant.STRtoDEFFactor; /// /// 额外物理护甲 [ 与额外力量相关 ] /// - public double ExDEF => ExSTR * General.GameplayEquilibriumConstant.STRtoDEFFactor; + public double ExDEF => ExSTR * GameplayEquilibriumConstant.STRtoDEFFactor; /// /// 额外物理护甲2 [ 与技能和物品相关 ] @@ -407,7 +407,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - double value = (DEF / (DEF + General.GameplayEquilibriumConstant.DEFReductionFactor)) + ExPDR; + double value = (DEF / (DEF + GameplayEquilibriumConstant.DEFReductionFactor)) + ExPDR; return Calculation.PercentageCheck(value); } } @@ -461,7 +461,7 @@ namespace Milimoe.FunGame.Core.Entity /// /// 生命回复力 = [ 与初始设定相关 ] [ 与力量相关 ] + 额外生命回复力 /// - public double HR => InitialHR + STR * General.GameplayEquilibriumConstant.STRtoHRFactor + ExHR; + public double HR => InitialHR + STR * GameplayEquilibriumConstant.STRtoHRFactor + ExHR; /// /// 额外生命回复力 [ 与技能和物品相关 ] @@ -477,7 +477,7 @@ namespace Milimoe.FunGame.Core.Entity /// /// 魔法回复力 = [ 与初始设定相关 ] [ 与智力相关 ] + 额外魔法回复力 /// - public double MR => InitialMR + INT * General.GameplayEquilibriumConstant.INTtoMRFactor + ExMR; + public double MR => InitialMR + INT * GameplayEquilibriumConstant.INTtoMRFactor + ExMR; /// /// 额外魔法回复力 [ 与技能和物品相关 ] @@ -672,7 +672,7 @@ namespace Milimoe.FunGame.Core.Entity /// /// 行动速度 = [ 与初始设定相关 ][ 与敏捷相关 ] + 额外行动速度 /// - public double SPD => InitialSPD + AGI * General.GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; + public double SPD => InitialSPD + AGI * GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; /// /// 额外行动速度 [ 与技能和物品相关 ] @@ -686,7 +686,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - double value = SPD / General.GameplayEquilibriumConstant.SPDUpperLimit + ExActionCoefficient; + double value = SPD / GameplayEquilibriumConstant.SPDUpperLimit + ExActionCoefficient; return Calculation.PercentageCheck(value); } } @@ -703,7 +703,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - double value = INT * General.GameplayEquilibriumConstant.INTtoAccelerationCoefficientMultiplier + ExAccelerationCoefficient; + double value = INT * GameplayEquilibriumConstant.INTtoAccelerationCoefficientMultiplier + ExAccelerationCoefficient; return Calculation.PercentageCheck(value); } } @@ -720,7 +720,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - double value = INT * General.GameplayEquilibriumConstant.INTtoCDRMultiplier + ExCDR; + double value = INT * GameplayEquilibriumConstant.INTtoCDRMultiplier + ExCDR; return Calculation.PercentageCheck(value); } } @@ -743,7 +743,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - double value = General.GameplayEquilibriumConstant.CritRate + AGI * General.GameplayEquilibriumConstant.AGItoCritRateMultiplier + ExCritRate; + double value = GameplayEquilibriumConstant.CritRate + AGI * GameplayEquilibriumConstant.AGItoCritRateMultiplier + ExCritRate; return Calculation.PercentageCheck(value); } } @@ -760,7 +760,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - return General.GameplayEquilibriumConstant.CritDMG + STR * General.GameplayEquilibriumConstant.STRtoCritDMGMultiplier + ExCritDMG; + return GameplayEquilibriumConstant.CritDMG + STR * GameplayEquilibriumConstant.STRtoCritDMGMultiplier + ExCritDMG; } } @@ -776,7 +776,7 @@ namespace Milimoe.FunGame.Core.Entity { get { - double value = General.GameplayEquilibriumConstant.EvadeRate + AGI * General.GameplayEquilibriumConstant.AGItoEvadeRateMultiplier + ExEvadeRate; + double value = GameplayEquilibriumConstant.EvadeRate + AGI * GameplayEquilibriumConstant.AGItoEvadeRateMultiplier + ExEvadeRate; return Calculation.PercentageCheck(value); } } @@ -844,6 +844,10 @@ namespace Milimoe.FunGame.Core.Entity { User = General.UnknownUserInstance; Profile = new(Name, FirstName, NickName); + InitialHP = GameplayEquilibriumConstant.InitialHP; + InitialMP = GameplayEquilibriumConstant.InitialMP; + InitialATK = GameplayEquilibriumConstant.InitialATK; + InitialDEF = GameplayEquilibriumConstant.InitialDEF; EquipSlot = new(); MDF = new(); NormalAttack = new(this); @@ -1136,10 +1140,10 @@ namespace Milimoe.FunGame.Core.Entity { break; } - if (General.GameplayEquilibriumConstant.UseLevelBreak && checkLevelBreak) + if (GameplayEquilibriumConstant.UseLevelBreak && checkLevelBreak) { // 检查角色突破进度 - int[] breaks = [.. General.GameplayEquilibriumConstant.LevelBreakList]; + int[] breaks = [.. GameplayEquilibriumConstant.LevelBreakList]; int nextBreak = LevelBreak + 1; if (nextBreak < breaks.Length && Level >= breaks[nextBreak]) { @@ -1147,7 +1151,7 @@ namespace Milimoe.FunGame.Core.Entity break; } } - if (Level > 0 && Level < General.GameplayEquilibriumConstant.MaxLevel && General.GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) && EXP >= need) + if (Level > 0 && Level < GameplayEquilibriumConstant.MaxLevel && GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) && EXP >= need) { EXP -= need; Level++; @@ -1166,10 +1170,10 @@ namespace Milimoe.FunGame.Core.Entity /// public void OnLevelBreak() { - if (General.GameplayEquilibriumConstant.UseLevelBreak) + if (GameplayEquilibriumConstant.UseLevelBreak) { // 检查角色突破进度 - int[] levels = [.. General.GameplayEquilibriumConstant.LevelBreakList]; + int[] levels = [.. GameplayEquilibriumConstant.LevelBreakList]; while (LevelBreak + 1 < levels.Length && Level >= levels[LevelBreak + 1]) { LevelBreak++; @@ -1313,14 +1317,14 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); if (showEXP) { - builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}(突破进度:{LevelBreak + 1} / {General.GameplayEquilibriumConstant.LevelBreakList.Count})"); - builder.AppendLine($"经验值:{EXP}{(Level != General.GameplayEquilibriumConstant.MaxLevel && General.GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) ? " / " + need : "")}"); + builder.AppendLine($"等级:{Level} / {GameplayEquilibriumConstant.MaxLevel}(突破进度:{LevelBreak + 1} / {GameplayEquilibriumConstant.LevelBreakList.Count})"); + builder.AppendLine($"经验值:{EXP}{(Level != GameplayEquilibriumConstant.MaxLevel && GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) ? " / " + need : "")}"); } double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : "")); - builder.AppendLine($"能量值:{EP:0.##} / {General.GameplayEquilibriumConstant.MaxEP:0.##}"); + builder.AppendLine($"能量值:{EP:0.##} / {GameplayEquilibriumConstant.MaxEP:0.##}"); double exATK = ExATK + ExATK2 + ExATK3; builder.AppendLine($"攻击力:{ATK:0.##}" + (exATK != 0 ? $" [{BaseATK:0.##} {(exATK >= 0 ? "+" : "-")} {Math.Abs(exATK):0.##}]" : "")); double exDEF = ExDEF + ExDEF2 + ExDEF3; @@ -1329,7 +1333,7 @@ namespace Milimoe.FunGame.Core.Entity MDF.Bright + MDF.Shadow + MDF.Element + MDF.Fleabane + MDF.Particle) / 9) * 100; if (Calculation.IsApproximatelyZero(mdf)) mdf = 0; builder.AppendLine($"魔法抗性:{mdf:0.##}%(平均)"); - double exSPD = AGI * General.GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; + double exSPD = AGI * GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; builder.AppendLine($"行动速度:{SPD:0.##}" + (exSPD != 0 ? $" [{InitialSPD:0.##} {(exSPD >= 0 ? "+" : "-")} {Math.Abs(exSPD):0.##}]" : "") + $" ({ActionCoefficient * 100:0.##}%)"); builder.AppendLine($"核心属性:{CharacterSet.GetPrimaryAttributeName(PrimaryAttribute)}"); double exSTR = ExSTR + ExSTR2; @@ -1338,8 +1342,8 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine($"敏捷:{AGI:0.##}" + (exAGI != 0 ? $" [{BaseAGI:0.##} {(exAGI >= 0 ? "+" : "-")} {Math.Abs(exAGI):0.##}]" : "") + (showGrowth ? $"({(AGIGrowth >= 0 ? "+" : "-")}{Math.Abs(AGIGrowth)}/Lv)" : "")); double exINT = ExINT + ExINT2; builder.AppendLine($"智力:{INT:0.##}" + (exINT != 0 ? $" [{BaseINT:0.##} {(exINT >= 0 ? "+" : "-")} {Math.Abs(exINT):0.##}]" : "") + (showGrowth ? $"({(INTGrowth >= 0 ? "+" : "-")}{Math.Abs(INTGrowth)}/Lv)" : "")); - builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * General.GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); - builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * General.GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); + builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); + builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); builder.AppendLine($"暴击率:{CritRate * 100:0.##}%"); builder.AppendLine($"暴击伤害:{CritDMG * 100:0.##}%"); builder.AppendLine($"闪避率:{EvadeRate * 100:0.##}%"); @@ -1347,8 +1351,8 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine($"加速系数:{AccelerationCoefficient * 100:0.##}%"); builder.AppendLine($"物理穿透:{PhysicalPenetration * 100:0.##}%"); builder.AppendLine($"魔法穿透:{MagicalPenetration * 100:0.##}%"); - builder.AppendLine($"魔法消耗减少:{INT * General.GameplayEquilibriumConstant.INTtoCastMPReduce * 100:0.##}%"); - builder.AppendLine($"能量消耗减少:{INT * General.GameplayEquilibriumConstant.INTtoCastEPReduce * 100:0.##}%"); + builder.AppendLine($"魔法消耗减少:{INT * GameplayEquilibriumConstant.INTtoCastMPReduce * 100:0.##}%"); + builder.AppendLine($"能量消耗减少:{INT * GameplayEquilibriumConstant.INTtoCastEPReduce * 100:0.##}%"); if (CharacterState != CharacterState.Actionable) { @@ -1444,14 +1448,14 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); if (showEXP) { - builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}(突破进度:{LevelBreak + 1} / {General.GameplayEquilibriumConstant.LevelBreakList.Count})"); - builder.AppendLine($"经验值:{EXP}{(Level != General.GameplayEquilibriumConstant.MaxLevel && General.GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) ? " / " + need : "")}"); + builder.AppendLine($"等级:{Level} / {GameplayEquilibriumConstant.MaxLevel}(突破进度:{LevelBreak + 1} / {GameplayEquilibriumConstant.LevelBreakList.Count})"); + builder.AppendLine($"经验值:{EXP}{(Level != GameplayEquilibriumConstant.MaxLevel && GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) ? " / " + need : "")}"); } double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : "")); - builder.AppendLine($"能量值:{EP:0.##} / {General.GameplayEquilibriumConstant.MaxEP:0.##}"); + builder.AppendLine($"能量值:{EP:0.##} / {GameplayEquilibriumConstant.MaxEP:0.##}"); double exATK = ExATK + ExATK2 + ExATK3; builder.AppendLine($"攻击力:{ATK:0.##}" + (exATK != 0 ? $" [{BaseATK:0.##} {(exATK >= 0 ? "+" : "-")} {Math.Abs(exATK):0.##}]" : "")); double exDEF = ExDEF + ExDEF2 + ExDEF3; @@ -1466,7 +1470,7 @@ namespace Milimoe.FunGame.Core.Entity } else { - double exSPD = AGI * General.GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; + double exSPD = AGI * GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; builder.AppendLine($"行动速度:{SPD:0.##}" + (exSPD != 0 ? $" [{InitialSPD:0.##} {(exSPD >= 0 ? "+" : "-")} {Math.Abs(exSPD):0.##}]" : "") + $" ({ActionCoefficient * 100:0.##}%)"); builder.AppendLine($"核心属性:{CharacterSet.GetPrimaryAttributeName(PrimaryAttribute)}"); double exSTR = ExSTR + ExSTR2; @@ -1476,8 +1480,8 @@ namespace Milimoe.FunGame.Core.Entity double exINT = ExINT + ExINT2; builder.AppendLine($"智力:{INT:0.##}" + (exINT != 0 ? $" [{BaseINT:0.##} {(exINT >= 0 ? "+" : "-")} {Math.Abs(exINT):0.##}]" : "") + (showGrowth ? $"({(INTGrowth >= 0 ? "+" : "-")}{Math.Abs(INTGrowth)}/Lv)" : "")); } - builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * General.GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); - builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * General.GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); + builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); + builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); if (!showBasicOnly) { @@ -1557,7 +1561,7 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : "")); - builder.AppendLine($"能量值:{EP:0.##} / {General.GameplayEquilibriumConstant.MaxEP:0.##}"); + builder.AppendLine($"能量值:{EP:0.##} / {GameplayEquilibriumConstant.MaxEP:0.##}"); double exATK = ExATK + ExATK2 + ExATK3; builder.AppendLine($"攻击力:{ATK:0.##}" + (exATK != 0 ? $" [{BaseATK:0.##} {(exATK >= 0 ? "+" : "-")} {Math.Abs(exATK):0.##}]" : "")); builder.AppendLine($"核心属性:{PrimaryAttributeValue:0.##}" + (ExPrimaryAttributeValue != 0 ? $" [{BasePrimaryAttributeValue:0.##} {(ExPrimaryAttributeValue >= 0 ? "+" : "-")} {Math.Abs(ExPrimaryAttributeValue):0.##}]" : "")); @@ -1605,7 +1609,7 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : "")); - builder.AppendLine($"能量值:{EP:0.##} / {General.GameplayEquilibriumConstant.MaxEP:0.##}"); + builder.AppendLine($"能量值:{EP:0.##} / {GameplayEquilibriumConstant.MaxEP:0.##}"); double exATK = ExATK + ExATK2 + ExATK3; builder.AppendLine($"攻击力:{ATK:0.##}" + (exATK != 0 ? $" [{BaseATK:0.##} {(exATK >= 0 ? "+" : "-")} {Math.Abs(exATK):0.##}]" : "")); builder.AppendLine($"核心属性:{PrimaryAttributeValue:0.##}" + (ExPrimaryAttributeValue != 0 ? $" [{BasePrimaryAttributeValue:0.##} {(ExPrimaryAttributeValue >= 0 ? "+" : "-")} {Math.Abs(ExPrimaryAttributeValue):0.##}]" : "")); @@ -1680,14 +1684,14 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); if (showEXP) { - builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}(突破进度:{LevelBreak + 1} / {General.GameplayEquilibriumConstant.LevelBreakList.Count})"); - builder.AppendLine($"经验值:{EXP}{(Level != General.GameplayEquilibriumConstant.MaxLevel && General.GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) ? " / " + need : "")}"); + builder.AppendLine($"等级:{Level} / {GameplayEquilibriumConstant.MaxLevel}(突破进度:{LevelBreak + 1} / {GameplayEquilibriumConstant.LevelBreakList.Count})"); + builder.AppendLine($"经验值:{EXP}{(Level != GameplayEquilibriumConstant.MaxLevel && GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(Level, out double need) ? " / " + need : "")}"); } double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : "")); - builder.AppendLine($"能量值:{EP:0.##} / {General.GameplayEquilibriumConstant.MaxEP:0.##}"); + builder.AppendLine($"能量值:{EP:0.##} / {GameplayEquilibriumConstant.MaxEP:0.##}"); double exATK = ExATK + ExATK2 + ExATK3; builder.AppendLine($"攻击力:{ATK:0.##}" + (exATK != 0 ? $" [{BaseATK:0.##} {(exATK >= 0 ? "+" : "-")} {Math.Abs(exATK):0.##}]" : "")); double exDEF = ExDEF + ExDEF2 + ExDEF3; @@ -1696,7 +1700,7 @@ namespace Milimoe.FunGame.Core.Entity MDF.Bright + MDF.Shadow + MDF.Element + MDF.Fleabane + MDF.Particle) / 9) * 100; if (Calculation.IsApproximatelyZero(mdf)) mdf = 0; builder.AppendLine($"魔法抗性:{mdf:0.##}%(平均)"); - double exSPD = AGI * General.GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; + double exSPD = AGI * GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; builder.AppendLine($"行动速度:{SPD:0.##}" + (exSPD != 0 ? $" [{InitialSPD:0.##} {(exSPD >= 0 ? "+" : "-")} {Math.Abs(exSPD):0.##}]" : "") + $" ({ActionCoefficient * 100:0.##}%)"); builder.AppendLine($"核心属性:{CharacterSet.GetPrimaryAttributeName(PrimaryAttribute)}"); double exSTR = ExSTR + ExSTR2; @@ -1705,8 +1709,8 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine($"敏捷:{AGI:0.##}" + (exAGI != 0 ? $" [{BaseAGI:0.##} {(exAGI >= 0 ? "+" : "-")} {Math.Abs(exAGI):0.##}]" : "") + (showGrowth ? $"({(AGIGrowth >= 0 ? "+" : "-")}{Math.Abs(AGIGrowth)}/Lv)" : "")); double exINT = ExINT + ExINT2; builder.AppendLine($"智力:{INT:0.##}" + (exINT != 0 ? $" [{BaseINT:0.##} {(exINT >= 0 ? "+" : "-")} {Math.Abs(exINT):0.##}]" : "") + (showGrowth ? $"({(INTGrowth >= 0 ? "+" : "-")}{Math.Abs(INTGrowth)}/Lv)" : "")); - builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * General.GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); - builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * General.GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); + builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); + builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); builder.AppendLine($"暴击率:{CritRate * 100:0.##}%"); builder.AppendLine($"暴击伤害:{CritDMG * 100:0.##}%"); builder.AppendLine($"闪避率:{EvadeRate * 100:0.##}%"); @@ -1714,8 +1718,8 @@ namespace Milimoe.FunGame.Core.Entity builder.AppendLine($"加速系数:{AccelerationCoefficient * 100:0.##}%"); builder.AppendLine($"物理穿透:{PhysicalPenetration * 100:0.##}%"); builder.AppendLine($"魔法穿透:{MagicalPenetration * 100:0.##}%"); - builder.AppendLine($"魔法消耗减少:{INT * General.GameplayEquilibriumConstant.INTtoCastMPReduce * 100:0.##}%"); - builder.AppendLine($"能量消耗减少:{INT * General.GameplayEquilibriumConstant.INTtoCastEPReduce * 100:0.##}%"); + builder.AppendLine($"魔法消耗减少:{INT * GameplayEquilibriumConstant.INTtoCastMPReduce * 100:0.##}%"); + builder.AppendLine($"能量消耗减少:{INT * GameplayEquilibriumConstant.INTtoCastEPReduce * 100:0.##}%"); if (EquipSlot.Any()) { @@ -1915,8 +1919,8 @@ namespace Milimoe.FunGame.Core.Entity Item? s = UnEquip(EquipSlotType.Shoes); Item? ac1 = UnEquip(EquipSlotType.Accessory1); Item? ac2 = UnEquip(EquipSlotType.Accessory2); - List skills = new(Skills); - List items = new(Items); + List skills = [.. Skills]; + List items = [.. Items]; Character c = original.Copy(); List effects = [.. Effects]; foreach (Effect e in effects) diff --git a/Entity/Character/Unit.cs b/Entity/Character/Unit.cs index 26bb4eb..76f9fc8 100644 --- a/Entity/Character/Unit.cs +++ b/Entity/Character/Unit.cs @@ -52,7 +52,7 @@ namespace Milimoe.FunGame.Core.Entity StringBuilder builder = new(); builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); - builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}"); + builder.AppendLine($"等级:{Level} / {GameplayEquilibriumConstant.MaxLevel}"); double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; @@ -65,10 +65,10 @@ namespace Milimoe.FunGame.Core.Entity MDF.Bright + MDF.Shadow + MDF.Element + MDF.Fleabane + MDF.Particle) / 9) * 100; if (Calculation.IsApproximatelyZero(mdf)) mdf = 0; builder.AppendLine($"魔法抗性:{mdf:0.##}%(平均)"); - double exSPD = AGI * General.GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; + double exSPD = AGI * GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; builder.AppendLine($"行动速度:{SPD:0.##}" + (exSPD != 0 ? $" [{InitialSPD:0.##} {(exSPD >= 0 ? "+" : "-")} {Math.Abs(exSPD):0.##}]" : "") + $" ({ActionCoefficient * 100:0.##}%)"); - builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * General.GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); - builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * General.GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); + builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); + builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); builder.AppendLine($"暴击率:{CritRate * 100:0.##}%"); builder.AppendLine($"暴击伤害:{CritDMG * 100:0.##}%"); builder.AppendLine($"闪避率:{EvadeRate * 100:0.##}%"); @@ -177,7 +177,7 @@ namespace Milimoe.FunGame.Core.Entity StringBuilder builder = new(); builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); - builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}"); + builder.AppendLine($"等级:{Level} / {GameplayEquilibriumConstant.MaxLevel}"); double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; @@ -190,10 +190,10 @@ namespace Milimoe.FunGame.Core.Entity MDF.Bright + MDF.Shadow + MDF.Element + MDF.Fleabane + MDF.Particle) / 9) * 100; if (Calculation.IsApproximatelyZero(mdf)) mdf = 0; builder.AppendLine($"魔法抗性:{mdf:0.##}%(平均)"); - double exSPD = AGI * General.GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; + double exSPD = AGI * GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; builder.AppendLine($"行动速度:{SPD:0.##}" + (exSPD != 0 ? $" [{InitialSPD:0.##} {(exSPD >= 0 ? "+" : "-")} {Math.Abs(exSPD):0.##}]" : "") + $" ({ActionCoefficient * 100:0.##}%)"); - builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * General.GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); - builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * General.GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); + builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); + builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); if (!showBasicOnly) { @@ -398,7 +398,7 @@ namespace Milimoe.FunGame.Core.Entity StringBuilder builder = new(); builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); - builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}"); + builder.AppendLine($"等级:{Level} / {GameplayEquilibriumConstant.MaxLevel}"); double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; @@ -411,10 +411,10 @@ namespace Milimoe.FunGame.Core.Entity MDF.Bright + MDF.Shadow + MDF.Element + MDF.Fleabane + MDF.Particle) / 9) * 100; if (Calculation.IsApproximatelyZero(mdf)) mdf = 0; builder.AppendLine($"魔法抗性:{mdf:0.##}%(平均)"); - double exSPD = AGI * General.GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; + double exSPD = AGI * GameplayEquilibriumConstant.AGItoSPDMultiplier + ExSPD; builder.AppendLine($"行动速度:{SPD:0.##}" + (exSPD != 0 ? $" [{InitialSPD:0.##} {(exSPD >= 0 ? "+" : "-")} {Math.Abs(exSPD):0.##}]" : "") + $" ({ActionCoefficient * 100:0.##}%)"); - builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * General.GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); - builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * General.GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); + builder.AppendLine($"生命回复:{HR:0.##}" + (ExHR != 0 ? $" [{InitialHR + STR * GameplayEquilibriumConstant.STRtoHRFactor:0.##} {(ExHR >= 0 ? "+" : "-")} {Math.Abs(ExHR):0.##}]" : "")); + builder.AppendLine($"魔法回复:{MR:0.##}" + (ExMR != 0 ? $" [{InitialMR + INT * GameplayEquilibriumConstant.INTtoMRFactor:0.##} {(ExMR >= 0 ? "+" : "-")} {Math.Abs(ExMR):0.##}]" : "")); builder.AppendLine($"暴击率:{CritRate * 100:0.##}%"); builder.AppendLine($"暴击伤害:{CritDMG * 100:0.##}%"); builder.AppendLine($"闪避率:{EvadeRate * 100:0.##}%"); diff --git a/Entity/Item/Item.cs b/Entity/Item/Item.cs index 43d6697..2e07bda 100644 --- a/Entity/Item/Item.cs +++ b/Entity/Item/Item.cs @@ -248,7 +248,7 @@ namespace Milimoe.FunGame.Core.Entity { foreach (Skill skill in Skills.Passives) { - List effects = Character.Effects.Where(e => e.Skill == skill && e.Level > 0).ToList(); + List effects = [.. Character.Effects.Where(e => e.Skill == skill && e.Level > 0)]; foreach (Effect e in effects) { Character.Effects.Remove(e); @@ -304,7 +304,7 @@ namespace Milimoe.FunGame.Core.Entity } /// - /// 局内使用物品触发 对某个角色使用 + /// 局内使用物品触发 /// /// public bool UseItem(IGamingQueue queue, Character character, List enemys, List teammates) @@ -318,13 +318,7 @@ namespace Milimoe.FunGame.Core.Entity } if (result && Skills.Active != null) { - Skill skill = Skills.Active; - List targets = queue.SelectTargets(character, skill, enemys, teammates, out cancel); - if (!cancel) - { - skill.OnSkillCasted(queue, character, targets); - used = true; - } + used = queue.UseItem(this, character, enemys, teammates); } if (used) { @@ -332,7 +326,7 @@ namespace Milimoe.FunGame.Core.Entity } return result && used; } - + /// /// 局外(库存)使用物品触发 /// @@ -448,11 +442,11 @@ namespace Milimoe.FunGame.Core.Entity if (isShowInStore && Price > 0) { - builder.AppendLine($"售价:{Price} {General.GameplayEquilibriumConstant.InGameCurrency}"); + builder.AppendLine($"售价:{Price} {GameplayEquilibriumConstant.InGameCurrency}"); } else if (Price > 0) { - builder.AppendLine($"回收价:{Price} {General.GameplayEquilibriumConstant.InGameCurrency}"); + builder.AppendLine($"回收价:{Price} {GameplayEquilibriumConstant.InGameCurrency}"); } if (RemainUseTimes > 0) diff --git a/Entity/Skill/NormalAttack.cs b/Entity/Skill/NormalAttack.cs index de6b497..8089464 100644 --- a/Entity/Skill/NormalAttack.cs +++ b/Entity/Skill/NormalAttack.cs @@ -38,7 +38,7 @@ namespace Milimoe.FunGame.Core.Entity } set { - _Level = Math.Min(Math.Max(1, value), General.GameplayEquilibriumConstant.MaxNormalAttackLevel); + _Level = Math.Min(Math.Max(1, value), GameplayEquilibriumConstant.MaxNormalAttackLevel); } } @@ -63,7 +63,7 @@ namespace Milimoe.FunGame.Core.Entity /// /// /// - public void Attack(IGamingQueue queue, Character attacker, params Character[] enemys) + public void Attack(IGamingQueue queue, Character attacker, params IEnumerable enemys) { foreach (Character enemy in enemys) { diff --git a/Entity/Skill/Skill.cs b/Entity/Skill/Skill.cs index 5c11e7e..84a78f4 100644 --- a/Entity/Skill/Skill.cs +++ b/Entity/Skill/Skill.cs @@ -48,7 +48,7 @@ namespace Milimoe.FunGame.Core.Entity } set { - int max = SkillSet.GetSkillMaxLevel(SkillType); + int max = SkillSet.GetSkillMaxLevel(SkillType, GameplayEquilibriumConstant); _Level = Math.Min(Math.Max(0, value), max); OnLevelUp(); } @@ -126,7 +126,7 @@ namespace Milimoe.FunGame.Core.Entity /// /// 实际魔法消耗 [ 魔法 ] /// - public double RealMPCost => Math.Max(0, MPCost * (1 - Calculation.PercentageCheck((Character?.INT ?? 0) * General.GameplayEquilibriumConstant.INTtoCastMPReduce))); + public double RealMPCost => Math.Max(0, MPCost * (1 - Calculation.PercentageCheck((Character?.INT ?? 0) * GameplayEquilibriumConstant.INTtoCastMPReduce))); /// /// 魔法消耗 [ 魔法 ] @@ -148,7 +148,7 @@ namespace Milimoe.FunGame.Core.Entity /// /// 实际能量消耗 [ 战技 ] /// - public double RealEPCost => CostAllEP ? Math.Max(MinCostEP, Character?.EP ?? MinCostEP) : (IsSuperSkill ? EPCost : Math.Max(0, EPCost * (1 - Calculation.PercentageCheck((Character?.INT ?? 0) * General.GameplayEquilibriumConstant.INTtoCastEPReduce)))); + public double RealEPCost => CostAllEP ? Math.Max(MinCostEP, Character?.EP ?? MinCostEP) : (IsSuperSkill ? EPCost : Math.Max(0, EPCost * (1 - Calculation.PercentageCheck((Character?.INT ?? 0) * GameplayEquilibriumConstant.INTtoCastEPReduce)))); /// /// 能量消耗 [ 战技 ] diff --git a/Entity/System/Inventory.cs b/Entity/System/Inventory.cs index 322ba49..7de60f0 100644 --- a/Entity/System/Inventory.cs +++ b/Entity/System/Inventory.cs @@ -1,21 +1,22 @@ using System.Text; using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Model; namespace Milimoe.FunGame.Core.Entity { - public class Inventory + public class Inventory : BaseEntity { /// /// 库存 ID 与用户 ID 绑定 /// - public long Id => User.Id; + public override long Id => User.Id; /// /// 库存的名称,默认为 “的库存”;可更改 /// - public string Name + public override string Name { get { @@ -105,8 +106,8 @@ namespace Milimoe.FunGame.Core.Entity StringBuilder builder = new(); builder.AppendLine($"☆★☆ {Name} ☆★☆"); - builder.AppendLine($"{General.GameplayEquilibriumConstant.InGameCurrency}:{Credits:0.00}"); - builder.AppendLine($"{General.GameplayEquilibriumConstant.InGameMaterial}:{Materials:0.00}"); + builder.AppendLine($"{GameplayEquilibriumConstant.InGameCurrency}:{Credits:0.00}"); + builder.AppendLine($"{GameplayEquilibriumConstant.InGameMaterial}:{Materials:0.00}"); builder.AppendLine($"======= 角色 ======="); Character[] characters = [.. Characters]; @@ -143,5 +144,10 @@ namespace Milimoe.FunGame.Core.Entity return builder.ToString(); } + + public override bool Equals(IBaseEntity? other) + { + return other is Inventory && other.GetIdName() == GetIdName(); + } } } diff --git a/Entity/System/Quest.cs b/Entity/System/Quest.cs index 1d225ac..5a7c2a1 100644 --- a/Entity/System/Quest.cs +++ b/Entity/System/Quest.cs @@ -20,11 +20,11 @@ namespace Milimoe.FunGame.Core.Entity List awards = []; if (CreditsAward > 0) { - awards.Add($"{General.GameplayEquilibriumConstant.InGameCurrency} * {CreditsAward}"); + awards.Add($"{GameplayEquilibriumConstant.InGameCurrency} * {CreditsAward}"); } if (MaterialsAward > 0) { - awards.Add($"{General.GameplayEquilibriumConstant.InGameMaterial} * {MaterialsAward}"); + awards.Add($"{GameplayEquilibriumConstant.InGameMaterial} * {MaterialsAward}"); } foreach (Item item in Awards) { diff --git a/Entity/System/Store.cs b/Entity/System/Store.cs index 567ea12..65485d1 100644 --- a/Entity/System/Store.cs +++ b/Entity/System/Store.cs @@ -62,7 +62,7 @@ namespace Milimoe.FunGame.Core.Entity description = item.Description; } Goods goods = new(id, item, stock, name, description); - goods.SetPrice(General.GameplayEquilibriumConstant.InGameCurrency, item.Price); + goods.SetPrice(GameplayEquilibriumConstant.InGameCurrency, item.Price); Goods.Add(id, goods); } @@ -97,7 +97,7 @@ namespace Milimoe.FunGame.Core.Entity double price = 0; if (Goods.TryGetValue(id, out Goods? goods) && goods != null) { - goods.GetPrice(General.GameplayEquilibriumConstant.InGameCurrency, out price); + goods.GetPrice(GameplayEquilibriumConstant.InGameCurrency, out price); } return price; } diff --git a/Interface/Base/IGamingQueue.cs b/Interface/Base/IGamingQueue.cs index 7443523..160a236 100644 --- a/Interface/Base/IGamingQueue.cs +++ b/Interface/Base/IGamingQueue.cs @@ -1,5 +1,6 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; +using Milimoe.FunGame.Core.Model; namespace Milimoe.FunGame.Core.Interface.Base { @@ -8,6 +9,11 @@ namespace Milimoe.FunGame.Core.Interface.Base /// public interface IGamingQueue { + /// + /// 使用的游戏平衡常数 + /// + public EquilibriumConstant GameplayEquilibriumConstant { get; } + /// /// 用于文本输出 /// @@ -124,6 +130,16 @@ namespace Milimoe.FunGame.Core.Interface.Base /// public void InterruptCasting(Character caster, Character interrupter); + /// + /// 使用物品 + /// + /// + /// + /// + /// + /// + public bool UseItem(Item item, Character caster, List enemys, List teammates); + /// /// 选取技能目标 /// @@ -131,9 +147,8 @@ namespace Milimoe.FunGame.Core.Interface.Base /// /// /// - /// /// - public List SelectTargets(Character caster, Skill skill, List enemys, List teammates, out bool cancel); + public List SelectTargets(Character caster, Skill skill, List enemys, List teammates); /// /// 选取普通攻击目标 @@ -142,8 +157,7 @@ namespace Milimoe.FunGame.Core.Interface.Base /// /// /// - /// /// - public List SelectTargets(Character character, NormalAttack attack, List enemys, List teammates, out bool cancel); + public List SelectTargets(Character character, NormalAttack attack, List enemys, List teammates); } } diff --git a/Library/Constant/ConstantSet.cs b/Library/Constant/ConstantSet.cs index 9f9dd2a..9f06bf7 100644 --- a/Library/Constant/ConstantSet.cs +++ b/Library/Constant/ConstantSet.cs @@ -1,4 +1,7 @@ -/** + +using Milimoe.FunGame.Core.Model; + +/** * 此文件用于保存字符串常量(String Set) */ namespace Milimoe.FunGame.Core.Library.Constant @@ -619,15 +622,16 @@ namespace Milimoe.FunGame.Core.Library.Constant }; } - public static int GetSkillMaxLevel(SkillType type) + public static int GetSkillMaxLevel(SkillType type, EquilibriumConstant? gameplayConstant = null) { + gameplayConstant ??= General.GameplayEquilibriumConstant; return type switch { - SkillType.Magic => General.GameplayEquilibriumConstant.MaxMagicLevel, - SkillType.Skill => General.GameplayEquilibriumConstant.MaxSkillLevel, - SkillType.SuperSkill => General.GameplayEquilibriumConstant.MaxSuperSkillLevel, - SkillType.Item => General.GameplayEquilibriumConstant.MaxSkillLevel, - _ => General.GameplayEquilibriumConstant.MaxPassiveSkillLevel + SkillType.Magic => gameplayConstant.MaxMagicLevel, + SkillType.Skill => gameplayConstant.MaxSkillLevel, + SkillType.SuperSkill => gameplayConstant.MaxSuperSkillLevel, + SkillType.Item => gameplayConstant.MaxSkillLevel, + _ => gameplayConstant.MaxPassiveSkillLevel }; } diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs index aa9e895..eb95d71 100644 --- a/Library/Constant/TypeEnum.cs +++ b/Library/Constant/TypeEnum.cs @@ -680,7 +680,8 @@ namespace Milimoe.FunGame.Core.Library.Constant PreCastSkill, CastSkill, CastSuperSkill, - UseItem + UseItem, + EndTurn } public enum VerifyCodeType diff --git a/Model/ActionQueue.cs b/Model/ActionQueue.cs index 80a6c04..e01da10 100644 --- a/Model/ActionQueue.cs +++ b/Model/ActionQueue.cs @@ -10,6 +10,11 @@ namespace Milimoe.FunGame.Core.Model /// public class ActionQueue : IGamingQueue { + /// + /// 使用的游戏平衡常数 + /// + public EquilibriumConstant GameplayEquilibriumConstant { get; } = General.GameplayEquilibriumConstant; + /// /// 用于文本输出 /// @@ -35,6 +40,11 @@ namespace Milimoe.FunGame.Core.Model /// public List EliminatedTeams => _eliminatedTeams; + /// + /// 角色是否在 AI 控制下 + /// + public HashSet CharactersInAI => _charactersInAI; + /// /// 角色数据 /// @@ -113,13 +123,18 @@ namespace Milimoe.FunGame.Core.Model /// protected readonly List _eliminatedTeams = []; + /// + /// 角色是否在 AI 控制下 + /// + protected readonly HashSet _charactersInAI = []; + /// /// 硬直时间表 /// protected readonly Dictionary _hardnessTimes = []; /// - /// 角色正在吟唱的魔法 + /// 角色正在吟唱的技能(通常是魔法) /// protected readonly Dictionary _castingSkills = []; @@ -128,6 +143,11 @@ namespace Milimoe.FunGame.Core.Model /// protected readonly Dictionary _castingSuperSkills = []; + /// + /// 角色即将使用的物品 + /// + protected readonly Dictionary _willUseItems = []; + /// /// 角色目前赚取的金钱 /// @@ -332,10 +352,12 @@ namespace Milimoe.FunGame.Core.Model _cutCount.Clear(); _castingSkills.Clear(); _castingSuperSkills.Clear(); + _willUseItems.Clear(); _maxContinuousKilling.Clear(); _continuousKilling.Clear(); _earnedMoney.Clear(); _eliminated.Clear(); + _charactersInAI.Clear(); } /// @@ -413,7 +435,7 @@ namespace Milimoe.FunGame.Core.Model if (isCheckProtected) { // 查找保护条件 被插队超过此次数便能获得插队补偿 即行动保护 - int countProtected = _queue.Count; + int countProtected = Math.Max(5, _queue.Count); // 查找队列中是否有满足插队补偿条件的角色(最后一个) var list = _queue @@ -564,6 +586,12 @@ namespace Milimoe.FunGame.Core.Model List items = [.. character.Items.Where(i => i.IsActive && i.Skills.Active != null && i.Enable && i.IsInGameItem && i.Skills.Active.SkillType == SkillType.Item && i.Skills.Active.Enable && !i.Skills.Active.IsInEffect && i.Skills.Active.CurrentCD == 0 && i.Skills.Active.RealMPCost <= character.MP && i.Skills.Active.RealEPCost <= character.EP)]; + // 回合开始事件,允许事件返回 false 接管回合操作 + if (!OnTurnStart(character, enemys, teammates, skills, items)) + { + return _isGameEnd; + } + // 此变量用于在取消选择时,能够重新行动 bool decided = false; // 最大取消次数 @@ -714,10 +742,15 @@ namespace Milimoe.FunGame.Core.Model if (type == CharacterActionType.NormalAttack) { // 使用普通攻击逻辑 - Character[] targets = [.. SelectTargets(character, character.NormalAttack, enemys, teammates, out bool cancel)]; - LastRound.Targets = [.. targets]; - if (!cancel) + List targets = SelectTargets(character, character.NormalAttack, enemys, teammates); + if (targets.Count == 0 && _charactersInAI.Contains(character) && enemys.Count > 0) { + // 如果没有选取目标,且角色在 AI 控制下,则随机选取一个目标 + targets = [enemys[Random.Shared.Next(enemys.Count)]]; + } + if (targets.Count > 0) + { + LastRound.Targets = [.. targets]; decided = true; character.NormalAttack.Attack(this, character, targets); baseTime = character.NormalAttack.HardnessTime; @@ -731,50 +764,68 @@ namespace Milimoe.FunGame.Core.Model else if (type == CharacterActionType.PreCastSkill) { // 预使用技能,即开始吟唱逻辑 - // 吟唱前需要先选取目标 - Skill skill = skills[Random.Shared.Next(skills.Count)]; - if (skill.SkillType == SkillType.Magic) + Skill? skill = OnSelectSkill(character, skills); + if (_charactersInAI.Contains(character)) { - List targets = SelectTargets(character, skill, enemys, teammates, out bool cancel); - LastRound.Targets = [.. targets]; - if (!cancel) - { - decided = true; - character.CharacterState = CharacterState.Casting; - _castingSkills.Add(character, new(skill, targets)); - baseTime = skill.CastTime; - skill.OnSkillCasting(this, character, targets); - } + skill = skills[Random.Shared.Next(skills.Count)]; } - else + if (skill != null) { - if (CheckCanCast(character, skill, out double cost)) + // 吟唱前需要先选取目标 + if (skill.SkillType == SkillType.Magic) { - List targets = SelectTargets(character, skill, enemys, teammates, out bool cancel); - LastRound.Targets = [.. targets]; - if (!cancel) + List targets = SelectTargets(character, skill, enemys, teammates); + if (targets.Count == 0 && _charactersInAI.Contains(character) && enemys.Count > 0) { + // 如果没有选取目标,且角色在 AI 控制下,则随机选取一个目标 + targets = [enemys[Random.Shared.Next(enemys.Count)]]; + } + if (targets.Count > 0) + { + LastRound.Targets = [.. targets]; decided = true; + character.CharacterState = CharacterState.Casting; + _castingSkills.Add(character, new(skill, targets)); + baseTime = skill.CastTime; skill.OnSkillCasting(this, character, targets); - skill.BeforeSkillCasted(); - - character.EP -= cost; - baseTime = skill.HardnessTime; - skill.CurrentCD = skill.RealCD; - skill.Enable = false; - LastRound.SkillCost = $"{-cost:0.##} EP"; - - WriteLine("[ " + character + $" ] 消耗了 {cost:0.##} 点能量,释放了{(skill.IsSuperSkill ? "爆发技" : "战技")} [ {skill.Name} ]!{(skill.Slogan != "" ? skill.Slogan : "")}"); - skill.OnSkillCasted(this, character, targets); - effects = [.. character.Effects.Where(e => e.Level > 0)]; - foreach (Effect effect in effects) + } + } + else + { + // 只有魔法需要吟唱,战技和爆发技直接释放 + if (CheckCanCast(character, skill, out double cost)) + { + List targets = SelectTargets(character, skill, enemys, teammates); + if (targets.Count == 0 && _charactersInAI.Contains(character) && enemys.Count > 0) { - effect.AlterHardnessTimeAfterCastSkill(character, skill, ref baseTime, ref isCheckProtected); + // 如果没有选取目标,且角色在 AI 控制下,则随机选取一个目标 + targets = [enemys[Random.Shared.Next(enemys.Count)]]; + } + if (targets.Count > 0) + { + LastRound.Targets = [.. targets]; + decided = true; + skill.OnSkillCasting(this, character, targets); + skill.BeforeSkillCasted(); + + character.EP -= cost; + baseTime = skill.HardnessTime; + skill.CurrentCD = skill.RealCD; + skill.Enable = false; + LastRound.SkillCost = $"{-cost:0.##} EP"; + + WriteLine("[ " + character + $" ] 消耗了 {cost:0.##} 点能量,释放了{(skill.IsSuperSkill ? "爆发技" : "战技")} [ {skill.Name} ]!{(skill.Slogan != "" ? skill.Slogan : "")}"); + skill.OnSkillCasted(this, character, targets); + effects = [.. character.Effects.Where(e => e.Level > 0)]; + foreach (Effect effect in effects) + { + effect.AlterHardnessTimeAfterCastSkill(character, skill, ref baseTime, ref isCheckProtected); + } } } } + LastRound.Skill = skill; } - LastRound.Skill = skill; } else if (type == CharacterActionType.CastSkill) { @@ -828,7 +879,7 @@ namespace Milimoe.FunGame.Core.Model if (CheckCanCast(character, skill, out double cost)) { // 预释放的爆发技不可取消 - List targets = SelectTargets(character, skill, enemys, teammates, out _); + List targets = SelectTargets(character, skill, enemys, teammates); LastRound.Targets = [.. targets]; skill.BeforeSkillCasted(); @@ -858,6 +909,22 @@ namespace Milimoe.FunGame.Core.Model else if (type == CharacterActionType.UseItem) { // 使用物品逻辑 + Item? item = OnSelectItem(character, items); + if (item != null && item.Skills.Active != null) + { + Skill skill = item.Skills.Active; + if (UseItem(item, character, enemys, teammates)) + { + decided = true; + LastRound.Item = item; + baseTime = skill.HardnessTime; + effects = [.. character.Effects.Where(e => e.Level > 0)]; + foreach (Effect effect in effects) + { + effect.AlterHardnessTimeAfterCastSkill(character, skill, ref baseTime, ref isCheckProtected); + } + } + } } } @@ -881,20 +948,17 @@ namespace Milimoe.FunGame.Core.Model if (character.CharacterState != CharacterState.Casting) { newHardnessTime = Math.Max(0, Calculation.Round2Digits(baseTime * (1 - character.ActionCoefficient))); - WriteLine("[ " + character + " ] 回合结束,获得硬直时间: " + newHardnessTime); + WriteLine($"[ {character} ] 回合结束,获得硬直时间:{newHardnessTime} {GameplayEquilibriumConstant.InGameTime}"); } else { newHardnessTime = Math.Max(0, Calculation.Round2Digits(baseTime * (1 - character.AccelerationCoefficient))); - WriteLine("[ " + character + " ] 进行吟唱,持续时间: " + newHardnessTime); + WriteLine($"[ {character} ] 进行吟唱,持续时间:{newHardnessTime} {GameplayEquilibriumConstant.InGameTime}"); LastRound.CastTime = newHardnessTime; } AddCharacter(character, newHardnessTime, isCheckProtected); LastRound.HardnessTime = newHardnessTime; - // 有人想要插队吗? - WillPreCastSuperSkill(character); - effects = [.. character.Effects.Where(e => e.Level > 0)]; foreach (Effect effect in effects) { @@ -920,6 +984,12 @@ namespace Milimoe.FunGame.Core.Model } } + // 有人想要插队吗? + WillPreCastSuperSkill(character); + + // 回合结束事件 + OnTurnEnd(character); + AfterTurn(character); WriteLine(""); @@ -966,7 +1036,7 @@ namespace Milimoe.FunGame.Core.Model { double hardnessTime = 5; character.Respawn(_original[character.Guid]); - WriteLine($"[ {character} ] 已复活!获得 {hardnessTime} 硬直时间。"); + WriteLine($"[ {character} ] 已复活!获得 {hardnessTime} {GameplayEquilibriumConstant.InGameTime}的硬直时间。"); AddCharacter(character, hardnessTime, false); LastRound.Respawns.Add(character); _respawnCountdown.Remove(character); @@ -1119,14 +1189,14 @@ namespace Milimoe.FunGame.Core.Model _assistDamage[actor][enemy] += damage; // 造成伤害和受伤都可以获得能量 - double ep = GetEP(damage, 0.03, 30); + double ep = GetEP(damage, GameplayEquilibriumConstant.DamageGetEPFactor, GameplayEquilibriumConstant.DamageGetEPMax); effects = [.. actor.Effects]; foreach (Effect effect in effects) { effect.AlterEPAfterDamage(actor, ref ep); } actor.EP += ep; - ep = GetEP(damage, 0.015, 15); + ep = GetEP(damage, GameplayEquilibriumConstant.TakenDamageGetEPFactor, GameplayEquilibriumConstant.TakenDamageGetEPMax); effects = [.. enemy.Effects.Where(e => e.Level > 0)]; foreach (Effect effect in effects) { @@ -1276,7 +1346,7 @@ namespace Milimoe.FunGame.Core.Model double penetratedDEF = (1 - actor.PhysicalPenetration) * enemy.DEF; // 物理伤害减免 - double physicalDamageReduction = penetratedDEF / (penetratedDEF + General.GameplayEquilibriumConstant.DEFReductionFactor); + double physicalDamageReduction = penetratedDEF / (penetratedDEF + GameplayEquilibriumConstant.DEFReductionFactor); // 最终的物理伤害 finalDamage = expectedDamage * (1 - Calculation.PercentageCheck(physicalDamageReduction + enemy.ExPDR)); @@ -1551,7 +1621,7 @@ namespace Milimoe.FunGame.Core.Model { money += (coefficient + 1) * Random.Shared.Next(50, 100); string termination = CharacterSet.GetContinuousKilling(coefficient); - string msg = $"[ {killer} ] 终结了 [ {death} ]{(termination != "" ? " 的" + termination : "")},获得 {money} {General.GameplayEquilibriumConstant.InGameCurrency}!"; + string msg = $"[ {killer} ] 终结了 [ {death} ]{(termination != "" ? " 的" + termination : "")},获得 {money} {GameplayEquilibriumConstant.InGameCurrency}!"; LastRound.DeathContinuousKilling.Add(msg); if (assists.Length > 1) { @@ -1561,7 +1631,7 @@ namespace Milimoe.FunGame.Core.Model } else { - string msg = $"[ {killer} ] 杀死了 [ {death} ],获得 {money} {General.GameplayEquilibriumConstant.InGameCurrency}!"; + string msg = $"[ {killer} ] 杀死了 [ {death} ],获得 {money} {GameplayEquilibriumConstant.InGameCurrency}!"; LastRound.DeathContinuousKilling.Add(msg); if (assists.Length > 1) { @@ -1576,7 +1646,7 @@ namespace Milimoe.FunGame.Core.Model _stats[killer].FirstKills += 1; _stats[death].FirstDeaths += 1; money += 200; - WriteLine($"[ {killer} ] 拿下了第一滴血!额外奖励 200 {General.GameplayEquilibriumConstant.InGameCurrency}!!"); + WriteLine($"[ {killer} ] 拿下了第一滴血!额外奖励 200 {GameplayEquilibriumConstant.InGameCurrency}!!"); } int kills = _continuousKilling[killer]; @@ -1640,7 +1710,7 @@ namespace Milimoe.FunGame.Core.Model double respawnTime = Calculation.Round2Digits(Math.Min(90, death.Level * 0.15 + times * 2.77 + coefficient * Random.Shared.Next(1, 3))); _respawnCountdown.TryAdd(death, respawnTime); LastRound.RespawnCountdowns.TryAdd(death, respawnTime); - WriteLine($"[ {death} ] 进入复活倒计时:{respawnTime:0.##} 时间!"); + WriteLine($"[ {death} ] 进入复活倒计时:{respawnTime:0.##} {GameplayEquilibriumConstant.InGameTime}!"); } // 移除死者的施法 @@ -1659,7 +1729,7 @@ namespace Milimoe.FunGame.Core.Model { caster.CharacterState = CharacterState.Actionable; } - WriteLine($"[ {caster} ] 终止了 [ {st.Skill.Name} ] 的施法" + (_hardnessTimes[caster] > 3 ? ",并获得了 3 硬直时间的补偿。" : "。")); + WriteLine($"[ {caster} ] 终止了 [ {st.Skill.Name} ] 的施法" + (_hardnessTimes[caster] > 3 ? $",并获得了 3 {GameplayEquilibriumConstant.InGameTime}的硬直时间的补偿。" : "。")); if (_hardnessTimes[caster] > 3) { _hardnessTimes[caster] = 3; @@ -1686,7 +1756,7 @@ namespace Milimoe.FunGame.Core.Model string topCharacter = ec.ToString() + (statistics.FirstKills > 0 ? " [ 第一滴血 ]" : "") + (_maxContinuousKilling.TryGetValue(ec, out int kills) && kills > 1 ? $" [ {CharacterSet.GetContinuousKilling(kills)} ]" : "") + - (_earnedMoney.TryGetValue(ec, out int earned) ? $" [ 已赚取 {earned} {General.GameplayEquilibriumConstant.InGameCurrency} ]" : ""); + (_earnedMoney.TryGetValue(ec, out int earned) ? $" [ 已赚取 {earned} {GameplayEquilibriumConstant.InGameCurrency} ]" : ""); if (top == 1) { WriteLine("冠军:" + topCharacter); @@ -1762,13 +1832,13 @@ namespace Milimoe.FunGame.Core.Model string respawning = ""; if (ec.HP <= 0) { - respawning = "[ " + (_respawnCountdown.TryGetValue(ec, out double time) && time > 0 ? $"{time:0.##} 时间后复活" : "阵亡") + " ] "; + respawning = "[ " + (_respawnCountdown.TryGetValue(ec, out double time) && time > 0 ? $"{time:0.##} {GameplayEquilibriumConstant.InGameTime}后复活" : "阵亡") + " ] "; } string topCharacter = respawning + ec.ToString() + (statistics.FirstKills > 0 ? " [ 第一滴血 ]" : "") + (_maxContinuousKilling.TryGetValue(ec, out int kills) && kills > 1 ? $" [ {CharacterSet.GetContinuousKilling(kills)} ]" : "") + - (_earnedMoney.TryGetValue(ec, out int earned) ? $" [ 已赚取 {earned} {General.GameplayEquilibriumConstant.InGameCurrency} ]" : "") + + (_earnedMoney.TryGetValue(ec, out int earned) ? $" [ 已赚取 {earned} {GameplayEquilibriumConstant.InGameCurrency} ]" : "") + $"({statistics.Kills} / {statistics.Assists}{(MaxRespawnTimes != 0 ? " / " + statistics.Deaths : "")})"; topTeam += topCharacter + "\r\n"; if (top == 1) @@ -1836,16 +1906,57 @@ namespace Milimoe.FunGame.Core.Model } return false; } + + /// + /// 检查是否可以释放技能(物品版) + /// + /// + /// + /// + /// + /// + public bool CheckCanCast(Character caster, Item item, out double costMP, out double costEP) + { + Skill? skill = item.Skills.Active; + if (skill is null) + { + costMP = 0; + costEP = 0; + return false; + } + costMP = skill.RealMPCost; + costEP = skill.RealEPCost; + bool isMPOk = false; + bool isEPOk = false; + if (costMP > 0 && costMP <= caster.MP) + { + isMPOk = true; + } + else + { + WriteLine("[ " + caster + $" ] 魔法不足!"); + } + costEP = skill.RealEPCost; + if (costEP > 0 && costEP <= caster.EP) + { + isEPOk = true; + } + else + { + WriteLine("[ " + caster + $" ] 能量不足!"); + } + return isMPOk && isEPOk; + } /// - /// 是否在回合外释放爆发技插队 + /// 是否在回合外释放爆发技插队(仅自动化) /// /// 当前正在行动的角色 /// public void WillPreCastSuperSkill(Character character) { - // 选取在顺序表一半之后的角色 - foreach (Character other in _queue.Where(c => c != character && c.CharacterState == CharacterState.Actionable && _queue.IndexOf(c) >= _queue.Count / 2).ToList()) + // 选取除了回合内角色之外的 AI 控制角色 + foreach (Character other in _queue.Where(c => c != character && c.CharacterState == CharacterState.Actionable && _charactersInAI.Contains(c)).ToList()) { // 有 65% 欲望插队 if (Random.Shared.NextDouble() < 0.65) @@ -1854,20 +1965,7 @@ namespace Milimoe.FunGame.Core.Model if (skills.Count > 0) { Skill skill = skills[Random.Shared.Next(skills.Count)]; - _castingSuperSkills.Add(other, skill); - other.CharacterState = CharacterState.PreCastSuperSkill; - _queue.Remove(other); - _cutCount.Remove(character); - AddCharacter(other, 0, false); - WriteLine("[ " + other + " ] 预释放了爆发技!!"); - foreach (Character c in _hardnessTimes.Keys) - { - if (_hardnessTimes[c] != 0) - { - _hardnessTimes[c] = Calculation.Round2Digits(_hardnessTimes[c] + 0.01); - } - } - skill.OnSkillCasting(this, other, []); + SetCharacterPreCastSuperSkill(other, skill); } } } @@ -2030,6 +2128,94 @@ namespace Milimoe.FunGame.Core.Model return item; } + /// + /// 使用物品实际逻辑 + /// + /// + /// + /// + /// + /// + public bool UseItem(Item item, Character character, List enemys, List teammates) + { + Skill? skill = item.Skills.Active; + if (skill != null) + { + if (CheckCanCast(character, skill, out double cost)) + { + List targets = SelectTargets(character, skill, enemys, teammates); + if (targets.Count == 0 && _charactersInAI.Contains(character) && enemys.Count > 0) + { + // 如果没有选取目标,且角色在 AI 控制下,则随机选取一个目标 + targets = [enemys[Random.Shared.Next(enemys.Count)]]; + } + if (targets.Count > 0) + { + LastRound.Targets = [.. targets]; + + skill.OnSkillCasting(this, character, targets); + skill.BeforeSkillCasted(); + + character.EP -= cost; + skill.CurrentCD = skill.RealCD; + skill.Enable = false; + LastRound.SkillCost = $"{-cost:0.##} EP"; + + WriteLine("[ " + character + $" ] 消耗了 {cost:0.##} 点能量,释放了{(skill.IsSuperSkill ? "爆发技" : "战技")} [ {skill.Name} ]!{(skill.Slogan != "" ? skill.Slogan : "")}"); + skill.OnSkillCasted(this, character, targets); + return true; + } + } + } + return false; + } + + /// + /// 设置角色将预释放爆发技 + /// + /// + /// + public void SetCharacterPreCastSuperSkill(Character character, Skill skill) + { + if (character.CharacterState == CharacterState.Actionable) + { + _castingSuperSkills.Add(character, skill); + character.CharacterState = CharacterState.PreCastSuperSkill; + _queue.Remove(character); + _cutCount.Remove(character); + AddCharacter(character, 0, false); + WriteLine("[ " + character + " ] 预释放了爆发技!!"); + foreach (Character c in _hardnessTimes.Keys) + { + if (_hardnessTimes[c] != 0) + { + _hardnessTimes[c] = Calculation.Round2Digits(_hardnessTimes[c] + 0.01); + } + } + skill.OnSkillCasting(this, character, []); + } + } + + /// + /// 设置角色为 AI 控制 + /// + /// + /// + public void SetCharactersToAIControl(bool cancel = false, params IEnumerable characters) + { + foreach (Character character in characters) + { + if (cancel) + { + _charactersInAI.Remove(character); + } + else + { + _charactersInAI.Add(character); + } + } + } + /// /// 选取技能目标 /// @@ -2037,16 +2223,14 @@ namespace Milimoe.FunGame.Core.Model /// /// /// - /// /// - public virtual List SelectTargets(Character caster, Skill skill, List enemys, List teammates, out bool cancel) + public virtual List SelectTargets(Character caster, Skill skill, List enemys, List teammates) { List targets = OnSelectSkillTargets(caster, skill, enemys, teammates); if (targets.Count == 0) { targets = skill.SelectTargets(caster, enemys, teammates); } - cancel = targets.Count == 0; return targets; } @@ -2057,16 +2241,10 @@ namespace Milimoe.FunGame.Core.Model /// /// /// - /// /// - public virtual List SelectTargets(Character character, NormalAttack attack, List enemys, List teammates, out bool cancel) + public virtual List SelectTargets(Character character, NormalAttack attack, List enemys, List teammates) { List targets = OnSelectNormalAttackTargets(character, attack, enemys, teammates); - if (targets.Count == 0 && enemys.Count > 0) - { - targets = [enemys[Random.Shared.Next(enemys.Count)]]; - } - cancel = targets.Count == 0; return targets; } @@ -2085,6 +2263,32 @@ namespace Milimoe.FunGame.Core.Model return DecideAction?.Invoke(character, pUseItem, pCastSkill, pNormalAttack) ?? CharacterActionType.None; } + public delegate Skill SelectSkillEventHandler(Character character, List skills); + public event SelectSkillEventHandler? SelectSkill; + /// + /// 角色需要选择一个技能 + /// + /// + /// + /// + public Skill? OnSelectSkill(Character character, List skills) + { + return SelectSkill?.Invoke(character, skills); + } + + public delegate Item SelectItemEventHandler(Character character, List items); + public event SelectItemEventHandler? SelectItem; + /// + /// 角色需要选择一个物品 + /// + /// + /// + /// + public Item? OnSelectItem(Character character, List items) + { + return SelectItem?.Invoke(character, items); + } + public delegate List SelectSkillTargetsEventHandler(Character caster, Skill skill, List enemys, List teammates); public event SelectSkillTargetsEventHandler? SelectSkillTargets; /// @@ -2114,5 +2318,33 @@ namespace Milimoe.FunGame.Core.Model { return SelectNormalAttackTargets?.Invoke(character, attack, enemys, teammates) ?? []; } + + public delegate bool TurnStartEventHandler(Character character, List enemys, List teammates, List skills, List items); + public event TurnStartEventHandler? TurnStart; + /// + /// 回合开始事件 + /// + /// + /// + /// + /// + /// + /// + public bool OnTurnStart(Character character, List enemys, List teammates, List skills, List items) + { + return TurnStart?.Invoke(character, enemys, teammates, skills, items) ?? true; + } + + public delegate void TurnEndEventHandler(Character character); + public event TurnEndEventHandler? TurnEnd; + /// + /// 回合结束事件 + /// + /// + /// + public void OnTurnEnd(Character character) + { + TurnEnd?.Invoke(character); + } } } diff --git a/Model/EquilibriumConstant.cs b/Model/EquilibriumConstant.cs index bce7cd8..d3185d9 100644 --- a/Model/EquilibriumConstant.cs +++ b/Model/EquilibriumConstant.cs @@ -1,3 +1,5 @@ +using Milimoe.FunGame.Core.Entity; + namespace Milimoe.FunGame.Core.Model { /// @@ -14,6 +16,11 @@ namespace Milimoe.FunGame.Core.Model /// 游戏材料名称(第二货币) /// public string InGameMaterial { get; set; } = "材料"; + + /// + /// 游戏时间名称(如技能冷却、硬直) + /// + public string InGameTime { get; set; } = "时间"; /// /// 晋升点数上限 @@ -258,5 +265,37 @@ namespace Milimoe.FunGame.Core.Model /// 每 1 点敏捷增加闪避率 /// public double AGItoEvadeRateMultiplier { get; set; } = 0.00175; + + /// + /// 造成伤害获得能量值因子 + /// + public double DamageGetEPFactor { get; set; } = 0.03; + + /// + /// 造成伤害获得能量值上限 + /// + public double DamageGetEPMax { get; set; } = 30; + + /// + /// 受到伤害获得能量值因子 + /// + public double TakenDamageGetEPFactor { get; set; } = 0.015; + + /// + /// 受到伤害获得能量值上限 + /// + public double TakenDamageGetEPMax { get; set; } = 15; + + /// + /// 应用此游戏平衡常数给实体 + /// + /// + public void SetEquilibriumConstant(params BaseEntity[] entities) + { + foreach (BaseEntity entity in entities) + { + entity.GameplayEquilibriumConstant = this; + } + } } }