chore: initialize OshimaBot repository (rename from Enhancement)
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using FunGame.Core.Entity;
|
||||
using FunGame.Core.Library.Constant;
|
||||
using FunGame.Core.Model.EffectContext;
|
||||
|
||||
namespace OshimaBot.Content.Effects.OpenEffects
|
||||
{
|
||||
public class ExMDF : Effect
|
||||
{
|
||||
public override long Id => (long)EffectID.ExMDF;
|
||||
public override string Name { get; set; } = "魔法抗性加成";
|
||||
public override string Description => $"{(实际加成 >= 0 ? "增加" : "减少")}角色 {Math.Abs(实际加成) * 100:0.##}% {CharacterSet.GetMagicResistanceName(魔法类型)}。" + (Source != null && (Skill.Character != Source || Skill is not OpenSkill) ? $"来自:[ {Source} ]" + (Skill.Item != null ? $" 的 [ {Skill.Item.Name} ]" : (Skill is OpenSkill ? "" : $" 的 [ {Skill.Name} ]")) : "");
|
||||
public double Value => 实际加成;
|
||||
|
||||
private readonly double 实际加成 = 0;
|
||||
private readonly MagicType 魔法类型 = MagicType.None;
|
||||
|
||||
public override void OnEffectGained(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
if (Durative && RemainDuration == 0)
|
||||
{
|
||||
RemainDuration = Duration;
|
||||
}
|
||||
else if (RemainDurationTurn == 0)
|
||||
{
|
||||
RemainDurationTurn = DurationTurn;
|
||||
}
|
||||
character.MDF[魔法类型] += 实际加成;
|
||||
}
|
||||
|
||||
public override void OnEffectLost(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
character.MDF[魔法类型] -= 实际加成;
|
||||
}
|
||||
|
||||
public ExMDF(Skill skill, Dictionary<string, object> args, Character? source = null) : base(skill, args)
|
||||
{
|
||||
EffectType = EffectType.Item;
|
||||
GamingQueue = skill.GamingQueue;
|
||||
Source = source;
|
||||
if (Values.Count > 0)
|
||||
{
|
||||
string key = Values.Keys.FirstOrDefault(s => s.Equals("mdftype", StringComparison.CurrentCultureIgnoreCase)) ?? "";
|
||||
if (key.Length > 0 && int.TryParse(Values[key].ToString(), out int mdfType))
|
||||
{
|
||||
if (Enum.IsDefined(typeof(MagicType), mdfType))
|
||||
{
|
||||
魔法类型 = (MagicType)mdfType;
|
||||
}
|
||||
else
|
||||
{
|
||||
魔法类型 = MagicType.None;
|
||||
}
|
||||
}
|
||||
key = Values.Keys.FirstOrDefault(s => s.Equals("mdfvalue", StringComparison.CurrentCultureIgnoreCase)) ?? "";
|
||||
if (key.Length > 0 && double.TryParse(Values[key].ToString(), out double mdfValue))
|
||||
{
|
||||
实际加成 = mdfValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user