From c0477dfde5ff3c5ed42134375cfbd7712110a9d6 Mon Sep 17 00:00:00 2001 From: milimoe Date: Tue, 29 Apr 2025 01:30:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AF=95=E4=B8=9A=E7=A4=BC?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OshimaModules/Items/GiftBox/礼包.cs | 27 +++++++++ OshimaModules/Items/ItemID.cs | 3 +- OshimaModules/Modules/ItemModule.cs | 1 + OshimaServers/Service/FunGameService.cs | 6 +- OshimaWebAPI/Controllers/FunGameController.cs | 55 ++++++++++--------- OshimaWebAPI/Services/RainBOTService.cs | 10 ++++ 6 files changed, 74 insertions(+), 28 deletions(-) diff --git a/OshimaModules/Items/GiftBox/礼包.cs b/OshimaModules/Items/GiftBox/礼包.cs index a4440f6..848c55b 100644 --- a/OshimaModules/Items/GiftBox/礼包.cs +++ b/OshimaModules/Items/GiftBox/礼包.cs @@ -130,6 +130,33 @@ namespace Oshima.FunGame.OshimaModules.Items } } + public class 毕业礼包 : Item, 礼包.GiftBox + { + public override long Id => (long)GiftBoxID.毕业礼包; + public override string Name => "毕业礼包"; + public override string Description => Skills.Active?.Description ?? ""; + public override QualityType QualityType => QualityType.Gold; + public Dictionary Gifts { get; set; } = []; + + public 毕业礼包(User? user = null, int remainUseTimes = 1) : base(ItemType.GiftBox) + { + User = user; + 礼包.Init(this, new() + { + { General.GameplayEquilibriumConstant.InGameCurrency, 290000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 2000 }, + { new 升华之印().Name, 33 }, + { new 流光之印().Name, 12 }, + { new 永恒之印().Name, 2 }, + { new 技能卷轴().Name, 76 }, + { new 智慧之果().Name, 35 }, + { new 奥术符文().Name, 10 }, + { new 混沌之核().Name, 2 }, + { new 大经验书().Name, 164 } + }, remainUseTimes); + } + } + public class 礼包技能 : Skill { public override long Id => (long)ItemActiveID.礼包; diff --git a/OshimaModules/Items/ItemID.cs b/OshimaModules/Items/ItemID.cs index 883daa0..6dda6f2 100644 --- a/OshimaModules/Items/ItemID.cs +++ b/OshimaModules/Items/ItemID.cs @@ -39,6 +39,7 @@ { 年夜饭 = 20001, 蛇年大吉 = 20002, - 新春快乐 = 20003 + 新春快乐 = 20003, + 毕业礼包 = 20004 } } diff --git a/OshimaModules/Modules/ItemModule.cs b/OshimaModules/Modules/ItemModule.cs index 7f30ba8..5230fa4 100644 --- a/OshimaModules/Modules/ItemModule.cs +++ b/OshimaModules/Modules/ItemModule.cs @@ -52,6 +52,7 @@ namespace Oshima.FunGame.OshimaModules (long)GiftBoxID.年夜饭 => new 年夜饭(), (long)GiftBoxID.蛇年大吉 => new 蛇年大吉(), (long)GiftBoxID.新春快乐 => new 新春快乐(), + (long)GiftBoxID.毕业礼包 => new 毕业礼包(), _ => null, }; }; diff --git a/OshimaServers/Service/FunGameService.cs b/OshimaServers/Service/FunGameService.cs index 7ff68ba..d1705d0 100644 --- a/OshimaServers/Service/FunGameService.cs +++ b/OshimaServers/Service/FunGameService.cs @@ -48,7 +48,7 @@ namespace Oshima.FunGame.OshimaServers.Service FunGameConstant.Items.AddRange(exItems.Values.Where(i => (int)i.ItemType > 4)); FunGameConstant.Items.AddRange([new 小经验书(), new 中经验书(), new 大经验书(), new 升华之印(), new 流光之印(), new 永恒之印(), new 技能卷轴(), new 智慧之果(), new 奥术符文(), new 混沌之核(), - new 小回复药(), new 中回复药(), new 大回复药(), new 魔力填充剂1(), new 魔力填充剂2(), new 魔力填充剂3(), new 能量饮料1(), new 能量饮料2(), new 能量饮料3(), new 年夜饭(), new 蛇年大吉(), new 新春快乐()]); + new 小回复药(), new 中回复药(), new 大回复药(), new 魔力填充剂1(), new 魔力填充剂2(), new 魔力填充剂3(), new 能量饮料1(), new 能量饮料2(), new 能量饮料3(), new 年夜饭(), new 蛇年大吉(), new 新春快乐(), new 毕业礼包()]); FunGameConstant.AllItems.AddRange(FunGameConstant.Equipment); FunGameConstant.AllItems.AddRange(FunGameConstant.Items); @@ -1116,6 +1116,10 @@ namespace Oshima.FunGame.OshimaServers.Service { msg += "\r\n" + "新春纳福,喜乐安康!!"; } + else if (item.Name == nameof(毕业礼包)) + { + msg += "\r\n" + "咦?!!啊咧!!!"; + } item.RemainUseTimes--; if (item.RemainUseTimes < 0) item.RemainUseTimes = 0; if (item.RemainUseTimes == 0) diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index cf417bf..ef03752 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -5023,7 +5023,7 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("creategiftbox")] - public string CreateGiftBox([FromQuery] long? uid = null, [FromQuery] string? name = null) + public string CreateGiftBox([FromQuery] long? uid = null, [FromQuery] string? name = null, [FromQuery] bool? checkRepeat = null) { long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); string itemName = name ?? ""; @@ -5037,18 +5037,25 @@ namespace Oshima.FunGame.WebAPI.Controllers if (FunGameConstant.AllItems.FirstOrDefault(i => i.Name == itemName) is Item item) { - PluginConfig pc2 = new("giftbox", "giftbox"); - pc2.LoadConfig(); - - List list = []; - if (pc2.TryGetValue(itemName, out object? value) && value is List tempList) + if (checkRepeat ?? false) { - list = [.. tempList]; - } + PluginConfig pc2 = new("giftbox", "giftbox"); + pc2.LoadConfig(); - if (list.Contains(user.Id)) - { - return NetworkUtility.JsonSerialize($"你已经领取过这个礼包【{itemName}】啦,不能重复领取哦!"); + List list = []; + if (pc2.TryGetValue(itemName, out object? value) && value is List tempList) + { + list = [.. tempList]; + } + + if (list.Contains(user.Id)) + { + return $"你已经领取过这个礼包【{itemName}】啦,不能重复领取哦!"; + } + + list.Add(user.Id); + pc2.Add(itemName, list); + pc2.SaveConfig(); } Item newItem = item.Copy(); @@ -5058,24 +5065,20 @@ namespace Oshima.FunGame.WebAPI.Controllers user.Inventory.Items.Add(newItem); string msg = $"恭喜你获得礼包【{itemName}】一份!"; - list.Add(user.Id); - pc2.Add(itemName, list); - pc2.SaveConfig(); - user.LastTime = DateTime.Now; pc.Add("user", user); pc.SaveConfig(); - return NetworkUtility.JsonSerialize(msg); + return msg; } else { - return NetworkUtility.JsonSerialize("没有找到这个礼包,可能已经过期。"); + return "没有找到这个礼包,可能已经过期。"; } } else { - return NetworkUtility.JsonSerialize(noSaved); + return noSaved; } } @@ -5168,9 +5171,9 @@ namespace Oshima.FunGame.WebAPI.Controllers int halfdown = user.Inventory.Characters.Count(c => (c.HP / c.MaxHP) < 0.5 && c.HP > 0); int halfup = user.Inventory.Characters.Count(c => (c.HP / c.MaxHP) >= 0.5 && c.HP != c.MaxHP); - double deadNeed = 10000 * dead; - double halfdownNeed = 6000 * halfdown; - double halfupNeed = 2000 * halfup; + double deadNeed = 3000 * dead; + double halfdownNeed = 1500 * halfdown; + double halfupNeed = 500 * halfup; double total = deadNeed + halfdownNeed + halfupNeed; if (total == 0) @@ -5197,9 +5200,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } msg += $"({dead} 个死亡角色,{halfdown} 个 50% 以下的角色,{halfup} 个 50% 以上的角色)\r\n" + - $"收费标准:\r\n10000 {General.GameplayEquilibriumConstant.InGameCurrency} / 死亡角色\r\n" + - $"6000 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以下的角色\r\n" + - $"2000 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以上的角色"; + $"收费标准:\r\n3000 {General.GameplayEquilibriumConstant.InGameCurrency} / 死亡角色\r\n" + + $"1500 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以下的角色\r\n" + + $"500 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以上的角色"; return msg; } @@ -5241,9 +5244,9 @@ namespace Oshima.FunGame.WebAPI.Controllers { FunGameService.Reload(); FunGameSimulation.InitFunGameSimulation(); - return NetworkUtility.JsonSerialize("FunGame已重新加载。"); + return "FunGame已重新加载。"; } - return NetworkUtility.JsonSerialize("提供的参数不正确。"); + return "提供的参数不正确。"; } } } diff --git a/OshimaWebAPI/Services/RainBOTService.cs b/OshimaWebAPI/Services/RainBOTService.cs index fb00a25..a875eb3 100644 --- a/OshimaWebAPI/Services/RainBOTService.cs +++ b/OshimaWebAPI/Services/RainBOTService.cs @@ -2004,6 +2004,16 @@ namespace Oshima.FunGame.WebAPI.Services } return result; } + + if (e.Detail == "毕业礼包") + { + string msg = Controller.CreateGiftBox(uid, "毕业礼包"); + if (msg != "") + { + await SendAsync(e, "毕业礼包", string.Join("\r\n", msg)); + } + return result; + } if (uid == GeneralSettings.Master && e.Detail.StartsWith("重载FunGame", StringComparison.CurrentCultureIgnoreCase)) {