using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; using Oshima.FunGame.OshimaModules.Effects.ItemEffects; using Oshima.FunGame.OshimaModules.Skills; namespace Oshima.FunGame.OshimaModules.Items { public class 魔力填充剂 { public interface MPRecovery { public double MP { get; set; } } public static void Init(Item item, double mp, int remainUseTimes = 1, bool isPercentage = false) { item.Skills.Active = new 魔力填充剂技能(item, mp, isPercentage); item.RemainUseTimes = remainUseTimes; item.IsReduceTimesAfterUse = true; item.IsRemoveAfterUse = true; } public static string UseItem(User user, Item item, Character character) { if (item.Skills.Active != null) { item.Skills.Active.OnSkillCasted(user, [character]); string msg = $"对角色 [ {character} ] 使用 [ {item.Name} ] 成功!"; if (item is MPRecovery hpBook) { msg += $"回复了 {hpBook.MP} 点魔法值!"; } return msg; } return "此物品没有主动技能,无法被使用!"; } public static bool OnItemUsed(User user, Item item, int times, Dictionary args) { string msg = ""; bool result = false; Character[] targets = []; string key = args.Keys.FirstOrDefault(s => s.Equals("targets", StringComparison.CurrentCultureIgnoreCase)) ?? ""; if (key != "" && args.TryGetValue(key, out object? value) && value is Character[] temp) { if (temp.Length > 0) { targets = [temp[0]]; msg = UseItem(user, item, temp[0]); result = true; } else { msg = $"使用物品失败,没有作用目标!"; } } args["msg"] = msg; string truemsg = $"对角色 [ {targets[0]} ] 使用 {times} 个 [ {item.Name} ] 成功!"; if (item is MPRecovery expBook) { truemsg += $"回复了 {expBook.MP * times} 点魔法值!"; } args["truemsg"] = truemsg; return result; } } public class 魔力填充剂1 : Item, 魔力填充剂.MPRecovery { public override long Id => (long)ConsumableID.魔力填充剂1; public override string Name => "魔力填充剂Ⅰ型"; public override string Description => Skills.Active?.Description ?? ""; public override QualityType QualityType => QualityType.White; public double MP { get; set; } = 300; public 魔力填充剂1(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable) { User = user; 魔力填充剂.Init(this, MP, remainUseTimes); } protected override bool OnItemUsed(User user, int times, Dictionary args) { return 魔力填充剂.OnItemUsed(user, this, times, args); } } public class 魔力填充剂2 : Item, 魔力填充剂.MPRecovery { public override long Id => (long)ConsumableID.魔力填充剂2; public override string Name => "魔力填充剂Ⅱ型"; public override string Description => Skills.Active?.Description ?? ""; public override QualityType QualityType => QualityType.Green; public double MP { get; set; } = 700; public 魔力填充剂2(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable) { User = user; 魔力填充剂.Init(this, MP, remainUseTimes); } protected override bool OnItemUsed(User user, int times, Dictionary args) { return 魔力填充剂.OnItemUsed(user, this, times, args); } } public class 魔力填充剂3 : Item, 魔力填充剂.MPRecovery { public override long Id => (long)ConsumableID.魔力填充剂3; public override string Name => "魔力填充剂Ⅲ型"; public override string Description => Skills.Active?.Description ?? ""; public override QualityType QualityType => QualityType.Blue; public double MP { get; set; } = 1500; public 魔力填充剂3(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable) { User = user; 魔力填充剂.Init(this, MP, remainUseTimes); } protected override bool OnItemUsed(User user, int times, Dictionary args) { return 魔力填充剂.OnItemUsed(user, this, times, args); } } public class 魔力填充剂技能 : Skill { public override long Id => (long)ItemActiveID.魔力填充剂; public override string Name => "魔力填充剂"; public override string Description => string.Join("", Effects.Select(e => e.Description)); public override bool CanSelectSelf => true; public override bool CanSelectTeammate => true; public override bool CanSelectEnemy => false; public override int CanSelectTargetCount => 1; public 魔力填充剂技能(Item? item = null, double mp = 0, bool isPercentage = false) : base(SkillType.Item) { Level = 1; Item = item; if (!isPercentage) { Effects.Add(new RecoverMP(this, new() { { "mp", mp } })); } else { Effects.Add(new RecoverMP2(this, new() { { "mp", mp } })); } } } }