diff --git a/OshimaCore/Controllers/FunGameController.cs b/OshimaCore/Controllers/FunGameController.cs index bd8bf88..4878090 100644 --- a/OshimaCore/Controllers/FunGameController.cs +++ b/OshimaCore/Controllers/FunGameController.cs @@ -693,7 +693,12 @@ namespace Oshima.Core.Controllers Item first = objs[0]; string str = $"{itemCount}. [{ItemSet.GetQualityTypeName(first.QualityType)}|{ItemSet.GetItemTypeName(first.ItemType)}] {first.Name}\r\n"; str += $"物品描述:{first.Description}\r\n"; - str += $"物品序号:{string.Join(",", objs.Select(i => items.IndexOf(i) + 1))}\r\n"; + string itemsIndex = string.Join(",", objs.Select(i => items.IndexOf(i) + 1)); + if (objs.Count > 10) + { + itemsIndex = string.Join(",", objs.Take(10).Select(i => items.IndexOf(i) + 1)) + ",..."; + } + str += $"物品序号:{itemsIndex}\r\n"; str += $"拥有数量:{objs.Count}(" + (first.IsEquipment ? $"可装备数量:{objs.Count(i => i.Character is null)}," : "") + (itemCanUsed.Contains(first.ItemType) ? $"可使用数量:{objs.Count(i => i.RemainUseTimes > 0)}," : "") + $"可出售数量:{objs.Count(i => i.IsSellable)},可交易数量:{objs.Count(i => i.IsTradable)})"; @@ -765,7 +770,7 @@ namespace Oshima.Core.Controllers { List keys = [.. FunGameService.GetPage(itemCategory.Keys, showPage, 10)]; int itemCount = 0; - list.Add($"======= {ItemSet.GetItemTypeName((ItemType)itemtype).Replace("物品", "")}物品 ======="); + list.Add($"======= {ItemSet.GetItemTypeName((ItemType)itemtype)} ======="); foreach (string key in keys) { itemCount++; @@ -773,7 +778,12 @@ namespace Oshima.Core.Controllers Item first = objs[0]; string str = $"{itemCount}. [{ItemSet.GetQualityTypeName(first.QualityType)}|{ItemSet.GetItemTypeName(first.ItemType)}] {first.Name}\r\n"; str += $"物品描述:{first.Description}\r\n"; - str += $"物品序号:{string.Join(",", objs.Select(i => items.IndexOf(i) + 1))}\r\n"; + string itemsIndex = string.Join(",", objs.Select(i => items.IndexOf(i) + 1)); + if (objs.Count > 10) + { + itemsIndex = string.Join(",", objs.Take(10).Select(i => items.IndexOf(i) + 1)) + ",..."; + } + str += $"物品序号:{itemsIndex}\r\n"; str += $"拥有数量:{objs.Count}(" + (first.IsEquipment ? $"可装备数量:{objs.Count(i => i.Character is null)}," : "") + (itemCanUsed.Contains(first.ItemType) ? $"可使用数量:{objs.Count(i => i.RemainUseTimes > 0)}," : "") + $"可出售数量:{objs.Count(i => i.IsSellable)},可交易数量:{objs.Count(i => i.IsTradable)})"; @@ -1313,6 +1323,9 @@ namespace Oshima.Core.Controllers if (pc.Count > 0) { user1 = FunGameService.GetUser(pc); + user1.LastTime = DateTime.Now; + pc.Add("user", user1); + pc.SaveConfig(); } else { @@ -1322,6 +1335,9 @@ namespace Oshima.Core.Controllers if (pc2.Count > 0) { user2 = FunGameService.GetUser(pc2); + user2.LastTime = DateTime.Now; + pc2.Add("user", user2); + pc2.SaveConfig(); } else { @@ -1376,6 +1392,416 @@ namespace Oshima.Core.Controllers } } + [HttpPost("useitem")] + public string UseItem([FromQuery] long? qq = null, [FromQuery] int? id = null, [FromBody] int[]? characters = null) + { + try + { + long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + int itemIndex = id ?? 0; + List charactersIndex = characters?.ToList() ?? []; + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + + Character? character = null; + Item? item = null; + if (itemIndex > 0 && itemIndex <= user.Inventory.Items.Count) + { + item = user.Inventory.Items.ToList()[itemIndex - 1]; + if (itemCanUsed.Contains(item.ItemType)) + { + if (item.RemainUseTimes <= 0) + { + return NetworkUtility.JsonSerialize("此物品剩余使用次数为0,无法使用!"); + } + + List targets = []; + foreach (int characterIndex in charactersIndex) + { + if (characterIndex > 0 && characterIndex <= user.Inventory.Characters.Count) + { + character = user.Inventory.Characters.ToList()[characterIndex - 1]; + targets.Add(character); + } + } + + if (FunGameService.UseItem(item, user, [.. targets], out string msg)) + { + user.LastTime = DateTime.Now; + pc.Add("user", user); + pc.SaveConfig(); + } + return NetworkUtility.JsonSerialize(msg); + } + else + { + return NetworkUtility.JsonSerialize($"这个物品无法使用!"); + } + } + else + { + return NetworkUtility.JsonSerialize($"没有找到与这个序号相对应的物品!"); + } + } + else + { + return NetworkUtility.JsonSerialize(noSaved); + } + } + catch (Exception e) + { + return NetworkUtility.JsonSerialize(e.ToString()); + } + } + + [HttpPost("useitem2")] + public string UseItem2([FromQuery] long? qq = null, [FromQuery] string? name = null, [FromQuery] int? count = null, [FromBody] int[]? characters = null) + { + try + { + long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + string itemName = name ?? ""; + int useCount = count ?? 0; + List charactersIndex = characters?.ToList() ?? []; + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + + IEnumerable items = user.Inventory.Items.Where(i => i.Name == name); + if (!items.Any()) + { + return NetworkUtility.JsonSerialize($"库存中不存在名称为【{name}】的物品!"); + } + + if (items.Count() >= useCount) + { + items = items.Reverse().Take(useCount); + List msgs = []; + int successCount = 0; + + List targets = []; + Character? character = null; + foreach (int characterIndex in charactersIndex) + { + if (characterIndex > 0 && characterIndex <= user.Inventory.Characters.Count) + { + character = user.Inventory.Characters.ToList()[characterIndex - 1]; + targets.Add(character); + } + else + { + msgs.Add($"库存中不存在序号为 {characterIndex} 的角色!"); + } + } + + foreach (Item item in items) + { + if (itemCanUsed.Contains(item.ItemType)) + { + if (item.RemainUseTimes <= 0) + { + msgs.Add("此物品剩余使用次数为0,无法使用!"); + } + + if (FunGameService.UseItem(item, user, [.. targets], out string msg)) + { + successCount++; + } + msgs.Add(msg); + } + else + { + msgs.Add($"这个物品无法使用!"); + } + } + if (successCount > 0) + { + user.LastTime = DateTime.Now; + pc.Add("user", user); + pc.SaveConfig(); + } + return NetworkUtility.JsonSerialize($"使用完毕!使用 {useCount} 件物品,成功 {successCount} 件!\r\n" + string.Join("\r\n", msgs)); + } + else + { + return NetworkUtility.JsonSerialize("此物品的可使用数量小于你想要使用的数量!"); + } + } + else + { + return NetworkUtility.JsonSerialize(noSaved); + } + } + catch (Exception e) + { + return NetworkUtility.JsonSerialize(e.ToString()); + } + } + + [HttpPost("characterlevelup")] + public string CharacterLevelUp([FromQuery] long? qq = null, [FromQuery] int? c = null, [FromQuery] int? count = null) + { + try + { + long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + int characterIndex = c ?? 0; + int upCount = count ?? 0; + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + + Character? character = null; + if (characterIndex > 0 && characterIndex <= user.Inventory.Characters.Count) + { + character = user.Inventory.Characters.ToList()[characterIndex - 1]; + } + else + { + return NetworkUtility.JsonSerialize($"没有找到与这个序号相对应的角色!"); + } + + if (character.Level == General.GameplayEquilibriumConstant.MaxLevel) + { + return NetworkUtility.JsonSerialize($"该角色等级已满,无需再升级!"); + } + + int originalLevel = character.Level; + + character.OnLevelUp(upCount); + + string msg = $"升级完成!角色 [ {character} ] 共提升 {character.Level - originalLevel} 级,当前等级:{character.Level} 级。"; + + if (General.GameplayEquilibriumConstant.EXPUpperLimit.TryGetValue(character.Level, out double need)) + { + if (character.EXP < need) + { + msg += $"\r\n角色 [ {character} ] 仍需 {need - character.EXP} 点经验值才能继续升级。"; + } + else + { + msg += $"\r\n角色 [ {character} ] 目前突破进度:{character.LevelBreak + 1}/{General.GameplayEquilibriumConstant.LevelBreakList.Count},需要进行【角色突破】才能继续升级。"; + } + } + + user.LastTime = DateTime.Now; + pc.Add("user", user); + pc.SaveConfig(); + return NetworkUtility.JsonSerialize(msg); + } + else + { + return NetworkUtility.JsonSerialize(noSaved); + } + } + catch (Exception e) + { + return NetworkUtility.JsonSerialize(e.ToString()); + } + } + + [HttpPost("getlevelbreakneedy")] + public string GetLevelBreakNeedy([FromQuery] long? qq = null, [FromQuery] int? id = null) + { + long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + int characterIndex = id ?? 0; + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + Character? character; + if (characterIndex > 0 && characterIndex <= user.Inventory.Characters.Count) + { + character = user.Inventory.Characters.ToList()[characterIndex - 1]; + } + else + { + return NetworkUtility.JsonSerialize($"没有找到与这个序号相对应的角色!"); + } + + if (character.LevelBreak + 1 == General.GameplayEquilibriumConstant.LevelBreakList.Count) + { + return NetworkUtility.JsonSerialize($"该角色已完成全部的突破阶段,无需再突破!"); + } + + return NetworkUtility.JsonSerialize($"角色 [ {character} ] 目前突破进度:{character.LevelBreak + 1}/{General.GameplayEquilibriumConstant.LevelBreakList.Count}" + + $"\r\n该角色下一个等级突破阶段在 {General.GameplayEquilibriumConstant.LevelBreakList.ToArray()[character.LevelBreak]} 级,所需材料:\r\n" + FunGameService.GetLevelBreakNeedy(character.LevelBreak + 1)); + } + else + { + return NetworkUtility.JsonSerialize(noSaved); + } + } + + [HttpPost("characterlevelbreak")] + public string CharacterLevelBreak([FromQuery] long? qq = null, [FromQuery] int? c = null) + { + try + { + long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + int characterIndex = c ?? 0; + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + + Character? character = null; + if (characterIndex > 0 && characterIndex <= user.Inventory.Characters.Count) + { + character = user.Inventory.Characters.ToList()[characterIndex - 1]; + } + else + { + return NetworkUtility.JsonSerialize($"没有找到与这个序号相对应的角色!"); + } + + if (character.LevelBreak + 1 == General.GameplayEquilibriumConstant.LevelBreakList.Count) + { + return NetworkUtility.JsonSerialize($"该角色已完成全部的突破阶段,无需再突破!"); + } + + int originalBreak = character.LevelBreak; + + if (FunGameService.LevelBreakNeedyList.TryGetValue(originalBreak, out Dictionary? needy) && needy != null && needy.Count > 0) + { + foreach (string key in needy.Keys) + { + int needCount = needy[key]; + if (key == General.GameplayEquilibriumConstant.InGameMaterial) + { + if (user.Inventory.Credits >= needCount) + { + user.Inventory.Credits -= needCount; + } + else + { + return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameCurrency}不足 {needCount} 呢,不满足突破条件!"); + } + } + if (needCount > 0) + { + IEnumerable items = user.Inventory.Items.Where(i => i.Name == key); + if (items.Count() >= needCount) + { + items = items.Reverse().Take(needCount); + foreach (Item item in items) + { + user.Inventory.Items.Remove(item); + } + } + else + { + return NetworkUtility.JsonSerialize($"你的物品【{key}】数量不足 {needCount} 呢,不满足突破条件!"); + } + } + } + } + + character.OnLevelBreak(); + + if (originalBreak == character.LevelBreak) + { + return NetworkUtility.JsonSerialize($"突破失败!角色 [ {character} ] 目前突破进度:{character.LevelBreak + 1}/{General.GameplayEquilibriumConstant.LevelBreakList.Count}。" + + $"\r\n该角色下一个等级突破阶段在 {General.GameplayEquilibriumConstant.LevelBreakList.ToArray()[character.LevelBreak]} 级,所需材料:\r\n" + FunGameService.GetLevelBreakNeedy(character.LevelBreak + 1)); + } + else + { + user.LastTime = DateTime.Now; + pc.Add("user", user); + pc.SaveConfig(); + return NetworkUtility.JsonSerialize($"突破成功!角色 [ {character} ] 目前突破进度:{character.LevelBreak + 1}/{General.GameplayEquilibriumConstant.LevelBreakList.Count}。" + + $"{(character.LevelBreak + 1 == General.GameplayEquilibriumConstant.LevelBreakList.Count ? + "\r\n该角色已完成全部的突破阶段,恭喜!" : + $"\r\n该角色下一个等级突破阶段在 {General.GameplayEquilibriumConstant.LevelBreakList.ToArray()[character.LevelBreak]} 级,所需材料:\r\n" + FunGameService.GetLevelBreakNeedy(character.LevelBreak + 1))}"); + } + } + else + { + return NetworkUtility.JsonSerialize(noSaved); + } + } + catch (Exception e) + { + return NetworkUtility.JsonSerialize(e.ToString()); + } + } + + [HttpPost("createitem")] + public string CreateItem([FromQuery] long? qq = null, [FromQuery] string? name = null, [FromQuery] int? count = null, [FromQuery] long? target = null) + { + long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + string itemName = name ?? ""; + int itemCount = count ?? 0; + long targetid = target ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + if (pc.Count > 0) + { + User user = FunGameService.GetUser(pc); + + string msg = ""; + if (user.IsAdmin) + { + if (FunGameService.AllItems.FirstOrDefault(i => i.Name == itemName) is Item item) + { + PluginConfig pc2 = new("saved", targetid.ToString()); + pc2.LoadConfig(); + if (pc2.Count > 0) + { + User user2 = FunGameService.GetUser(pc2); + for (int i = 0; i < itemCount; i++) + { + Item newItem = item.Copy(); + newItem.User = user2; + user2.Inventory.Items.Add(newItem); + } + pc2.Add("user", user2); + pc2.SaveConfig(); + msg = $"已为 [ {user2} ] 生成 {itemCount} 个 [{ItemSet.GetQualityTypeName(item.QualityType)}|{ItemSet.GetItemTypeName(item.ItemType)}] {item.Name}"; + } + else + { + return NetworkUtility.JsonSerialize($"目标 UID 不存在!"); + } + } + else + { + return NetworkUtility.JsonSerialize($"此物品不存在!"); + } + } + else + { + return NetworkUtility.JsonSerialize($"你没有权限使用此指令!"); + } + + return NetworkUtility.JsonSerialize(msg); + } + else + { + return NetworkUtility.JsonSerialize(noSaved); + } + } + [HttpGet("reload")] public string Relaod([FromQuery] long? master = null) { diff --git a/OshimaCore/Utils/FunGameService.cs b/OshimaCore/Utils/FunGameService.cs index 90dea69..267be7a 100644 --- a/OshimaCore/Utils/FunGameService.cs +++ b/OshimaCore/Utils/FunGameService.cs @@ -6,7 +6,6 @@ using Oshima.FunGame.OshimaModules; using Oshima.FunGame.OshimaModules.Characters; using Oshima.FunGame.OshimaModules.Effects.OpenEffects; using Oshima.FunGame.OshimaModules.Items; -using Oshima.FunGame.OshimaModules.Items.Consumable; using Oshima.FunGame.OshimaModules.Skills; namespace Oshima.Core.Utils @@ -20,7 +19,59 @@ namespace Oshima.Core.Utils public static List Items { get; } = []; public static List ItemSkills { get; } = []; public static List AllItems { get; } = []; + public static List AllSkills { get; } = []; public static Dictionary UserIdAndUsername { get; } = []; + public static Dictionary> LevelBreakNeedyList + { + get + { + return new() + { + { + 0, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 80 }, + { nameof(鍗囧崕涔嬪嵃), 10 } + } + }, + { + 1, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 400 }, + { nameof(鍗囧崕涔嬪嵃), 40 } + } + }, + { + 2, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 1040 }, + { nameof(鍗囧崕涔嬪嵃), 75 } + } + }, + { + 3, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 2320 }, + { nameof(鍗囧崕涔嬪嵃), 115 } + } + }, + { + 4, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 4880 }, + { nameof(鍗囧崕涔嬪嵃), 160 } + } + }, + { + 5, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 10000 }, + { nameof(鍗囧崕涔嬪嵃), 210 } + } + }, + }; + } + } public static void InitFunGame() { @@ -47,7 +98,7 @@ namespace Oshima.Core.Utils Equipment.AddRange([new 鏀诲嚮涔嬬埅5(), new 鏀诲嚮涔嬬埅15(), new 鏀诲嚮涔嬬埅25(), new 鏀诲嚮涔嬬埅35()]); Items.AddRange(exItems.Values.Where(i => (int)i.ItemType > 4)); - Items.AddRange([new 灏忕粡楠屼功(), new 涓粡楠屼功(), new 澶х粡楠屼功()]); + Items.AddRange([new 灏忕粡楠屼功(), new 涓粡楠屼功(), new 澶х粡楠屼功(), new 鍗囧崕涔嬪嵃()]); AllItems.AddRange(Equipment); AllItems.AddRange(Items); @@ -61,6 +112,9 @@ namespace Oshima.Core.Utils } } ItemSkills.AddRange([.. Equipment.SelectMany(i => i.Skills.Passives), .. Items.SelectMany(i => i.Skills.Passives)]); + + AllSkills.AddRange(Skills); + AllSkills.AddRange(ItemSkills); } public static List GenerateMagicCards(int count, QualityType? qualityType = null) @@ -361,6 +415,7 @@ namespace Oshima.Core.Utils Magics.Clear(); AllItems.Clear(); ItemSkills.Clear(); + AllSkills.Clear(); InitFunGame(); } @@ -447,14 +502,14 @@ namespace Oshima.Core.Utils foreach (Character inventoryCharacter in characters) { - Character realCharacter = CharacterBuilder.Build(inventoryCharacter, false, [.. Equipment, .. Items], ItemSkills); + Character realCharacter = CharacterBuilder.Build(inventoryCharacter, false, AllItems, AllSkills); realCharacter.User = user; user.Inventory.Characters.Add(realCharacter); } foreach (Item inventoryItem in items) { - Item realItem = inventoryItem.Copy(true, true, true, [.. Equipment, .. Items], ItemSkills); + Item realItem = inventoryItem.Copy(true, true, true, AllItems, AllSkills); if (realItem.IsEquipment) { IEnumerable has = user.Inventory.Characters.Where(character => @@ -491,9 +546,9 @@ namespace Oshima.Core.Utils if (has.Any() && has.First() is Character character) { realItem.Character = character; - realItem.User = user; } } + realItem.User = user; user.Inventory.Items.Add(realItem); } @@ -853,5 +908,30 @@ namespace Oshima.Core.Utils character.Skills.Add(琛涔嬬媯娆); } } + + public static bool UseItem(Item item, User user, Character[] targets, out string msg) + { + msg = ""; + Dictionary args = new() + { + { "targets", targets } + }; + bool result = item.UseItem(args); + string key = args.Keys.FirstOrDefault(s => s.Equals("msg", StringComparison.CurrentCultureIgnoreCase)) ?? ""; + if (key != "" && args.TryGetValue(key, out object? value) && value is string str) + { + msg = str; + } + return result; + } + + public static string GetLevelBreakNeedy(int levelBreak) + { + if (LevelBreakNeedyList.TryGetValue(levelBreak, out Dictionary? needy) && needy != null && needy.Count > 0) + { + return string.Join("锛", needy.Select(kv => kv.Key + " * " + kv.Value)); + } + return ""; + } } } diff --git a/OshimaModules/Effects/ItemEffects/GetEXP.cs b/OshimaModules/Effects/ItemEffects/GetEXP.cs index a690d31..1a837cb 100644 --- a/OshimaModules/Effects/ItemEffects/GetEXP.cs +++ b/OshimaModules/Effects/ItemEffects/GetEXP.cs @@ -31,5 +31,13 @@ namespace Oshima.FunGame.OshimaModules.Effects.ItemEffects { caster.EXP += 瀹為檯鑾峰緱; } + + public override void OnSkillCasted(List targets, Dictionary others) + { + foreach (Character target in targets) + { + target.EXP += 瀹為檯鑾峰緱; + } + } } } \ No newline at end of file diff --git a/OshimaModules/Items/Consumable/缁忛獙涔.cs b/OshimaModules/Items/Consumable/缁忛獙涔.cs index 4d48363..bd7c53a 100644 --- a/OshimaModules/Items/Consumable/缁忛獙涔.cs +++ b/OshimaModules/Items/Consumable/缁忛獙涔.cs @@ -3,50 +3,118 @@ using Milimoe.FunGame.Core.Library.Constant; using Oshima.FunGame.OshimaModules.Effects.ItemEffects; using Oshima.FunGame.OshimaModules.Skills; -namespace Oshima.FunGame.OshimaModules.Items.Consumable +namespace Oshima.FunGame.OshimaModules.Items { - public class 灏忕粡楠屼功 : Item + public class 缁忛獙涔 + { + public interface EXPBook + { + public double EXP { get; set; } + } + + public static void Init(Item item, double exp, int remainUseTimes = 1) + { + item.Skills.Active = new 缁忛獙涔︽妧鑳(item, exp); + item.RemainUseTimes = remainUseTimes; + item.IsInGameItem = false; + item.IsReduceTimesAfterUse = true; + item.IsRemoveAfterUse = true; + } + + public static string UseItem(Item item, Character character) + { + if (item.Skills.Active != null) + { + item.Skills.Active.OnSkillCasted([character]); + string msg = $"瀵硅鑹 [ {character} ] 浣跨敤 [ {item.Name} ] 鎴愬姛锛"; + if (item is EXPBook expBook) + { + msg += $"鑾峰緱浜 {expBook.EXP} 鐐圭粡楠屽硷紒"; + } + return msg; + } + return "姝ょ墿鍝佹病鏈変富鍔ㄦ妧鑳斤紝鏃犳硶琚娇鐢紒"; + } + + public static bool OnItemUsed(Item item, Dictionary args) + { + string msg = ""; + bool result = false; + string key = args.Keys.FirstOrDefault(s => s.Equals("targets", StringComparison.CurrentCultureIgnoreCase)) ?? ""; + if (key != "" && args.TryGetValue(key, out object? value) && value is Character[] targets) + { + if (targets.Length > 0) + { + msg = UseItem(item, targets[0]); + result = true; + } + else + { + msg = $"浣跨敤鐗╁搧澶辫触锛屾病鏈変綔鐢ㄧ洰鏍囷紒"; + } + } + args.Add("msg", msg); + return result; + } + } + + public class 灏忕粡楠屼功 : Item, 缁忛獙涔.EXPBook { public override long Id => (long)ConsumableID.灏忕粡楠屼功; public override string Name => "灏忕粡楠屼功"; public override string Description => Skills.Active?.Description ?? ""; public override QualityType QualityType => QualityType.White; + public double EXP { get; set; } = 200; public 灏忕粡楠屼功(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable) { User = user; - Skills.Active = new 缁忛獙涔︽妧鑳(this, 200); - RemainUseTimes = remainUseTimes; + 缁忛獙涔.Init(this, EXP, remainUseTimes); + } + + protected override bool OnItemUsed(Dictionary args) + { + return 缁忛獙涔.OnItemUsed(this, args); } } - public class 涓粡楠屼功 : Item + public class 涓粡楠屼功 : Item, 缁忛獙涔.EXPBook { public override long Id => (long)ConsumableID.涓粡楠屼功; public override string Name => "涓粡楠屼功"; public override string Description => Skills.Active?.Description ?? ""; public override QualityType QualityType => QualityType.Green; + public double EXP { get; set; } = 500; public 涓粡楠屼功(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable) { User = user; - Skills.Active = new 缁忛獙涔︽妧鑳(this, 500); - RemainUseTimes = remainUseTimes; + 缁忛獙涔.Init(this, EXP, remainUseTimes); + } + + protected override bool OnItemUsed(Dictionary args) + { + return 缁忛獙涔.OnItemUsed(this, args); } } - public class 澶х粡楠屼功 : Item + public class 澶х粡楠屼功 : Item, 缁忛獙涔.EXPBook { public override long Id => (long)ConsumableID.澶х粡楠屼功; public override string Name => "澶х粡楠屼功"; public override string Description => Skills.Active?.Description ?? ""; public override QualityType QualityType => QualityType.Blue; + public double EXP { get; set; } = 1000; public 澶х粡楠屼功(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable) { User = user; - Skills.Active = new 缁忛獙涔︽妧鑳(this, 1000); - RemainUseTimes = remainUseTimes; + 缁忛獙涔.Init(this, EXP, remainUseTimes); + } + + protected override bool OnItemUsed(Dictionary args) + { + return 缁忛獙涔.OnItemUsed(this, args); } } diff --git a/OshimaModules/Items/ItemID.cs b/OshimaModules/Items/ItemID.cs index ea1de79..dd66cf4 100644 --- a/OshimaModules/Items/ItemID.cs +++ b/OshimaModules/Items/ItemID.cs @@ -14,4 +14,9 @@ 涓粡楠屼功 = 15002, 澶х粡楠屼功 = 15003, } + + public enum SpecialItemID : long + { + 鍗囧崕涔嬪嵃 = 18001, + } } diff --git a/OshimaModules/Items/SpecialItem/鍗囧崕涔嬪嵃.cs b/OshimaModules/Items/SpecialItem/鍗囧崕涔嬪嵃.cs new file mode 100644 index 0000000..4c790c2 --- /dev/null +++ b/OshimaModules/Items/SpecialItem/鍗囧崕涔嬪嵃.cs @@ -0,0 +1,12 @@ +锘縰sing Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Library.Constant; + +namespace Oshima.FunGame.OshimaModules.Items +{ + public class 鍗囧崕涔嬪嵃() : Item(ItemType.SpecialItem) + { + public override long Id => (long)SpecialItemID.鍗囧崕涔嬪嵃; + public override string Name => "鍗囧崕涔嬪嵃"; + public override string Description => Skills.Passives.Count > 0 ? Skills.Passives.First().Description : ""; + } +} diff --git a/OshimaModules/Modules/ItemModule.cs b/OshimaModules/Modules/ItemModule.cs index 75e16c8..6327cc1 100644 --- a/OshimaModules/Modules/ItemModule.cs +++ b/OshimaModules/Modules/ItemModule.cs @@ -1,7 +1,6 @@ 锘縰sing Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; using Oshima.FunGame.OshimaModules.Items; -using Oshima.FunGame.OshimaModules.Items.Consumable; namespace Oshima.FunGame.OshimaModules { @@ -33,6 +32,7 @@ namespace Oshima.FunGame.OshimaModules (long)ConsumableID.灏忕粡楠屼功 => new 灏忕粡楠屼功(), (long)ConsumableID.涓粡楠屼功 => new 涓粡楠屼功(), (long)ConsumableID.澶х粡楠屼功 => new 澶х粡楠屼功(), + (long)SpecialItemID.鍗囧崕涔嬪嵃 => new 鍗囧崕涔嬪嵃(), _ => null, }; }; diff --git a/OshimaModules/Modules/SkillModule.cs b/OshimaModules/Modules/SkillModule.cs index a484d7b..cc67f95 100644 --- a/OshimaModules/Modules/SkillModule.cs +++ b/OshimaModules/Modules/SkillModule.cs @@ -3,7 +3,6 @@ using Milimoe.FunGame.Core.Entity; using Oshima.FunGame.OshimaModules.Effects.ItemEffects; using Oshima.FunGame.OshimaModules.Effects.OpenEffects; using Oshima.FunGame.OshimaModules.Items; -using Oshima.FunGame.OshimaModules.Items.Consumable; using Oshima.FunGame.OshimaModules.Skills; namespace Oshima.FunGame.OshimaModules