diff --git a/OshimaModules/configs/oshima-studios/oshima.fungame.items.json b/OshimaModules/configs/oshima-studios/oshima.fungame.items.json index f3852fb..7ead7ba 100644 --- a/OshimaModules/configs/oshima-studios/oshima.fungame.items.json +++ b/OshimaModules/configs/oshima-studios/oshima.fungame.items.json @@ -7,7 +7,6 @@ "ItemType": 1, "WeaponType": 1, "QualityType": 0, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -33,7 +32,6 @@ "ItemType": 1, "WeaponType": 2, "QualityType": 0, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -59,7 +57,6 @@ "ItemType": 1, "WeaponType": 3, "QualityType": 0, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -85,7 +82,6 @@ "ItemType": 1, "WeaponType": 5, "QualityType": 0, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -111,7 +107,6 @@ "ItemType": 1, "WeaponType": 11, "QualityType": 0, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -137,7 +132,6 @@ "ItemType": 1, "WeaponType": 1, "QualityType": 1, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -163,7 +157,6 @@ "ItemType": 1, "WeaponType": 2, "QualityType": 1, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -189,7 +182,6 @@ "ItemType": 1, "WeaponType": 3, "QualityType": 1, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -215,7 +207,6 @@ "ItemType": 1, "WeaponType": 4, "QualityType": 1, - "Price": 0, "Skills": { "Active": null, "Passives": [ @@ -241,7 +232,6 @@ "ItemType": 1, "WeaponType": 8, "QualityType": 1, - "Price": 0, "Skills": { "Active": null, "Passives": [ diff --git a/OshimaServers/AnonymousServer.cs b/OshimaServers/AnonymousServer.cs index f36caa7..de6f9bb 100644 --- a/OshimaServers/AnonymousServer.cs +++ b/OshimaServers/AnonymousServer.cs @@ -126,7 +126,7 @@ namespace Oshima.FunGame.OshimaServers { User user = FunGameService.GetUser(pc); // 将用户存入缓存 - FunGameService.UserIdAndUsername[user.Id] = user; + FunGameConstant.UserIdAndUsername[user.Id] = user; // 任务结算 EntityModuleConfig quests = new("quests", user.Id.ToString()); quests.LoadConfig(); diff --git a/OshimaServers/OshimaServer.cs b/OshimaServers/OshimaServer.cs index 4b9b989..169691b 100644 --- a/OshimaServers/OshimaServer.cs +++ b/OshimaServers/OshimaServer.cs @@ -1,12 +1,14 @@ using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Interface; using Milimoe.FunGame.Core.Library.Common.Addon; +using Milimoe.FunGame.Core.Library.Common.Event; using Oshima.Core; using Oshima.Core.Constant; using Oshima.FunGame.OshimaServers.Service; namespace Oshima.FunGame.OshimaServers { - public class OshimaServer : ServerPlugin + public class OshimaServer : ServerPlugin, IOpenStoreEvent { public override string Name => OshimaGameModuleConstant.Server; @@ -32,7 +34,28 @@ namespace Oshima.FunGame.OshimaServers public override void AfterLoad(ServerPluginLoader loader, params object[] objs) { + FunGameService.ServerPluginLoader ??= loader; OSMCore.InitOSMCore(); } + + public void BeforeOpenStoreEvent(object sender, GeneralEventArgs e) + { + if (e.EventMsg != "") Controller.WriteLine(e.EventMsg, Milimoe.FunGame.Core.Library.Constant.LogLevel.Debug); + } + + public void AfterOpenStoreEvent(object sender, GeneralEventArgs e) + { + + } + + public void SucceedOpenStoreEvent(object sender, GeneralEventArgs e) + { + if (e.EventMsg != "") Controller.WriteLine(e.EventMsg, Milimoe.FunGame.Core.Library.Constant.LogLevel.Debug); + } + + public void FailedOpenStoreEvent(object sender, GeneralEventArgs e) + { + + } } } diff --git a/OshimaServers/Service/FunGameActionQueue.cs b/OshimaServers/Service/FunGameActionQueue.cs index a7deaf2..27634fa 100644 --- a/OshimaServers/Service/FunGameActionQueue.cs +++ b/OshimaServers/Service/FunGameActionQueue.cs @@ -98,7 +98,7 @@ namespace Oshima.FunGame.OshimaServers.Service foreach (Skill skill in skillRewards) { Dictionary effectArgs = []; - if (FunGameService.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary? dict) && dict != null) + if (FunGameConstant.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary? dict) && dict != null) { effectArgs = new(dict); } @@ -341,7 +341,7 @@ namespace Oshima.FunGame.OshimaServers.Service foreach (Skill skill in skillRewards) { Dictionary effectArgs = []; - if (FunGameService.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary? dict) && dict != null) + if (FunGameConstant.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary? dict) && dict != null) { effectArgs = new(dict); } diff --git a/OshimaServers/Service/FunGameConstant.cs b/OshimaServers/Service/FunGameConstant.cs new file mode 100644 index 0000000..9d59089 --- /dev/null +++ b/OshimaServers/Service/FunGameConstant.cs @@ -0,0 +1,511 @@ +using Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Library.Constant; +using Oshima.FunGame.OshimaModules.Effects.OpenEffects; +using Oshima.FunGame.OshimaModules.Items; + +namespace Oshima.FunGame.OshimaServers.Service +{ + public class FunGameConstant + { + public const long CustomCharacterId = -1; + public static List Characters { get; } = []; + public static List Skills { get; } = []; + public static List PassiveSkills { get; } = []; + public static List SuperSkills { get; } = []; + public static List Magics { get; } = []; + public static List Equipment { get; } = []; + 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 ItemType[] ItemCanUsed => [ItemType.Consumable, ItemType.MagicCard, ItemType.SpecialItem, ItemType.GiftBox, ItemType.Others]; + + public static Dictionary> LevelBreakNeedyList + { + get + { + return new() + { + { + 0, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 20 }, + { nameof(升华之印), 2 } + } + }, + { + 1, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 40 }, + { nameof(升华之印), 4 } + } + }, + { + 2, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 80 }, + { nameof(升华之印), 6 }, + { nameof(流光之印), 2 } + } + }, + { + 3, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 160 }, + { nameof(升华之印), 9 }, + { nameof(流光之印), 4 } + } + }, + { + 4, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 320 }, + { nameof(升华之印), 12 }, + { nameof(流光之印), 6 }, + { nameof(永恒之印), 2 } + } + }, + { + 5, new() + { + { General.GameplayEquilibriumConstant.InGameMaterial, 640 }, + { nameof(升华之印), 16 }, + { nameof(流光之印), 9 }, + { nameof(永恒之印), 4 } + } + }, + }; + } + } + + public static Dictionary> SkillLevelUpList + { + get + { + return new() + { + { + 1, new() + { + { "角色等级", 1 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 2000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 10 }, + { nameof(技能卷轴), 1 }, + } + }, + { + 2, new() + { + { "角色等级", 12 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 5000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 30 }, + { nameof(技能卷轴), 2 }, + } + }, + { + 3, new() + { + { "角色等级", 24 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 10000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 60 }, + { nameof(技能卷轴), 4 }, + { nameof(智慧之果), 1 }, + } + }, + { + 4, new() + { + { "角色等级", 36 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 18000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 100 }, + { nameof(技能卷轴), 6 }, + { nameof(智慧之果), 2 }, + } + }, + { + 5, new() + { + { "角色等级", 48 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 30000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 150 }, + { nameof(技能卷轴), 9 }, + { nameof(智慧之果), 4 }, + { nameof(奥术符文), 1 } + } + }, + { + 6, new() + { + { "角色等级", 60 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 47000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 210 }, + { nameof(技能卷轴), 6 }, + { nameof(智慧之果), 6 }, + { nameof(奥术符文), 2 } + } + } + }; + } + } + + public static Dictionary> NormalAttackLevelUpList + { + get + { + return new() + { + { + 2, new() + { + { "角色等级", 8 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 2000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 10 }, + { nameof(技能卷轴), 1 }, + } + }, + { + 3, new() + { + { "角色等级", 16 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 5000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 30 }, + { nameof(技能卷轴), 2 }, + } + }, + { + 4, new() + { + { "角色等级", 24 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 10000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 60 }, + { nameof(技能卷轴), 4 }, + { nameof(智慧之果), 1 }, + } + }, + { + 5, new() + { + { "角色等级", 32 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 18000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 100 }, + { nameof(技能卷轴), 6 }, + { nameof(智慧之果), 2 }, + } + }, + { + 6, new() + { + { "角色等级", 40 }, + { "角色突破进度", 4 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 30000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 150 }, + { nameof(技能卷轴), 9 }, + { nameof(智慧之果), 4 }, + { nameof(奥术符文), 1 } + } + }, + { + 7, new() + { + { "角色等级", 48 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 47000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 210 }, + { nameof(技能卷轴), 12 }, + { nameof(智慧之果), 6 }, + { nameof(奥术符文), 2 } + } + }, + { + 8, new() + { + { "角色等级", 56 }, + { General.GameplayEquilibriumConstant.InGameCurrency, 70000 }, + { General.GameplayEquilibriumConstant.InGameMaterial, 280 }, + { nameof(技能卷轴), 16 }, + { nameof(智慧之果), 9 }, + { nameof(奥术符文), 4 }, + { nameof(混沌之核), 1 } + } + } + }; + } + } + + public static Dictionary> RoundRewards + { + get + { + return new() + { + { + EffectID.ExATK, + new() + { + { "exatk", Random.Shared.Next(40, 80) } + } + }, + { + EffectID.ExCritRate, + new() + { + { "excr", Math.Clamp(Random.Shared.NextDouble(), 0.25, 0.5) } + } + }, + { + EffectID.ExCritDMG, + new() + { + { "excrd", Math.Clamp(Random.Shared.NextDouble(), 0.5, 1) } + } + }, + { + EffectID.ExATK2, + new() + { + { "exatk", Math.Clamp(Random.Shared.NextDouble(), 0.15, 0.3) } + } + }, + { + EffectID.RecoverHP, + new() + { + { "hp", Random.Shared.Next(160, 640) } + } + }, + { + EffectID.RecoverMP, + new() + { + { "mp", Random.Shared.Next(140, 490) } + } + }, + { + EffectID.RecoverHP2, + new() + { + { "hp", Math.Clamp(Random.Shared.NextDouble(), 0.04, 0.08) } + } + }, + { + EffectID.RecoverMP2, + new() + { + { "mp", Math.Clamp(Random.Shared.NextDouble(), 0.09, 0.18) } + } + }, + { + EffectID.GetEP, + new() + { + { "ep", Random.Shared.Next(20, 40) } + } + } + }; + } + } + + public static Dictionary QuestList + { + get + { + return new() + { + { + "丢失的共享单车之谜", + "寻找被魔法传送走的共享单车。" + }, + { + "咖啡店的神秘顾客", + "调查每天都点奇怪饮品的神秘顾客。" + }, + { + "地铁里的幽灵乘客", + "找出在地铁里出没的半透明乘客。" + }, + { + "公园的精灵涂鸦", + "清除公园里突然出现的精灵涂鸦。" + }, + { + "手机信号的干扰源", + "找出干扰手机信号的魔法源头。" + }, + { + "外卖小哥的奇遇", + "帮助外卖小哥找回被偷走的魔法外卖。" + }, + { + "广场舞的魔法节奏", + "调查广场舞音乐中隐藏的魔法节奏。" + }, + { + "自动贩卖机的秘密", + "找出自动贩卖机里突然出现的奇怪物品。" + }, + { + "便利店的异次元入口", + "调查便利店里突然出现的异次元入口。" + }, + { + "街头艺人的魔法表演", + "调查街头艺人表演中使用的魔法。" + }, + { + "午夜电台的幽灵来电", + "调查午夜电台收到的奇怪来电。" + }, + { + "高楼大厦的秘密通道", + "寻找隐藏在高楼大厦里的秘密通道。" + }, + { + "城市下水道的神秘生物", + "调查城市下水道里出现的神秘生物。" + }, + { + "废弃工厂的魔法实验", + "调查废弃工厂里进行的秘密魔法实验。" + }, + { + "博物馆的活化雕像", + "调查博物馆里突然活化的雕像。" + }, + { + "公园的都市传说", + "调查公园里流传的都市传说。" + }, + { + "闹鬼公寓的真相", + "调查闹鬼公寓里的真相。" + }, + { + "地下酒吧的秘密交易", + "调查地下酒吧里进行的秘密魔法交易。" + }, + { + "旧书店的魔法书籍", + "寻找旧书店里隐藏的魔法书籍。" + }, + { + "涂鸦墙的预言", + "解读涂鸦墙上出现的神秘预言。" + }, + { + "黑客的魔法入侵", + "阻止黑客利用魔法入侵城市网络。" + }, + { + "高科技魔法装备的测试", + "测试新型的高科技魔法装备。" + }, + { + "无人机的魔法改造", + "改造无人机,使其拥有魔法能力。" + }, + { + "人工智能的觉醒", + "调查人工智能觉醒的原因。" + }, + { + "虚拟现实的魔法世界", + "探索虚拟现实中出现的魔法世界。" + }, + { + "智能家居的魔法故障", + "修复智能家居的魔法故障。" + }, + { + "能量饮料的魔法副作用", + "调查能量饮料的魔法副作用。" + }, + { + "社交媒体的魔法病毒", + "清除社交媒体上出现的魔法病毒。" + }, + { + "共享汽车的魔法漂移", + "调查共享汽车的魔法漂移现象。" + }, + { + "城市监控的魔法干扰", + "修复城市监控的魔法干扰。" + }, + { + "寻找丢失的魔法宠物", + "寻找在城市里走失的魔法宠物。" + }, + { + "参加魔法美食节", + "参加城市举办的魔法美食节。" + }, + { + "解开城市谜题", + "解开隐藏在城市各处的谜题。" + }, + { + "参加魔法cosplay大赛", + "参加城市举办的魔法cosplay大赛。" + }, + { + "寻找隐藏的魔法商店", + "寻找隐藏在城市里的魔法商店。" + }, + { + "制作魔法主题的街头艺术", + "在城市里创作魔法主题的街头艺术。" + }, + { + "举办一场魔法快闪活动", + "在城市里举办一场魔法快闪活动。" + }, + { + "寻找失落的魔法乐器", + "寻找失落的魔法乐器,让城市充满音乐。" + }, + { + "参加魔法运动会", + "参加城市举办的魔法运动会。" + }, + { + "拯救被困在魔法结界里的市民", + "拯救被困在城市魔法结界里的市民。" + } + }; + } + } + + public static Dictionary DrawCardProbabilities + { + get + { + return new() + { + { QualityType.White, 69.53 }, + { QualityType.Green, 15.35 }, + { QualityType.Blue, 9.48 }, + { QualityType.Purple, 4.25 }, + { QualityType.Orange, 1.33 }, + { QualityType.Red, 0.06 } + }; + } + } + + public static Dictionary PriceRanges + { + get + { + return new() + { + { QualityType.White, (200, 2000) }, + { QualityType.Green, (1500, 15000) }, + { QualityType.Blue, (5000, 50000) }, + { QualityType.Purple, (10000, 100000) }, + { QualityType.Orange, (40000, 400000) }, + { QualityType.Red, (100000, 1000000) }, + { QualityType.Gold, (500000, 5000000) } + }; + } + } + } +} diff --git a/OshimaServers/Service/FunGameService.cs b/OshimaServers/Service/FunGameService.cs index 394272d..c82c9d9 100644 --- a/OshimaServers/Service/FunGameService.cs +++ b/OshimaServers/Service/FunGameService.cs @@ -1,8 +1,8 @@ using System.Text; +using Milimoe.FunGame.Core.Api.Transmittal; using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -using Oshima.Core.Configs; using Oshima.Core.Constant; using Oshima.FunGame.OshimaModules.Characters; using Oshima.FunGame.OshimaModules.Effects.OpenEffects; @@ -13,70 +13,60 @@ namespace Oshima.FunGame.OshimaServers.Service { public class FunGameService { - public static List Characters { get; } = []; - public static List Skills { get; } = []; - public static List PassiveSkills { get; } = []; - public static List SuperSkills { get; } = []; - public static List Magics { get; } = []; - public static List Equipment { get; } = []; - 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 Bosses { get; } = []; - public static ItemType[] ItemCanUsed => [ItemType.Consumable, ItemType.MagicCard, ItemType.SpecialItem, ItemType.GiftBox, ItemType.Others]; + public static ServerPluginLoader? ServerPluginLoader { get; set; } = null; + public static WebAPIPluginLoader? WebAPIPluginLoader { get; set; } = null; public static void InitFunGame() { - Characters.Add(new OshimaShiya()); - Characters.Add(new XinYin()); - Characters.Add(new Yang()); - Characters.Add(new NanGanYu()); - Characters.Add(new NiuNan()); - Characters.Add(new DokyoMayor()); - Characters.Add(new MagicalGirl()); - Characters.Add(new QingXiang()); - Characters.Add(new QWQAQW()); - Characters.Add(new ColdBlue()); - Characters.Add(new dddovo()); - Characters.Add(new Quduoduo()); + FunGameConstant.Characters.Add(new OshimaShiya()); + FunGameConstant.Characters.Add(new XinYin()); + FunGameConstant.Characters.Add(new Yang()); + FunGameConstant.Characters.Add(new NanGanYu()); + FunGameConstant.Characters.Add(new NiuNan()); + FunGameConstant.Characters.Add(new DokyoMayor()); + FunGameConstant.Characters.Add(new MagicalGirl()); + FunGameConstant.Characters.Add(new QingXiang()); + FunGameConstant.Characters.Add(new QWQAQW()); + FunGameConstant.Characters.Add(new ColdBlue()); + FunGameConstant.Characters.Add(new dddovo()); + FunGameConstant.Characters.Add(new Quduoduo()); - Skills.AddRange([new 疾风步()]); + FunGameConstant.Skills.AddRange([new 疾风步()]); - SuperSkills.AddRange([new 嗜血本能(), new 平衡强化(), new 绝对领域(), new 精准打击(), new 三重叠加(), new 变幻之心(), new 力量爆发(), new 能量毁灭(), new 血之狂欢(), new 迅捷之势(), new 天赐之力(), new 魔法涌流()]); + FunGameConstant.SuperSkills.AddRange([new 嗜血本能(), new 平衡强化(), new 绝对领域(), new 精准打击(), new 三重叠加(), new 变幻之心(), new 力量爆发(), new 能量毁灭(), new 血之狂欢(), new 迅捷之势(), new 天赐之力(), new 魔法涌流()]); - PassiveSkills.AddRange([new META马(), new 心灵之火(), new 魔法震荡(), new 灵能反射(), new 智慧与力量(), new 致命打击(), new 毁灭之势(), new 枯竭打击(), new 破釜沉舟(), new 累积之压(), new 敏捷之刃(), new 弱者猎手()]); + FunGameConstant.PassiveSkills.AddRange([new META马(), new 心灵之火(), new 魔法震荡(), new 灵能反射(), new 智慧与力量(), new 致命打击(), new 毁灭之势(), new 枯竭打击(), new 破釜沉舟(), new 累积之压(), new 敏捷之刃(), new 弱者猎手()]); - Magics.AddRange([new 冰霜攻击(), new 火之矢(), new 水之矢(), new 风之轮(), new 石之锤(), new 心灵之霞(), new 次元上升(), new 暗物质(), new 回复术(), new 治愈术(), + FunGameConstant.Magics.AddRange([new 冰霜攻击(), new 火之矢(), new 水之矢(), new 风之轮(), new 石之锤(), new 心灵之霞(), new 次元上升(), new 暗物质(), new 回复术(), new 治愈术(), new 时间加速(), new 时间减速(), new 沉默十字(), new 反魔法领域()]); Dictionary exItems = Factory.GetGameModuleInstances(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Item); - Equipment.AddRange(exItems.Values.Where(i => (int)i.ItemType >= 0 && (int)i.ItemType < 5)); - Equipment.AddRange([new 攻击之爪8(), new 攻击之爪20(), new 攻击之爪35(), new 攻击之爪50()]); + FunGameConstant.Equipment.AddRange(exItems.Values.Where(i => (int)i.ItemType >= 0 && (int)i.ItemType < 5)); + FunGameConstant.Equipment.AddRange([new 攻击之爪8(), new 攻击之爪20(), new 攻击之爪35(), new 攻击之爪50()]); - Items.AddRange(exItems.Values.Where(i => (int)i.ItemType > 4)); - Items.AddRange([new 小经验书(), new 中经验书(), new 大经验书(), new 升华之印(), new 流光之印(), new 永恒之印(), new 技能卷轴(), new 智慧之果(), new 奥术符文(), new 混沌之核(), + 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()]); - AllItems.AddRange(Equipment); - AllItems.AddRange(Items); + FunGameConstant.AllItems.AddRange(FunGameConstant.Equipment); + FunGameConstant.AllItems.AddRange(FunGameConstant.Items); - Skill?[] activeSkills = [.. Equipment.Select(i => i.Skills.Active), .. Items.Select(i => i.Skills.Active)]; + Skill?[] activeSkills = [.. FunGameConstant.Equipment.Select(i => i.Skills.Active), .. FunGameConstant.Items.Select(i => i.Skills.Active)]; foreach (Skill? skill in activeSkills) { if (skill != null) { - ItemSkills.Add(skill); + FunGameConstant.ItemSkills.Add(skill); } } - ItemSkills.AddRange([.. Equipment.SelectMany(i => i.Skills.Passives), .. Items.SelectMany(i => i.Skills.Passives)]); + FunGameConstant.ItemSkills.AddRange([.. FunGameConstant.Equipment.SelectMany(i => i.Skills.Passives), .. FunGameConstant.Items.SelectMany(i => i.Skills.Passives)]); - AllSkills.AddRange(Magics); - AllSkills.AddRange(Skills); - AllSkills.AddRange(PassiveSkills); - AllSkills.AddRange(ItemSkills); - AllSkills.AddRange(SuperSkills); + FunGameConstant.AllSkills.AddRange(FunGameConstant.Magics); + FunGameConstant.AllSkills.AddRange(FunGameConstant.Skills); + FunGameConstant.AllSkills.AddRange(FunGameConstant.PassiveSkills); + FunGameConstant.AllSkills.AddRange(FunGameConstant.ItemSkills); + FunGameConstant.AllSkills.AddRange(FunGameConstant.SuperSkills); } public static List GenerateMagicCards(int count, QualityType? qualityType = null) @@ -140,7 +130,7 @@ namespace Oshima.FunGame.OshimaServers.Service public static void GenerateAndAddSkillToMagicCard(Item item, int total) { - Skill magic = Magics[Random.Shared.Next(Magics.Count)].Copy(); + Skill magic = FunGameConstant.Magics[Random.Shared.Next(FunGameConstant.Magics.Count)].Copy(); magic.Guid = item.Guid; magic.Level = (int)item.QualityType switch { @@ -371,15 +361,15 @@ namespace Oshima.FunGame.OshimaServers.Service public static void Reload() { - Characters.Clear(); - Equipment.Clear(); - Skills.Clear(); - SuperSkills.Clear(); - PassiveSkills.Clear(); - Magics.Clear(); - AllItems.Clear(); - ItemSkills.Clear(); - AllSkills.Clear(); + FunGameConstant.Characters.Clear(); + FunGameConstant.Equipment.Clear(); + FunGameConstant.Skills.Clear(); + FunGameConstant.SuperSkills.Clear(); + FunGameConstant.PassiveSkills.Clear(); + FunGameConstant.Magics.Clear(); + FunGameConstant.AllItems.Clear(); + FunGameConstant.ItemSkills.Clear(); + FunGameConstant.AllSkills.Clear(); InitFunGame(); } @@ -471,7 +461,7 @@ namespace Oshima.FunGame.OshimaServers.Service foreach (Item inventoryItem in items) { - Item realItem = inventoryItem.Copy(true, true, true, AllItems, AllSkills); + Item realItem = inventoryItem.Copy(true, true, true, FunGameConstant.AllItems, FunGameConstant.AllSkills); realItem.User = user; user.Inventory.Items.Add(realItem); } @@ -495,7 +485,7 @@ namespace Oshima.FunGame.OshimaServers.Service inventoryCharacter.InitialHR = tempCharacter.InitialHR; inventoryCharacter.InitialMR = tempCharacter.InitialMR; } - Character realCharacter = CharacterBuilder.Build(inventoryCharacter, false, true, user.Inventory, AllItems, AllSkills, false); + Character realCharacter = CharacterBuilder.Build(inventoryCharacter, false, true, user.Inventory, FunGameConstant.AllItems, FunGameConstant.AllSkills, false); // 自动回血 DateTime now = DateTime.Now; int seconds = (int)(now - user.LastTime).TotalSeconds; @@ -586,9 +576,9 @@ namespace Oshima.FunGame.OshimaServers.Service int r = Random.Shared.Next(8); double q = Random.Shared.NextDouble() * 100; QualityType type = QualityType.White; - foreach (QualityType typeTemp in DrawCardProbabilities.Keys.OrderByDescending(o => (int)o)) + foreach (QualityType typeTemp in FunGameConstant.DrawCardProbabilities.Keys.OrderByDescending(o => (int)o)) { - if (q <= DrawCardProbabilities[typeTemp]) + if (q <= FunGameConstant.DrawCardProbabilities[typeTemp]) { type = typeTemp; break; @@ -599,7 +589,7 @@ namespace Oshima.FunGame.OshimaServers.Service { case 1: if ((int)type > (int)QualityType.Orange) type = QualityType.Orange; - Item[] 武器 = Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type).ToArray(); + Item[] 武器 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type).ToArray(); Item a = 武器[Random.Shared.Next(武器.Length)].Copy(); SetSellAndTradeTime(a); user.Inventory.Items.Add(a); @@ -608,7 +598,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 2: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 防具 = Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type).ToArray(); + Item[] 防具 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type).ToArray(); Item b = 防具[Random.Shared.Next(防具.Length)].Copy(); SetSellAndTradeTime(b); user.Inventory.Items.Add(b); @@ -617,7 +607,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 3: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 鞋子 = Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type).ToArray(); + Item[] 鞋子 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type).ToArray(); Item c = 鞋子[Random.Shared.Next(鞋子.Length)].Copy(); SetSellAndTradeTime(c); user.Inventory.Items.Add(c); @@ -626,7 +616,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 4: if ((int)type > (int)QualityType.Purple) type = QualityType.Purple; - Item[] 饰品 = Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type).ToArray(); + Item[] 饰品 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type).ToArray(); Item d = 饰品[Random.Shared.Next(饰品.Length)].Copy(); SetSellAndTradeTime(d); user.Inventory.Items.Add(d); @@ -634,7 +624,7 @@ namespace Oshima.FunGame.OshimaServers.Service break; case 5: - Character character = Characters[Random.Shared.Next(Characters.Count)].Copy(); + Character character = FunGameConstant.Characters[Random.Shared.Next(FunGameConstant.Characters.Count)].Copy(); AddCharacterSkills(character, 1, 0, 0); if (user.Inventory.Characters.Any(c => c.Id == character.Id)) { @@ -657,7 +647,7 @@ namespace Oshima.FunGame.OshimaServers.Service break; case 7: - Item 物品 = Items[Random.Shared.Next(Items.Count)].Copy(); + Item 物品 = FunGameConstant.Items[Random.Shared.Next(FunGameConstant.Items.Count)].Copy(); SetSellAndTradeTime(物品); user.Inventory.Items.Add(物品); msg += ItemSet.GetQualityTypeName(物品.QualityType) + ItemSet.GetItemTypeName(物品.ItemType) + "【" + 物品.Name + "】!\r\n" + 物品.Description; @@ -693,7 +683,7 @@ namespace Oshima.FunGame.OshimaServers.Service // 根据签到天数调整概率 double daysFactor = Math.Min(days * 0.02, 30); - Dictionary adjustedProbabilities = new(DrawCardProbabilities); + Dictionary adjustedProbabilities = new(FunGameConstant.DrawCardProbabilities); foreach (QualityType typeTemp in adjustedProbabilities.Keys) { adjustedProbabilities[typeTemp] += daysFactor; @@ -715,7 +705,7 @@ namespace Oshima.FunGame.OshimaServers.Service { case 1: if ((int)type > (int)QualityType.Orange) type = QualityType.Orange; - Item[] 武器 = Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type).ToArray(); + Item[] 武器 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type).ToArray(); Item a = 武器[Random.Shared.Next(武器.Length)].Copy(); SetSellAndTradeTime(a); user.Inventory.Items.Add(a); @@ -724,7 +714,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 2: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 防具 = Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type).ToArray(); + Item[] 防具 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type).ToArray(); Item b = 防具[Random.Shared.Next(防具.Length)].Copy(); SetSellAndTradeTime(b); user.Inventory.Items.Add(b); @@ -733,7 +723,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 3: if ((int)type > (int)QualityType.Green) type = QualityType.Green; - Item[] 鞋子 = Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type).ToArray(); + Item[] 鞋子 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type).ToArray(); Item c = 鞋子[Random.Shared.Next(鞋子.Length)].Copy(); SetSellAndTradeTime(c); user.Inventory.Items.Add(c); @@ -742,7 +732,7 @@ namespace Oshima.FunGame.OshimaServers.Service case 4: if ((int)type > (int)QualityType.Purple) type = QualityType.Purple; - Item[] 饰品 = Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type).ToArray(); + Item[] 饰品 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type).ToArray(); Item d = 饰品[Random.Shared.Next(饰品.Length)].Copy(); SetSellAndTradeTime(d); user.Inventory.Items.Add(d); @@ -1052,7 +1042,7 @@ namespace Oshima.FunGame.OshimaServers.Service { break; } - if (ItemCanUsed.Contains(item.ItemType)) + if (FunGameConstant.ItemCanUsed.Contains(item.ItemType)) { if (item.RemainUseTimes <= 0) { @@ -1106,7 +1096,7 @@ namespace Oshima.FunGame.OshimaServers.Service public static string GetLevelBreakNeedy(int levelBreak) { - if (LevelBreakNeedyList.TryGetValue(levelBreak, out Dictionary? needy) && needy != null && needy.Count > 0) + if (FunGameConstant.LevelBreakNeedyList.TryGetValue(levelBreak, out Dictionary? needy) && needy != null && needy.Count > 0) { return string.Join(",", needy.Select(kv => kv.Key + " * " + kv.Value)); } @@ -1205,7 +1195,7 @@ namespace Oshima.FunGame.OshimaServers.Service public static string GetSkillLevelUpNeedy(int level) { - if (SkillLevelUpList.TryGetValue(level, out Dictionary? needy) && needy != null && needy.Count > 0) + if (FunGameConstant.SkillLevelUpList.TryGetValue(level, out Dictionary? needy) && needy != null && needy.Count > 0) { return GetNeedyInfo(needy); } @@ -1214,7 +1204,7 @@ namespace Oshima.FunGame.OshimaServers.Service public static string GetNormalAttackLevelUpNeedy(int level) { - if (NormalAttackLevelUpList.TryGetValue(level, out Dictionary? needy) && needy != null && needy.Count > 0) + if (FunGameConstant.NormalAttackLevelUpList.TryGetValue(level, out Dictionary? needy) && needy != null && needy.Count > 0) { return GetNeedyInfo(needy); } @@ -1270,10 +1260,10 @@ namespace Oshima.FunGame.OshimaServers.Service boss.Level = cLevel; boss.NormalAttack.Level = naLevel; boss.NormalAttack.HardnessTime = 6; - Item[] weapons = Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == 4).ToArray(); - Item[] armors = Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == 1).ToArray(); - Item[] shoes = Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == 1).ToArray(); - Item[] accessory = Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == 3).ToArray(); + Item[] weapons = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == 4).ToArray(); + Item[] armors = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == 1).ToArray(); + Item[] shoes = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == 1).ToArray(); + Item[] accessory = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == 3).ToArray(); Item? a = null, b = null, c = null, d = null, d2 = null; if (weapons.Length > 0) { @@ -1373,476 +1363,6 @@ namespace Oshima.FunGame.OshimaServers.Service } } - public static Dictionary> LevelBreakNeedyList - { - get - { - return new() - { - { - 0, new() - { - { General.GameplayEquilibriumConstant.InGameMaterial, 80 }, - { nameof(升华之印), 10 } - } - }, - { - 1, new() - { - { General.GameplayEquilibriumConstant.InGameMaterial, 400 }, - { nameof(升华之印), 20 } - } - }, - { - 2, new() - { - { General.GameplayEquilibriumConstant.InGameMaterial, 960 }, - { nameof(升华之印), 30 }, - { nameof(流光之印), 10 } - } - }, - { - 3, new() - { - { General.GameplayEquilibriumConstant.InGameMaterial, 1760 }, - { nameof(升华之印), 40 }, - { nameof(流光之印), 20 } - } - }, - { - 4, new() - { - { General.GameplayEquilibriumConstant.InGameMaterial, 2800 }, - { nameof(升华之印), 50 }, - { nameof(流光之印), 30 }, - { nameof(永恒之印), 10 } - } - }, - { - 5, new() - { - { General.GameplayEquilibriumConstant.InGameMaterial, 4080 }, - { nameof(升华之印), 60 }, - { nameof(流光之印), 40 }, - { nameof(永恒之印), 20 } - } - }, - }; - } - } - - public static Dictionary> SkillLevelUpList - { - get - { - return new() - { - { - 1, new() - { - { "角色等级", 1 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 2000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 10 }, - { nameof(技能卷轴), 1 }, - } - }, - { - 2, new() - { - { "角色等级", 12 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 5000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 30 }, - { nameof(技能卷轴), 2 }, - } - }, - { - 3, new() - { - { "角色等级", 24 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 10000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 60 }, - { nameof(技能卷轴), 3 }, - { nameof(智慧之果), 1 }, - } - }, - { - 4, new() - { - { "角色等级", 36 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 18000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 100 }, - { nameof(技能卷轴), 4 }, - { nameof(智慧之果), 2 }, - } - }, - { - 5, new() - { - { "角色等级", 48 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 30000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 150 }, - { nameof(技能卷轴), 5 }, - { nameof(智慧之果), 3 }, - { nameof(奥术符文), 1 } - } - }, - { - 6, new() - { - { "角色等级", 60 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 47000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 210 }, - { nameof(技能卷轴), 6 }, - { nameof(智慧之果), 4 }, - { nameof(奥术符文), 2 } - } - } - }; - } - } - - public static Dictionary> NormalAttackLevelUpList - { - get - { - return new() - { - { - 2, new() - { - { "角色等级", 8 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 2000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 10 }, - { nameof(技能卷轴), 1 }, - } - }, - { - 3, new() - { - { "角色等级", 16 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 5000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 30 }, - { nameof(技能卷轴), 2 }, - } - }, - { - 4, new() - { - { "角色等级", 24 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 10000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 60 }, - { nameof(技能卷轴), 3 }, - { nameof(智慧之果), 1 }, - } - }, - { - 5, new() - { - { "角色等级", 32 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 18000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 100 }, - { nameof(技能卷轴), 4 }, - { nameof(智慧之果), 2 }, - } - }, - { - 6, new() - { - { "角色等级", 40 }, - { "角色突破进度", 4 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 30000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 150 }, - { nameof(技能卷轴), 5 }, - { nameof(智慧之果), 3 }, - { nameof(奥术符文), 1 } - } - }, - { - 7, new() - { - { "角色等级", 48 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 47000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 210 }, - { nameof(技能卷轴), 6 }, - { nameof(智慧之果), 4 }, - { nameof(奥术符文), 2 } - } - }, - { - 8, new() - { - { "角色等级", 56 }, - { General.GameplayEquilibriumConstant.InGameCurrency, 70000 }, - { General.GameplayEquilibriumConstant.InGameMaterial, 280 }, - { nameof(技能卷轴), 7 }, - { nameof(智慧之果), 5 }, - { nameof(奥术符文), 3 }, - { nameof(混沌之核), 1 } - } - } - }; - } - } - - public static Dictionary> RoundRewards - { - get - { - return new() - { - { - EffectID.ExATK, - new() - { - { "exatk", Random.Shared.Next(40, 80) } - } - }, - { - EffectID.ExCritRate, - new() - { - { "excr", Math.Clamp(Random.Shared.NextDouble(), 0.25, 0.5) } - } - }, - { - EffectID.ExCritDMG, - new() - { - { "excrd", Math.Clamp(Random.Shared.NextDouble(), 0.5, 1) } - } - }, - { - EffectID.ExATK2, - new() - { - { "exatk", Math.Clamp(Random.Shared.NextDouble(), 0.15, 0.3) } - } - }, - { - EffectID.RecoverHP, - new() - { - { "hp", Random.Shared.Next(160, 640) } - } - }, - { - EffectID.RecoverMP, - new() - { - { "mp", Random.Shared.Next(140, 490) } - } - }, - { - EffectID.RecoverHP2, - new() - { - { "hp", Math.Clamp(Random.Shared.NextDouble(), 0.04, 0.08) } - } - }, - { - EffectID.RecoverMP2, - new() - { - { "mp", Math.Clamp(Random.Shared.NextDouble(), 0.09, 0.18) } - } - }, - { - EffectID.GetEP, - new() - { - { "ep", Random.Shared.Next(20, 40) } - } - } - }; - } - } - - public static Dictionary QuestList - { - get - { - return new() - { - { - "丢失的共享单车之谜", - "寻找被魔法传送走的共享单车。" - }, - { - "咖啡店的神秘顾客", - "调查每天都点奇怪饮品的神秘顾客。" - }, - { - "地铁里的幽灵乘客", - "找出在地铁里出没的半透明乘客。" - }, - { - "公园的精灵涂鸦", - "清除公园里突然出现的精灵涂鸦。" - }, - { - "手机信号的干扰源", - "找出干扰手机信号的魔法源头。" - }, - { - "外卖小哥的奇遇", - "帮助外卖小哥找回被偷走的魔法外卖。" - }, - { - "广场舞的魔法节奏", - "调查广场舞音乐中隐藏的魔法节奏。" - }, - { - "自动贩卖机的秘密", - "找出自动贩卖机里突然出现的奇怪物品。" - }, - { - "便利店的异次元入口", - "调查便利店里突然出现的异次元入口。" - }, - { - "街头艺人的魔法表演", - "调查街头艺人表演中使用的魔法。" - }, - { - "午夜电台的幽灵来电", - "调查午夜电台收到的奇怪来电。" - }, - { - "高楼大厦的秘密通道", - "寻找隐藏在高楼大厦里的秘密通道。" - }, - { - "城市下水道的神秘生物", - "调查城市下水道里出现的神秘生物。" - }, - { - "废弃工厂的魔法实验", - "调查废弃工厂里进行的秘密魔法实验。" - }, - { - "博物馆的活化雕像", - "调查博物馆里突然活化的雕像。" - }, - { - "公园的都市传说", - "调查公园里流传的都市传说。" - }, - { - "闹鬼公寓的真相", - "调查闹鬼公寓里的真相。" - }, - { - "地下酒吧的秘密交易", - "调查地下酒吧里进行的秘密魔法交易。" - }, - { - "旧书店的魔法书籍", - "寻找旧书店里隐藏的魔法书籍。" - }, - { - "涂鸦墙的预言", - "解读涂鸦墙上出现的神秘预言。" - }, - { - "黑客的魔法入侵", - "阻止黑客利用魔法入侵城市网络。" - }, - { - "高科技魔法装备的测试", - "测试新型的高科技魔法装备。" - }, - { - "无人机的魔法改造", - "改造无人机,使其拥有魔法能力。" - }, - { - "人工智能的觉醒", - "调查人工智能觉醒的原因。" - }, - { - "虚拟现实的魔法世界", - "探索虚拟现实中出现的魔法世界。" - }, - { - "智能家居的魔法故障", - "修复智能家居的魔法故障。" - }, - { - "能量饮料的魔法副作用", - "调查能量饮料的魔法副作用。" - }, - { - "社交媒体的魔法病毒", - "清除社交媒体上出现的魔法病毒。" - }, - { - "共享汽车的魔法漂移", - "调查共享汽车的魔法漂移现象。" - }, - { - "城市监控的魔法干扰", - "修复城市监控的魔法干扰。" - }, - { - "寻找丢失的魔法宠物", - "寻找在城市里走失的魔法宠物。" - }, - { - "参加魔法美食节", - "参加城市举办的魔法美食节。" - }, - { - "解开城市谜题", - "解开隐藏在城市各处的谜题。" - }, - { - "参加魔法cosplay大赛", - "参加城市举办的魔法cosplay大赛。" - }, - { - "寻找隐藏的魔法商店", - "寻找隐藏在城市里的魔法商店。" - }, - { - "制作魔法主题的街头艺术", - "在城市里创作魔法主题的街头艺术。" - }, - { - "举办一场魔法快闪活动", - "在城市里举办一场魔法快闪活动。" - }, - { - "寻找失落的魔法乐器", - "寻找失落的魔法乐器,让城市充满音乐。" - }, - { - "参加魔法运动会", - "参加城市举办的魔法运动会。" - }, - { - "拯救被困在魔法结界里的市民", - "拯救被困在城市魔法结界里的市民。" - } - }; - } - } - - public static Dictionary DrawCardProbabilities - { - get - { - return new() - { - { QualityType.White, 69.53 }, - { QualityType.Green, 15.35 }, - { QualityType.Blue, 9.48 }, - { QualityType.Purple, 4.25 }, - { QualityType.Orange, 1.33 }, - { QualityType.Red, 0.06 } - }; - } - } - public static Dictionary> GenerateRoundRewards(int maxRound) { Dictionary> roundRewards = []; @@ -1857,7 +1377,7 @@ namespace Oshima.FunGame.OshimaServers.Service List skills = []; // 添加回合奖励特效 - long effectID = (long)RoundRewards.Keys.ToArray()[Random.Shared.Next(RoundRewards.Count)]; + long effectID = (long)FunGameConstant.RoundRewards.Keys.ToArray()[Random.Shared.Next(FunGameConstant.RoundRewards.Count)]; Dictionary args = []; if (effectID > (long)EffectID.Active_Start) { @@ -1945,25 +1465,25 @@ namespace Oshima.FunGame.OshimaServers.Service Dictionary items = []; items[General.GameplayEquilibriumConstant.InGameCurrency] = minutes * 20; items[General.GameplayEquilibriumConstant.InGameMaterial] = minutes / 8 * 1; - int index = Random.Shared.Next(AllItems.Count); - Item item = AllItems[index]; + int index = Random.Shared.Next(FunGameConstant.AllItems.Count); + Item item = FunGameConstant.AllItems[index]; items.Add(item.Name, 1); while (true) { - int index2 = Random.Shared.Next(AllItems.Count); + int index2 = Random.Shared.Next(FunGameConstant.AllItems.Count); if (index2 != index) { - Item item2 = AllItems[index2]; + Item item2 = FunGameConstant.AllItems[index2]; items.Add(item2.Name, 1); break; } } - string name = QuestList.Keys.OrderBy(o => Random.Shared.Next()).First(); + string name = FunGameConstant.QuestList.Keys.OrderBy(o => Random.Shared.Next()).First(); Quest quest = new() { Id = quests.Count > 0 ? quests.Values.Max(q => q.Id) + 1 : 1, Name = name, - Description = QuestList[name], + Description = FunGameConstant.QuestList[name], EstimatedMinutes = minutes, Awards = items }; @@ -2011,7 +1531,7 @@ namespace Oshima.FunGame.OshimaServers.Service { user.Inventory.Materials += quest.Awards[name]; } - else if (AllItems.FirstOrDefault(i => i.Name == name) is Item item) + else if (FunGameConstant.AllItems.FirstOrDefault(i => i.Name == name) is Item item) { Item newItem = item.Copy(); newItem.User = user; @@ -2026,17 +1546,26 @@ namespace Oshima.FunGame.OshimaServers.Service return result; } - public static string CheckDailyStore(EntityModuleConfig store) + public static string CheckDailyStore(EntityModuleConfig store, User? user = null) { if (store.Count == 0) { // 生成每日商店 - Store daily = new("每日商店"); + Store daily = new($"{(user != null ? user.Username + "的" : "")}每日商店"); for (int i = 0; i < 4; i++) { - int index = Random.Shared.Next(AllItems.Count); - Item item = AllItems[index].Copy(); - double price = Random.Shared.NextDouble() * 10000 * (int)item.QualityType * Random.Shared.Next(5,20); + int index = Random.Shared.Next(FunGameConstant.AllItems.Count); + Item item = FunGameConstant.AllItems[index].Copy(); + (int min, int max) = (0, 0); + if (FunGameConstant.PriceRanges.TryGetValue(item.QualityType, out (int Min, int Max) range)) + { + (min, max) = (range.Min, range.Max); + } + double price = Random.Shared.Next(min, max); + if (price == 0) + { + price = (Random.Shared.NextDouble() + 0.1) * Random.Shared.Next(1000, 10000) * Random.Shared.Next((int)item.QualityType + 2, 6 + ((int)item.QualityType)); + } item.Price = Calculation.Round2Digits(price); daily.AddItem(item, Random.Shared.Next(1, 3)); } @@ -2055,5 +1584,71 @@ namespace Oshima.FunGame.OshimaServers.Service } } } + + public static string StoreBuyItem(Store store, Goods goods, User user, int count) + { + string msg = ""; + if (goods.Stock - count < 0) + { + return msg = $"此商品【{goods.Name}】库存不足,无法购买!\r\n你想要购买 {count} 件,但库存只有 {goods.Stock} 件。"; + } + + foreach (string needy in goods.Prices.Keys) + { + if (needy == General.GameplayEquilibriumConstant.InGameCurrency) + { + double reduce = Calculation.Round2Digits(goods.Prices[needy] * count); + if (user.Inventory.Credits >= reduce) + { + user.Inventory.Credits -= reduce; + } + else + { + return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameCurrency}不足 {reduce} 呢,无法购买【{goods.Name}】!"); + } + } + else if (needy == General.GameplayEquilibriumConstant.InGameMaterial) + { + double reduce = Calculation.Round2Digits(goods.Prices[needy] * count); + if (user.Inventory.Materials >= reduce) + { + user.Inventory.Materials -= reduce; + } + else + { + return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce} 呢,无法购买【{goods.Name}】!"); + } + } + } + + foreach (Item item in goods.Items) + { + for (int i = 0; i < count; i++) + { + Item newItem = item.Copy(); + SetSellAndTradeTime(newItem); + if (goods.GetPrice(General.GameplayEquilibriumConstant.InGameCurrency, out double price) && price > 0) + { + newItem.Price = Calculation.Round2Digits(price * 0.35); + } + newItem.User = user; + user.Inventory.Items.Add(newItem); + } + } + + goods.Stock -= count; + + msg += $"恭喜你成功购买 {count} 件【{goods.Name}】!\r\n" + + $"总计消费:{(goods.Prices.Count > 0 ? string.Join("、", goods.Prices.Select(kv => $"{kv.Value * count:0.##} {kv.Key}")) : "免单")}\r\n" + + $"包含物品:{string.Join("、", goods.Items.Select(i => $"[{ItemSet.GetQualityTypeName(i.QualityType)}|{ItemSet.GetItemTypeName(i.ItemType)}] {i.Name} * {count}"))}"; + + return msg; + } + + public static string Select_CheckAutoKey(SQLHelper SQLHelper, string AutoKey) + { + SQLHelper.Parameters["@AutoKey"] = AutoKey; + return $"{Milimoe.FunGame.Core.Library.SQLScript.Entity.UserQuery.Select_Users} {Milimoe.FunGame.Core.Library.SQLScript.Constant.Command_Where} {Milimoe.FunGame.Core.Library.SQLScript.Entity.UserQuery.Column_AutoKey} = @AutoKey"; + } } } diff --git a/OshimaServers/Service/FunGameSimulation.cs b/OshimaServers/Service/FunGameSimulation.cs index af5628e..3aaf13d 100644 --- a/OshimaServers/Service/FunGameSimulation.cs +++ b/OshimaServers/Service/FunGameSimulation.cs @@ -24,7 +24,7 @@ namespace Oshima.FunGame.OshimaServers.Service CharacterStatistics.Clear(); TeamCharacterStatistics.Clear(); - foreach (Character c in FunGameService.Characters) + foreach (Character c in FunGameConstant.Characters) { CharacterStatistics.Add(c, new()); } @@ -38,7 +38,7 @@ namespace Oshima.FunGame.OshimaServers.Service } } - foreach (Character c in FunGameService.Characters) + foreach (Character c in FunGameConstant.Characters) { TeamCharacterStatistics.Add(c, new()); } @@ -76,7 +76,7 @@ namespace Oshima.FunGame.OshimaServers.Service // M = 5, W = 0, P1 = 0, P3 = 2 // M = 5, W = 1, P1 = 0, P3 = 0 - List list = new(FunGameService.Characters); + List list = new(FunGameConstant.Characters); if (list.Count > 11) { @@ -270,7 +270,7 @@ namespace Oshima.FunGame.OshimaServers.Service foreach (Skill skill in skillRewards) { Dictionary effectArgs = []; - if (FunGameService.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary? dict) && dict != null) + if (FunGameConstant.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary? dict) && dict != null) { effectArgs = new(dict); } @@ -589,10 +589,10 @@ namespace Oshima.FunGame.OshimaServers.Service { foreach (Character character in queue.Queue) { - Item[] 武器 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == wQuality).ToArray(); - Item[] 防具 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == aQuality).ToArray(); - Item[] 鞋子 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == sQuality).ToArray(); - Item[] 饰品 = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == acQuality).ToArray(); + Item[] 武器 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("11") && (int)i.QualityType == wQuality).ToArray(); + Item[] 防具 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("12") && (int)i.QualityType == aQuality).ToArray(); + Item[] 鞋子 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("13") && (int)i.QualityType == sQuality).ToArray(); + Item[] 饰品 = FunGameConstant.Equipment.Where(i => i.Id.ToString().StartsWith("14") && (int)i.QualityType == acQuality).ToArray(); Item? a = null, b = null, c = null, d = null; if (武器.Length > 0) { diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index 8104368..82e1982 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -3,9 +3,12 @@ using System.Text.RegularExpressions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; +using Milimoe.FunGame.Core.Api.Transmittal; using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Library.Common.Event; using Milimoe.FunGame.Core.Library.Constant; +using Milimoe.FunGame.Core.Library.SQLScript.Entity; using Oshima.Core.Configs; using Oshima.FunGame.OshimaModules.Characters; using Oshima.FunGame.OshimaModules.Items; @@ -24,6 +27,7 @@ namespace Oshima.FunGame.WebAPI.Controllers private const int drawCardReduce = 2000; private const int drawCardReduce_Material = 10; private const string noSaved = "你还没有创建存档!请发送【创建存档】创建。"; + private const string refused = "暂时无法使用此指令。"; [AllowAnonymous] [HttpGet("test")] @@ -39,9 +43,9 @@ namespace Oshima.FunGame.WebAPI.Controllers [HttpGet("stats")] public string GetStats([FromQuery] int? id = null) { - if (id != null && id > 0 && id <= FunGameService.Characters.Count) + if (id != null && id > 0 && id <= FunGameConstant.Characters.Count) { - Character character = FunGameService.Characters[Convert.ToInt32(id) - 1]; + Character character = FunGameConstant.Characters[Convert.ToInt32(id) - 1]; if (FunGameSimulation.CharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) { StringBuilder builder = new(); @@ -94,9 +98,9 @@ namespace Oshima.FunGame.WebAPI.Controllers [HttpGet("teamstats")] public string GetTeamStats([FromQuery] int? id = null) { - if (id != null && id > 0 && id <= FunGameService.Characters.Count) + if (id != null && id > 0 && id <= FunGameConstant.Characters.Count) { - Character character = FunGameService.Characters[Convert.ToInt32(id) - 1]; + Character character = FunGameConstant.Characters[Convert.ToInt32(id) - 1]; if (FunGameSimulation.TeamCharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) { StringBuilder builder = new(); @@ -234,9 +238,9 @@ namespace Oshima.FunGame.WebAPI.Controllers [HttpGet("characterinfo")] public string GetCharacterInfo([FromQuery] int? id = null) { - if (id != null && id > 0 && id <= FunGameService.Characters.Count) + if (id != null && id > 0 && id <= FunGameConstant.Characters.Count) { - Character c = FunGameService.Characters[Convert.ToInt32(id) - 1].Copy(); + Character c = FunGameConstant.Characters[Convert.ToInt32(id) - 1].Copy(); c.Level = General.GameplayEquilibriumConstant.MaxLevel; c.NormalAttack.Level = General.GameplayEquilibriumConstant.MaxNormalAttackLevel; FunGameService.AddCharacterSkills(c, 1, General.GameplayEquilibriumConstant.MaxSkillLevel, General.GameplayEquilibriumConstant.MaxSuperSkillLevel); @@ -248,9 +252,9 @@ namespace Oshima.FunGame.WebAPI.Controllers [AllowAnonymous] [HttpGet("skillinfo")] - public string GetSkillInfo([FromQuery] long? qq = null, [FromQuery] long? id = null) + public string GetSkillInfo([FromQuery] long? uid = null, [FromQuery] long? id = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); List msg = []; @@ -263,11 +267,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } else { - character = FunGameService.Characters[1].Copy(); + character = FunGameConstant.Characters[1].Copy(); msg.Add($"技能展示的属性基于演示角色:[ {character} ]"); } - IEnumerable skills = FunGameService.AllSkills; - if (id != null && FunGameService.Characters.Count > 1) + IEnumerable skills = FunGameConstant.AllSkills; + if (id != null && FunGameConstant.Characters.Count > 1) { Skill? skill = skills.Where(s => s.Id == id).FirstOrDefault()?.Copy(); if (skill != null) @@ -289,9 +293,9 @@ namespace Oshima.FunGame.WebAPI.Controllers [AllowAnonymous] [HttpGet("skillinfoname")] - public string GetSkillInfo_Name([FromQuery] long? qq = null, [FromQuery] string? name = null) + public string GetSkillInfo_Name([FromQuery] long? uid = null, [FromQuery] string? name = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); List msg = []; @@ -304,11 +308,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } else { - character = FunGameService.Characters[1].Copy(); + character = FunGameConstant.Characters[1].Copy(); msg.Add($"技能展示的属性基于演示角色:[ {character} ]"); } - IEnumerable skills = FunGameService.AllSkills; - if (name != null && FunGameService.Characters.Count > 1) + IEnumerable skills = FunGameConstant.AllSkills; + if (name != null && FunGameConstant.Characters.Count > 1) { Skill? skill = skills.Where(s => s.Name == name).FirstOrDefault()?.Copy(); if (skill != null) @@ -330,9 +334,9 @@ namespace Oshima.FunGame.WebAPI.Controllers [AllowAnonymous] [HttpGet("iteminfo")] - public string GetItemInfo([FromQuery] long? qq = null, [FromQuery] long? id = null) + public string GetItemInfo([FromQuery] long? uid = null, [FromQuery] long? id = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); List msg = []; @@ -345,10 +349,10 @@ namespace Oshima.FunGame.WebAPI.Controllers } else { - character = FunGameService.Characters[1].Copy(); + character = FunGameConstant.Characters[1].Copy(); msg.Add($"技能展示的属性基于演示角色:[ {character} ]"); } - IEnumerable items = FunGameService.AllItems; + IEnumerable items = FunGameConstant.AllItems; if (id != null) { Item? item = items.Where(i => i.Id == id).FirstOrDefault()?.Copy(); @@ -366,9 +370,9 @@ namespace Oshima.FunGame.WebAPI.Controllers [AllowAnonymous] [HttpGet("iteminfoname")] - public string GetItemInfo_Name([FromQuery] long? qq = null, [FromQuery] string? name = null) + public string GetItemInfo_Name([FromQuery] long? uid = null, [FromQuery] string? name = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); List msg = []; @@ -381,10 +385,10 @@ namespace Oshima.FunGame.WebAPI.Controllers } else { - character = FunGameService.Characters[1].Copy(); + character = FunGameConstant.Characters[1].Copy(); msg.Add($"技能展示的属性基于演示角色:[ {character} ]"); } - IEnumerable items = FunGameService.AllItems; + IEnumerable items = FunGameConstant.AllItems; if (name != null) { Item? item = items.Where(i => i.Name == name).FirstOrDefault()?.Copy(); @@ -421,34 +425,88 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("createsaved")] - public string CreateSaved([FromQuery] long? qq = null, [FromQuery] string? name = null) + public string CreateSaved([FromQuery] long? uid = null, [FromQuery] string? name = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); - string username = name ?? FunGameService.GenerateRandomChineseUserName(); + string username = FunGameService.GenerateRandomChineseUserName(); + using SQLHelper? sqlHelper = Factory.OpenFactory.GetSQLHelper(); - PluginConfig pc = new("saved", userid.ToString()); - pc.LoadConfig(); + if (name != null && sqlHelper != null) + { + try + { + if (name.Trim() == "") + { + return NetworkUtility.JsonSerialize("未提供接入ID!"); + } + Logger.LogInformation("[Reg] 接入ID:{name}", name); + sqlHelper.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sqlHelper, name)); + if (sqlHelper.Success) + { + return NetworkUtility.JsonSerialize("你已经创建过存档!"); + } + string password = name.Encrypt(name); + sqlHelper.NewTransaction(); + sqlHelper.Execute(UserQuery.Insert_Register(sqlHelper, username, password, "", "", name)); + if (sqlHelper.Result == SQLResult.Success) + { + sqlHelper.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sqlHelper, name)); + if (sqlHelper.Success) + { + User user = Factory.GetUser(sqlHelper.DataSet); + sqlHelper.Commit(); + user.Inventory.Credits = 5000; + user.Inventory.Characters.Add(new CustomCharacter(FunGameConstant.CustomCharacterId, username, nickname: username)); + FunGameConstant.UserIdAndUsername[user.Id] = user; + PluginConfig pc = new("saved", user.Id.ToString()); + pc.LoadConfig(); + pc.Add("user", user); + pc.SaveConfig(); + return NetworkUtility.JsonSerialize($"创建存档成功!你的昵称是【{username}】。"); + } + else + { + return NetworkUtility.JsonSerialize("无法处理注册,创建存档失败!"); + } + } + else + { + sqlHelper.Rollback(); + } + } + catch (Exception e) + { + sqlHelper.Rollback(); + Logger.LogError(e, "Error: "); + } + return NetworkUtility.JsonSerialize("无法处理注册,创建存档失败!"); + } + else if (uid != null && uid != 0) + { + PluginConfig pc = new("saved", uid.Value.ToString()); + pc.LoadConfig(); - if (pc.Count == 0) - { - User user = Factory.GetUser(userid, username, DateTime.Now, DateTime.Now, userid + "@qq.com", username); - user.Inventory.Credits = 5000000; - user.Inventory.Characters.Add(new CustomCharacter(userid, username)); - FunGameService.UserIdAndUsername[userid] = user; - pc.Add("user", user); - pc.SaveConfig(); - return NetworkUtility.JsonSerialize($"创建存档成功!你的用户名是【{username}】。"); - } - else - { - return NetworkUtility.JsonSerialize("你已经创建过存档!"); + if (pc.Count == 0) + { + User user = Factory.GetUser(uid.Value, username, DateTime.Now, DateTime.Now, uid + "@qq.com", username); + user.Inventory.Credits = 5000; + user.Inventory.Characters.Add(new CustomCharacter(uid.Value, username)); + FunGameConstant.UserIdAndUsername[uid.Value] = user; + pc.Add("user", user); + pc.SaveConfig(); + return NetworkUtility.JsonSerialize($"创建存档成功!你的昵称是【{username}】。"); + } + else + { + return NetworkUtility.JsonSerialize("你已经创建过存档!"); + } } + return NetworkUtility.JsonSerialize("创建存档失败!"); } [HttpPost("restoresaved")] - public string RestoreSaved([FromQuery] long? qq = null) + public string RestoreSaved([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -456,11 +514,11 @@ namespace Oshima.FunGame.WebAPI.Controllers if (pc.Count > 0) { User user = FunGameService.GetUser(pc); - user.Inventory.Credits = 5000000; + user.Inventory.Credits = 5000; user.Inventory.Materials = 0; user.Inventory.Characters.Clear(); user.Inventory.Items.Clear(); - user.Inventory.Characters.Add(new CustomCharacter(userid, user.Username)); + user.Inventory.Characters.Add(new CustomCharacter(FunGameConstant.CustomCharacterId, user.Username)); user.LastTime = DateTime.Now; pc.Add("user", user); pc.SaveConfig(); @@ -473,9 +531,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showsaved")] - public string ShowSaved([FromQuery] long? qq = null) + public string ShowSaved([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -494,7 +552,7 @@ namespace Oshima.FunGame.WebAPI.Controllers Dictionary characters = user.Inventory.Characters .Select((character, index) => new { character, index }) .ToDictionary(x => x.character, x => x.index + 1); - builder.AppendLine($"小队成员:{(squad.Length > 0 ? string.Join(" / ", squad.Select(c => $"[#{characters[c]}]{c.Name}({c.Level})")) : "空")}"); + builder.AppendLine($"小队成员:{(squad.Length > 0 ? string.Join(" / ", squad.Select(c => $"[#{characters[c]}]{c.NickName}({c.Level})")) : "空")}"); if (user.Inventory.Training.Count > 0) { builder.AppendLine($"正在练级:{string.Join(" / ", user.Inventory.Characters.Where(c => user.Inventory.Training.ContainsKey(c.Id)).Select(c => c.ToStringWithLevelWithOutUser()))}"); @@ -531,9 +589,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("rename")] - public string ReName([FromQuery] long? qq = null) + public string ReName([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -553,19 +611,21 @@ namespace Oshima.FunGame.WebAPI.Controllers } user.Username = FunGameService.GenerateRandomChineseUserName(); - if (user.Inventory.Characters.FirstOrDefault(c => c.Id == user.Id) is Character character) + user.NickName = user.Username; + if (user.Inventory.Characters.FirstOrDefault(c => c.Id == FunGameConstant.CustomCharacterId) is Character character) { character.Name = user.Username; + character.NickName = user.NickName; } if (user.Inventory.Name.EndsWith("的库存")) { user.Inventory.Name = user.Username + "的库存"; } - FunGameService.UserIdAndUsername[user.Id] = user; + FunGameConstant.UserIdAndUsername[user.Id] = user; user.LastTime = DateTime.Now; pc.Add("user", user); pc.SaveConfig(); - return NetworkUtility.JsonSerialize($"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},你的新名字是【{user.Username}】"); + return NetworkUtility.JsonSerialize($"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},你的新昵称是【{user.Username}】"); } else { @@ -574,9 +634,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("randomcustom")] - public string RandomCustomCharacter([FromQuery] long? qq = null, [FromQuery] bool? confirm = null) + public string RandomCustomCharacter([FromQuery] long? uid = null, [FromQuery] bool? confirm = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); bool isConfirm = confirm ?? false; PluginConfig pc = new("saved", userid.ToString()); @@ -588,7 +648,7 @@ namespace Oshima.FunGame.WebAPI.Controllers if (pc.Count > 0) { User user = FunGameService.GetUser(pc); - if (user.Inventory.Characters.FirstOrDefault(c => c.Id == user.Id) is Character character) + if (user.Inventory.Characters.FirstOrDefault(c => c.Id == FunGameConstant.CustomCharacterId) is Character character) { PrimaryAttribute oldPA = character.PrimaryAttribute; double oldSTR = character.InitialSTR; @@ -639,7 +699,7 @@ namespace Oshima.FunGame.WebAPI.Controllers { return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce} 呢,无法重随自建角色属性!"); } - newCustom = new CustomCharacter(user.Id, ""); + newCustom = new CustomCharacter(FunGameConstant.CustomCharacterId, ""); user.LastTime = DateTime.Now; pc.Add("user", user); pc.SaveConfig(); @@ -652,7 +712,7 @@ namespace Oshima.FunGame.WebAPI.Controllers $"初始智力:{oldINT}(+{oldINTG}/Lv)=> {newCustom.InitialINT}(+{newCustom.INTGrowth}/Lv)\r\n" + $"请发送【确认角色重随】来确认更新,或者发送【取消角色重随】来取消操作。"); } - else if (newCustom.Id == user.Id) + else if (newCustom.Id == FunGameConstant.CustomCharacterId) { return NetworkUtility.JsonSerialize($"你已经有一个待确认的重随属性如下:\r\n" + $"核心属性:{CharacterSet.GetPrimaryAttributeName(oldPA)} => {CharacterSet.GetPrimaryAttributeName(newCustom.PrimaryAttribute)}\r\n" + @@ -679,9 +739,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("cancelrandomcustom")] - public string CancelRandomCustomCharacter([FromQuery] long? qq = null) + public string CancelRandomCustomCharacter([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -708,9 +768,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("inventoryinfo")] - public string GetInventoryInfo([FromQuery] long? qq = null) + public string GetInventoryInfo([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -728,9 +788,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("inventoryinfo2")] - public List GetInventoryInfo2([FromQuery] long? qq = null, [FromQuery] int? page = null) + public List GetInventoryInfo2([FromQuery] long? uid = null, [FromQuery] int? page = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int showPage = page ?? 1; if (showPage <= 0) showPage = 1; @@ -804,9 +864,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("inventoryinfo3")] - public List GetInventoryInfo3([FromQuery] long? qq = null, [FromQuery] int? page = null, [FromQuery] int? order = null, [FromQuery] int? orderqty = null) + public List GetInventoryInfo3([FromQuery] long? uid = null, [FromQuery] int? page = null, [FromQuery] int? order = null, [FromQuery] int? orderqty = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int showPage = page ?? 1; if (showPage <= 0) showPage = 1; @@ -879,7 +939,7 @@ namespace Oshima.FunGame.WebAPI.Controllers } str += $"物品序号:{itemsIndex}\r\n"; str += $"拥有数量:{objs.Count}(" + (first.IsEquipment ? $"可装备数量:{objs.Count(i => i.Character is null)}," : "") + - (FunGameService.ItemCanUsed.Contains(first.ItemType) ? $"可使用数量:{objs.Count(i => i.RemainUseTimes > 0)}," : "") + + (FunGameConstant.ItemCanUsed.Contains(first.ItemType) ? $"可使用数量:{objs.Count(i => i.RemainUseTimes > 0)}," : "") + $"可出售数量:{objs.Count(i => i.IsSellable)},可交易数量:{objs.Count(i => i.IsTradable)})"; list.Add(str); } @@ -898,9 +958,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("inventoryinfo4")] - public List GetInventoryInfo4([FromQuery] long? qq = null, [FromQuery] int? page = null, [FromQuery] int? type = null) + public List GetInventoryInfo4([FromQuery] long? uid = null, [FromQuery] int? page = null, [FromQuery] int? type = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int showPage = page ?? 1; int itemtype = type ?? -1; if (showPage <= 0) showPage = 1; @@ -964,7 +1024,7 @@ namespace Oshima.FunGame.WebAPI.Controllers } str += $"物品序号:{itemsIndex}\r\n"; str += $"拥有数量:{objs.Count}(" + (first.IsEquipment ? $"可装备数量:{objs.Count(i => i.Character is null)}," : "") + - (FunGameService.ItemCanUsed.Contains(first.ItemType) ? $"可使用数量:{objs.Count(i => i.RemainUseTimes > 0)}," : "") + + (FunGameConstant.ItemCanUsed.Contains(first.ItemType) ? $"可使用数量:{objs.Count(i => i.RemainUseTimes > 0)}," : "") + $"可出售数量:{objs.Count(i => i.IsSellable)},可交易数量:{objs.Count(i => i.IsTradable)})"; list.Add(str); } @@ -983,9 +1043,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("inventoryinfo5")] - public List GetInventoryInfo5([FromQuery] long? qq = null, [FromQuery] int? page = null) + public List GetInventoryInfo5([FromQuery] long? uid = null, [FromQuery] int? page = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int showPage = page ?? 1; if (showPage <= 0) showPage = 1; @@ -1045,9 +1105,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("newcustomcharacter")] - public string NewCustomCharacter([FromQuery] long? qq = null) + public string NewCustomCharacter([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -1055,13 +1115,13 @@ namespace Oshima.FunGame.WebAPI.Controllers if (pc.Count > 0) { User user = FunGameService.GetUser(pc); - if (user.Inventory.Characters.Any(c => c.Id == user.Id)) + if (user.Inventory.Characters.Any(c => c.Id == FunGameConstant.CustomCharacterId)) { return NetworkUtility.JsonSerialize($"你已经拥有一个自建角色【{user.Username}】,无法再创建!"); } else { - user.Inventory.Characters.Add(new CustomCharacter(userid, user.Username)); + user.Inventory.Characters.Add(new CustomCharacter(FunGameConstant.CustomCharacterId, user.Username)); user.LastTime = DateTime.Now; pc.Add("user", user); pc.SaveConfig(); @@ -1075,9 +1135,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("drawcard")] - public string DrawCard([FromQuery] long? qq = null) + public string DrawCard([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -1118,9 +1178,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("drawcards")] - public List DrawCards([FromQuery] long? qq = null) + public List DrawCards([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -1166,9 +1226,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("drawcardm")] - public string DrawCard_Material([FromQuery] long? qq = null) + public string DrawCard_Material([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -1209,9 +1269,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("drawcardsm")] - public List DrawCards_Material([FromQuery] long? qq = null) + public List DrawCards_Material([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -1257,9 +1317,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("exchangecredits")] - public string ExchangeCredits([FromQuery] long? qq = null, [FromQuery] double? materials = null) + public string ExchangeCredits([FromQuery] long? uid = null, [FromQuery] double? materials = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); double useMaterials = materials ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -1293,11 +1353,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showcharacterinfo")] - public string GetCharacterInfoFromInventory([FromQuery] long? qq = null, [FromQuery] int? seq = null, [FromQuery] bool? simple = null) + public string GetCharacterInfoFromInventory([FromQuery] long? uid = null, [FromQuery] int? seq = null, [FromQuery] bool? simple = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int cIndex = seq ?? 0; bool isSimple = simple ?? false; @@ -1345,11 +1405,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showcharacterskills")] - public string GetCharacterSkills([FromQuery] long? qq = null, [FromQuery] int? seq = null) + public string GetCharacterSkills([FromQuery] long? uid = null, [FromQuery] int? seq = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int cIndex = seq ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -1388,11 +1448,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showcharacteritems")] - public string GetCharacterItems([FromQuery] long? qq = null, [FromQuery] int? seq = null) + public string GetCharacterItems([FromQuery] long? uid = null, [FromQuery] int? seq = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int cIndex = seq ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -1431,11 +1491,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showiteminfo")] - public string GetItemInfoFromInventory([FromQuery] long? qq = null, [FromQuery] int? seq = null) + public string GetItemInfoFromInventory([FromQuery] long? uid = null, [FromQuery] int? seq = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int itemIndex = seq ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -1467,11 +1527,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("equipitem")] - public string EquipItem([FromQuery] long? qq = null, [FromQuery] int? c = null, [FromQuery] int? i = null) + public string EquipItem([FromQuery] long? uid = null, [FromQuery] int? c = null, [FromQuery] int? i = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; int itemIndex = i ?? 0; @@ -1533,11 +1593,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("unequipitem")] - public string UnEquipItem([FromQuery] long? qq = null, [FromQuery] int? c = null, [FromQuery] int? i = null) + public string UnEquipItem([FromQuery] long? uid = null, [FromQuery] int? c = null, [FromQuery] int? i = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; EquipSlotType type = (EquipSlotType)(i ?? 0); @@ -1580,11 +1640,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("fightcustom")] - public List FightCustom([FromQuery] long? qq = null, [FromQuery] long? eqq = null, [FromQuery] bool? all = null) + public List FightCustom([FromQuery] long? uid = null, [FromQuery] long? eqq = null, [FromQuery] bool? all = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); long enemyid = eqq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); bool showAllRound = all ?? false; @@ -1638,18 +1698,18 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("fightcustom2")] - public List FightCustom2([FromQuery] long? qq = null, [FromQuery] string? name = null, [FromQuery] bool? all = null) + public List FightCustom2([FromQuery] long? uid = null, [FromQuery] string? name = null, [FromQuery] bool? all = null) { try { if (name != null) { - long enemyid = FunGameService.UserIdAndUsername.Where(kv => kv.Value.Username == name).Select(kv => kv.Key).FirstOrDefault(); + long enemyid = FunGameConstant.UserIdAndUsername.Where(kv => kv.Value.Username == name).Select(kv => kv.Key).FirstOrDefault(); if (enemyid == 0) { - return [$"找不到此名称对应的玩家!"]; + return [$"找不到此昵称对应的玩家!"]; } - return FightCustom(qq, enemyid, all); + return FightCustom(uid, enemyid, all); } return [$"决斗发起失败!"]; } @@ -1660,11 +1720,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("fightcustomteam")] - public List FightCustomTeam([FromQuery] long? qq = null, [FromQuery] long? eqq = null, [FromQuery] bool? all = null) + public List FightCustomTeam([FromQuery] long? uid = null, [FromQuery] long? eqq = null, [FromQuery] bool? all = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); long enemyid = eqq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); bool showAllRound = all ?? false; @@ -1736,18 +1796,18 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("fightcustomteam2")] - public List FightCustomTeam2([FromQuery] long? qq = null, [FromQuery] string? name = null, [FromQuery] bool? all = null) + public List FightCustomTeam2([FromQuery] long? uid = null, [FromQuery] string? name = null, [FromQuery] bool? all = null) { try { if (name != null) { - long enemyid = FunGameService.UserIdAndUsername.Where(kv => kv.Value.Username == name).Select(kv => kv.Key).FirstOrDefault(); + long enemyid = FunGameConstant.UserIdAndUsername.Where(kv => kv.Value.Username == name).Select(kv => kv.Key).FirstOrDefault(); if (enemyid == 0) { - return [$"找不到此名称对应的玩家!"]; + return [$"找不到此昵称对应的玩家!"]; } - return FightCustomTeam(qq, enemyid, all); + return FightCustomTeam(uid, enemyid, all); } return [$"决斗发起失败!"]; } @@ -1758,11 +1818,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("useitem")] - public string UseItem([FromQuery] long? qq = null, [FromQuery] int? id = null, [FromBody] int[]? characters = null) + public string UseItem([FromQuery] long? uid = null, [FromQuery] int? id = null, [FromBody] int[]? characters = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int itemIndex = id ?? 0; List charactersIndex = characters?.ToList() ?? []; @@ -1778,7 +1838,7 @@ namespace Oshima.FunGame.WebAPI.Controllers if (itemIndex > 0 && itemIndex <= user.Inventory.Items.Count) { item = user.Inventory.Items.ToList()[itemIndex - 1]; - if (FunGameService.ItemCanUsed.Contains(item.ItemType)) + if (FunGameConstant.ItemCanUsed.Contains(item.ItemType)) { if (item.RemainUseTimes <= 0) { @@ -1825,11 +1885,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("useitem2")] - public string UseItem2([FromQuery] long? qq = null, [FromQuery] string? name = null, [FromQuery] int? count = null, [FromBody] int[]? characters = null) + public string UseItem2([FromQuery] long? uid = 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)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); string itemName = name ?? ""; int useCount = count ?? 0; List charactersIndex = characters?.ToList() ?? []; @@ -1893,11 +1953,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("useitem3")] - public string UseItem3([FromQuery] long? qq = null, [FromQuery] int? id = null, [FromQuery] int? id2 = null, [FromQuery] bool? c = null) + public string UseItem3([FromQuery] long? uid = null, [FromQuery] int? id = null, [FromQuery] int? id2 = null, [FromQuery] bool? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int itemIndex = id ?? 0; int itemToIndex = id2 ?? 0; bool isCharacter = c ?? false; @@ -1996,11 +2056,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("characterlevelup")] - public string CharacterLevelUp([FromQuery] long? qq = null, [FromQuery] int? c = null, [FromQuery] int? count = null) + public string CharacterLevelUp([FromQuery] long? uid = null, [FromQuery] int? c = null, [FromQuery] int? count = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; int upCount = count ?? 0; @@ -2065,9 +2125,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("getlevelbreakneedy")] - public string GetLevelBreakNeedy([FromQuery] long? qq = null, [FromQuery] int? id = null) + public string GetLevelBreakNeedy([FromQuery] long? uid = null, [FromQuery] int? id = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = id ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -2101,11 +2161,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("characterlevelbreak")] - public string CharacterLevelBreak([FromQuery] long? qq = null, [FromQuery] int? c = null) + public string CharacterLevelBreak([FromQuery] long? uid = null, [FromQuery] int? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -2132,7 +2192,7 @@ namespace Oshima.FunGame.WebAPI.Controllers int originalBreak = character.LevelBreak; - if (FunGameService.LevelBreakNeedyList.TryGetValue(originalBreak + 1, out Dictionary? needy) && needy != null && needy.Count > 0) + if (FunGameConstant.LevelBreakNeedyList.TryGetValue(originalBreak + 1, out Dictionary? needy) && needy != null && needy.Count > 0) { foreach (string key in needy.Keys) { @@ -2200,9 +2260,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("createitem")] - public string CreateItem([FromQuery] long? qq = null, [FromQuery] string? name = null, [FromQuery] int? count = null, [FromQuery] long? target = null) + public string CreateItem([FromQuery] long? uid = null, [FromQuery] string? name = null, [FromQuery] int? count = null, [FromQuery] long? target = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? 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)); @@ -2271,7 +2331,7 @@ namespace Oshima.FunGame.WebAPI.Controllers } } } - else if (FunGameService.AllItems.FirstOrDefault(i => i.Name == itemName) is Item item) + else if (FunGameConstant.AllItems.FirstOrDefault(i => i.Name == itemName) is Item item) { for (int i = 0; i < itemCount; i++) { @@ -2307,11 +2367,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("decomposeitem")] - public string DecomposeItem([FromQuery] long? qq = null, [FromBody] int[]? items = null) + public string DecomposeItem([FromQuery] long? uid = null, [FromBody] int[]? items = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int[] ids = items ?? []; PluginConfig pc = new("saved", userid.ToString()); @@ -2336,12 +2396,12 @@ namespace Oshima.FunGame.WebAPI.Controllers { double gained = item.QualityType switch { - QualityType.Gold => 80, - QualityType.Red => 55, - QualityType.Orange => 35, - QualityType.Purple => 20, - QualityType.Blue => 10, - QualityType.Green => 4, + QualityType.Gold => 28, + QualityType.Red => 21, + QualityType.Orange => 15, + QualityType.Purple => 10, + QualityType.Blue => 6, + QualityType.Green => 3, _ => 1 }; totalGained += gained; @@ -2370,11 +2430,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("decomposeitem2")] - public string DecomposeItem2([FromQuery] long? qq = null, [FromQuery] string? name = null, [FromQuery] int? count = null) + public string DecomposeItem2([FromQuery] long? uid = null, [FromQuery] string? name = null, [FromQuery] int? count = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); string itemName = name ?? ""; int useCount = count ?? 0; @@ -2404,12 +2464,12 @@ namespace Oshima.FunGame.WebAPI.Controllers { double gained = item.QualityType switch { - QualityType.Gold => 80, - QualityType.Red => 55, - QualityType.Orange => 35, - QualityType.Purple => 20, - QualityType.Blue => 10, - QualityType.Green => 4, + QualityType.Gold => 28, + QualityType.Red => 21, + QualityType.Orange => 15, + QualityType.Purple => 10, + QualityType.Blue => 6, + QualityType.Green => 3, _ => 1 }; totalGained += gained; @@ -2442,11 +2502,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("decomposeitem3")] - public string DecomposeItem3([FromQuery] long? qq = null, [FromQuery] int? q = null) + public string DecomposeItem3([FromQuery] long? uid = null, [FromQuery] int? q = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int qType = q ?? 0; if (qType < 0 || qType > (int)QualityType.Gold) @@ -2472,12 +2532,12 @@ namespace Oshima.FunGame.WebAPI.Controllers int successCount = 0; double gained = items.First().QualityType switch { - QualityType.Gold => 80, - QualityType.Red => 55, - QualityType.Orange => 35, - QualityType.Purple => 20, - QualityType.Blue => 10, - QualityType.Green => 4, + QualityType.Gold => 28, + QualityType.Red => 21, + QualityType.Orange => 15, + QualityType.Purple => 10, + QualityType.Blue => 6, + QualityType.Green => 3, _ => 1 }; @@ -2512,11 +2572,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("conflatemagiccardpack")] - public string ConflateMagicCardPack([FromQuery] long? qq = null, [FromBody] int[]? items = null) + public string ConflateMagicCardPack([FromQuery] long? uid = null, [FromBody] int[]? items = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); List itemsIndex = items?.ToList() ?? []; PluginConfig pc = new("saved", userid.ToString()); @@ -2585,11 +2645,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("setmain")] - public string SetMain([FromQuery] long? qq = null, [FromQuery] int? c = null) + public string SetMain([FromQuery] long? uid = null, [FromQuery] int? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -2627,11 +2687,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("starttraining")] - public string StartTraining([FromQuery] long? qq = null, [FromQuery] int? c = null) + public string StartTraining([FromQuery] long? uid = null, [FromQuery] int? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -2674,11 +2734,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("stoptraining")] - public string StopTraining([FromQuery] long? qq = null) + public string StopTraining([FromQuery] long? uid = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -2748,11 +2808,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("gettraininginfo")] - public string GetTrainingInfo([FromQuery] long? qq = null) + public string GetTrainingInfo([FromQuery] long? uid = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -2794,9 +2854,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("getskilllevelupneedy")] - public string GetSkillLevelUpNeedy([FromQuery] long? qq = null, [FromQuery] int? c = null, [FromQuery] string? s = null) + public string GetSkillLevelUpNeedy([FromQuery] long? uid = null, [FromQuery] int? c = null, [FromQuery] string? s = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; string skillName = s ?? ""; @@ -2842,11 +2902,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("skilllevelup")] - public string SkillLevelUp([FromQuery] long? qq = null, [FromQuery] int? c = null, [FromQuery] string? s = null) + public string SkillLevelUp([FromQuery] long? uid = null, [FromQuery] int? c = null, [FromQuery] string? s = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; string skillName = s ?? ""; @@ -2878,7 +2938,7 @@ namespace Oshima.FunGame.WebAPI.Controllers return NetworkUtility.JsonSerialize($"此技能【{skill.Name}】已经升至满级!"); } - if (FunGameService.SkillLevelUpList.TryGetValue(skill.Level + 1, out Dictionary? needy) && needy != null && needy.Count > 0) + if (FunGameConstant.SkillLevelUpList.TryGetValue(skill.Level + 1, out Dictionary? needy) && needy != null && needy.Count > 0) { foreach (string key in needy.Keys) { @@ -2983,9 +3043,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("getnormalattacklevelupneedy")] - public string GetNormalAttackLevelUpNeedy([FromQuery] long? qq = null, [FromQuery] int? c = null) + public string GetNormalAttackLevelUpNeedy([FromQuery] long? uid = null, [FromQuery] int? c = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -3020,11 +3080,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("normalattacklevelup")] - public string NormalAttackLevelUp([FromQuery] long? qq = null, [FromQuery] int? c = null) + public string NormalAttackLevelUp([FromQuery] long? uid = null, [FromQuery] int? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -3050,7 +3110,7 @@ namespace Oshima.FunGame.WebAPI.Controllers return NetworkUtility.JsonSerialize($"角色 [ {character} ] 的【{na.Name}】已经升至满级!"); } - if (FunGameService.NormalAttackLevelUpList.TryGetValue(na.Level + 1, out Dictionary? needy) && needy != null && needy.Count > 0) + if (FunGameConstant.NormalAttackLevelUpList.TryGetValue(na.Level + 1, out Dictionary? needy) && needy != null && needy.Count > 0) { foreach (string key in needy.Keys) { @@ -3179,9 +3239,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("fightboss")] - public List FightBoss([FromQuery] long? qq = null, [FromQuery] int? index = null, [FromQuery] bool? all = null) + public List FightBoss([FromQuery] long? uid = null, [FromQuery] int? index = null, [FromQuery] bool? all = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int bossIndex = index ?? 0; bool showAllRound = all ?? false; @@ -3199,7 +3259,7 @@ namespace Oshima.FunGame.WebAPI.Controllers return [$"主战角色重伤未愈,当前生命值低于 10%,请先等待生命值自动回复或设置其他主战角色!"]; } - Character boss2 = CharacterBuilder.Build(boss, false, true, null, FunGameService.AllItems, FunGameService.AllSkills, false); + Character boss2 = CharacterBuilder.Build(boss, false, true, null, FunGameConstant.AllItems, FunGameConstant.AllSkills, false); List msgs = FunGameActionQueue.NewAndStartGame([user.Inventory.MainCharacter, boss2], false, false, false, false, showAllRound); if (boss2.HP <= 0) @@ -3234,11 +3294,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("addsquad")] - public string AddSquad([FromQuery] long? qq = null, [FromQuery] int? c = null) + public string AddSquad([FromQuery] long? uid = null, [FromQuery] int? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -3288,11 +3348,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("removesquad")] - public string RemoveSquad([FromQuery] long? qq = null, [FromQuery] int? c = null) + public string RemoveSquad([FromQuery] long? uid = null, [FromQuery] int? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int characterIndex = c ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -3336,11 +3396,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("setsquad")] - public string SetSquad([FromQuery] long? qq = null, [FromBody] int[]? c = null) + public string SetSquad([FromQuery] long? uid = null, [FromBody] int[]? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int[] characterIndexs = c ?? []; PluginConfig pc = new("saved", userid.ToString()); @@ -3383,11 +3443,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("clearsquad")] - public string ClearSquad([FromQuery] long? qq = null, [FromBody] int[]? c = null) + public string ClearSquad([FromQuery] long? uid = null, [FromBody] int[]? c = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int[] characterIndexs = c ?? []; PluginConfig pc = new("saved", userid.ToString()); @@ -3415,11 +3475,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showsquad")] - public string ShowSquad([FromQuery] long? qq = null) + public string ShowSquad([FromQuery] long? uid = null) { try { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -3442,9 +3502,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("fightbossteam")] - public List FightBossTeam([FromQuery] long? qq = null, [FromQuery] int? index = null, [FromQuery] bool? all = null) + public List FightBossTeam([FromQuery] long? uid = null, [FromQuery] int? index = null, [FromQuery] bool? all = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int bossIndex = index ?? 0; bool showAllRound = all ?? false; @@ -3466,7 +3526,7 @@ namespace Oshima.FunGame.WebAPI.Controllers string.Join("\r\n", user.Inventory.Characters.Where(c => user.Inventory.Squad.Contains(c.Id)))]; } - Character boss2 = CharacterBuilder.Build(boss, false, true, null, FunGameService.AllItems, FunGameService.AllSkills, false); + Character boss2 = CharacterBuilder.Build(boss, false, true, null, FunGameConstant.AllItems, FunGameConstant.AllSkills, false); Team team1 = new($"{user.Username}的小队", squad); Team team2 = new($"Boss", [boss2]); List msgs = FunGameActionQueue.NewAndStartTeamGame([team1, team2], showAllRound: showAllRound); @@ -3503,9 +3563,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("checkquestlist")] - public string CheckQuestList([FromQuery] long? qq = null) + public string CheckQuestList([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -3532,9 +3592,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("checkworkingquest")] - public string CheckWorkingQuest([FromQuery] long? qq = null) + public string CheckWorkingQuest([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -3569,9 +3629,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("acceptquest")] - public string AcceptQuest([FromQuery] long? qq = null, [FromQuery] int? id = null) + public string AcceptQuest([FromQuery] long? uid = null, [FromQuery] int? id = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int questid = id ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -3627,9 +3687,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("settlequest")] - public string SettleQuest([FromQuery] long? qq = null) + public string SettleQuest([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -3657,9 +3717,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showmaincharacterorsquadstatus")] - public string ShowMainCharacterOrSquadStatus([FromQuery] long? qq = null, [FromQuery] bool? squad = null) + public string ShowMainCharacterOrSquadStatus([FromQuery] long? uid = null, [FromQuery] bool? squad = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); bool showSquad = squad ?? false; PluginConfig pc = new("saved", userid.ToString()); @@ -3693,9 +3753,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("signin")] - public string SignIn([FromQuery] long? qq = null) + public string SignIn([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -3743,9 +3803,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("joinclub")] - public string JoinClub([FromQuery] long? qq = null, [FromQuery] long? id = null) + public string JoinClub([FromQuery] long? uid = null, [FromQuery] long? id = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); long clubid = id ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -3802,9 +3862,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("quitclub")] - public string QuitClub([FromQuery] long? qq = null) + public string QuitClub([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -3859,9 +3919,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("createclub")] - public string CreateClub([FromQuery] long? qq = null, [FromQuery] bool? @public = null, [FromQuery] string? prefix = null) + public string CreateClub([FromQuery] long? uid = null, [FromQuery] bool? @public = null, [FromQuery] string? prefix = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); bool isPublic = @public ?? false; string clubPrefix = prefix ?? ""; @@ -3936,9 +3996,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showclubinfo")] - public string ShowClubInfo([FromQuery] long? qq = null) + public string ShowClubInfo([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -3959,7 +4019,7 @@ namespace Oshima.FunGame.WebAPI.Controllers if (club != null) { string master = "无"; - if (FunGameService.UserIdAndUsername.TryGetValue(club.Master?.Id ?? 0, out User? user2) && user2 != null) + if (FunGameConstant.UserIdAndUsername.TryGetValue(club.Master?.Id ?? 0, out User? user2) && user2 != null) { master = user2.Username; } @@ -3998,9 +4058,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showclubmemberlist")] - public string ShowClubMemberList([FromQuery] long? qq = null, [FromQuery] int? type = null) + public string ShowClubMemberList([FromQuery] long? uid = null, [FromQuery] int? type = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); int showType = type ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -4033,9 +4093,9 @@ namespace Oshima.FunGame.WebAPI.Controllers { admins.Add(club.Master.Id); } - foreach (long uid in admins) + foreach (long uid2 in admins) { - if (FunGameService.UserIdAndUsername.TryGetValue(uid, out User? user2) && user2 != null) + if (FunGameConstant.UserIdAndUsername.TryGetValue(uid2, out User? user2) && user2 != null) { builer.AppendLine($"{count}."); builer.AppendLine($"UID:{user2.Id}"); @@ -4050,9 +4110,9 @@ namespace Oshima.FunGame.WebAPI.Controllers { builer.AppendLine($"☆--- 社团 [ {club.Name} ] 申请人列表 ---☆"); count = 1; - foreach (long uid in club.Applicants.Keys) + foreach (long uid2 in club.Applicants.Keys) { - if (FunGameService.UserIdAndUsername.TryGetValue(uid, out User? user2) && user2 != null) + if (FunGameConstant.UserIdAndUsername.TryGetValue(uid2, out User? user2) && user2 != null) { builer.AppendLine($"{count}."); builer.AppendLine($"UID:{user2.Id}"); @@ -4071,9 +4131,9 @@ namespace Oshima.FunGame.WebAPI.Controllers default: builer.AppendLine($"☆--- 社团 [ {club.Name} ] 成员列表 ---☆"); count = 1; - foreach (long uid in club.Members.Keys) + foreach (long uid2 in club.Members.Keys) { - if (FunGameService.UserIdAndUsername.TryGetValue(uid, out User? user2) && user2 != null) + if (FunGameConstant.UserIdAndUsername.TryGetValue(uid2, out User? user2) && user2 != null) { builer.AppendLine($"{count}."); builer.AppendLine($"UID:{user2.Id}"); @@ -4111,9 +4171,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("disbandclub")] - public string DisbandClub([FromQuery] long? qq = null) + public string DisbandClub([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -4188,9 +4248,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("approveclub")] - public string ApproveClub([FromQuery] long? qq = null, [FromQuery] long? id = null, [FromQuery] bool? approval = null) + public string ApproveClub([FromQuery] long? uid = null, [FromQuery] long? id = null, [FromQuery] bool? approval = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); long applicant = id ?? 0; bool isApproval = approval ?? false; @@ -4281,9 +4341,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("kickclub")] - public string KickClub([FromQuery] long? qq = null, [FromQuery] long? id = null) + public string KickClub([FromQuery] long? uid = null, [FromQuery] long? id = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); long kickid = id ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -4365,9 +4425,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("changeclub")] - public string ChangeClub([FromQuery] long? qq = null, [FromQuery] string? part = null, [FromBody] string[]? args = null) + public string ChangeClub([FromQuery] long? uid = null, [FromQuery] string? part = null, [FromBody] string[]? args = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); string name = part?.Trim().ToLower() ?? ""; string[] values = args ?? []; @@ -4405,10 +4465,10 @@ namespace Oshima.FunGame.WebAPI.Controllers { if (values[0].Length >= 2 && values[0].Length <= 10) { - return NetworkUtility.JsonSerialize("社团名称只能包含2至15个字符!"); + club.Name = values[0]; + msg = "修改成功,新的社团名称是:" + club.Name; } - club.Name = values[0]; - msg = "修改成功,新的社团名称是:" + club.Name; + else return NetworkUtility.JsonSerialize("社团名称只能包含2至15个字符!"); } else { @@ -4475,7 +4535,7 @@ namespace Oshima.FunGame.WebAPI.Controllers { return NetworkUtility.JsonSerialize("只有社长可以设置社团管理员!"); } - if (values.Length > 0 && long.TryParse(values[0], out long id) && club.Members.ContainsKey(id) && FunGameService.UserIdAndUsername.TryGetValue(id, out User? user2) && user2 != null) + if (values.Length > 0 && long.TryParse(values[0], out long id) && club.Members.ContainsKey(id) && FunGameConstant.UserIdAndUsername.TryGetValue(id, out User? user2) && user2 != null) { club.Admins[id] = user2; msg = $"将 [ {user2.Username} ] 设置为社团管理员成功!"; @@ -4490,7 +4550,7 @@ namespace Oshima.FunGame.WebAPI.Controllers { return NetworkUtility.JsonSerialize("只有社长可以取消社团管理员!"); } - if (values.Length > 0 && long.TryParse(values[0], out id) && club.Members.ContainsKey(id) && FunGameService.UserIdAndUsername.TryGetValue(id, out user2) && user2 != null) + if (values.Length > 0 && long.TryParse(values[0], out id) && club.Members.ContainsKey(id) && FunGameConstant.UserIdAndUsername.TryGetValue(id, out user2) && user2 != null) { if (club.Admins.Remove(id)) { @@ -4511,7 +4571,7 @@ namespace Oshima.FunGame.WebAPI.Controllers { return NetworkUtility.JsonSerialize("只有社长可以转让社团!"); } - if (values.Length > 0 && long.TryParse(values[0], out id) && club.Members.ContainsKey(id) && FunGameService.UserIdAndUsername.TryGetValue(id, out user2) && user2 != null) + if (values.Length > 0 && long.TryParse(values[0], out id) && club.Members.ContainsKey(id) && FunGameConstant.UserIdAndUsername.TryGetValue(id, out user2) && user2 != null) { club.Master = user2; club.Admins.Remove(user2.Id); @@ -4552,9 +4612,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("showdailystore")] - public string ShowDailyStore([FromQuery] long? qq = null) + public string ShowDailyStore([FromQuery] long? uid = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -4563,15 +4623,28 @@ namespace Oshima.FunGame.WebAPI.Controllers { User user = FunGameService.GetUser(pc); + GeneralEventArgs e = new() + { + EventMsg = $"{user.Username}正在访问每日商店" + }; + FunGameService.ServerPluginLoader?.OnBeforeOpenStoreEvent(user, e); + if (e.Cancel) + { + return NetworkUtility.JsonSerialize(refused + (e.EventMsg != "" ? $"原因:{e.EventMsg}" : "")); + } + EntityModuleConfig store = new("stores", userid.ToString()); store.LoadConfig(); - string msg = FunGameService.CheckDailyStore(store); + string msg = FunGameService.CheckDailyStore(store, user); store.SaveConfig(); user.LastTime = DateTime.Now; pc.Add("user", user); pc.SaveConfig(); + e.EventMsg = $"{user.Username}访问每日商店成功"; + FunGameService.ServerPluginLoader?.OnSucceedOpenStoreEvent(user, e); + return NetworkUtility.JsonSerialize(msg); } else @@ -4581,10 +4654,11 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("dailystorebuy")] - public string DailyStoreBuy([FromQuery] long? qq = null, [FromQuery] long? id = null) + public string DailyStoreBuy([FromQuery] long? uid = null, [FromQuery] long? id = null, [FromQuery] int? count = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); long goodid = id ?? 0; + int buycount = count ?? 0; PluginConfig pc = new("saved", userid.ToString()); pc.LoadConfig(); @@ -4602,56 +4676,7 @@ namespace Oshima.FunGame.WebAPI.Controllers { if (daily.Goods.Values.FirstOrDefault(g => g.Id == goodid) is Goods good) { - if (good.Stock <= 0) - { - return NetworkUtility.JsonSerialize($"此商品【{good.Name}】库存不足,无法购买!"); - } - - foreach (string needy in good.Prices.Keys) - { - if (needy == General.GameplayEquilibriumConstant.InGameCurrency) - { - double reduce = good.Prices[needy]; - if (user.Inventory.Credits >= reduce) - { - user.Inventory.Credits -= reduce; - } - else - { - return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameCurrency}不足 {reduce} 呢,无法购买【{good.Name}】!"); - } - } - else if (needy == General.GameplayEquilibriumConstant.InGameMaterial) - { - double reduce = good.Prices[needy]; - if (user.Inventory.Materials >= reduce) - { - user.Inventory.Materials -= reduce; - } - else - { - return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce} 呢,无法购买【{good.Name}】!"); - } - } - } - - foreach (Item item in good.Items) - { - Item newItem = item.Copy(); - FunGameService.SetSellAndTradeTime(newItem); - if (good.GetPrice(General.GameplayEquilibriumConstant.InGameCurrency, out double price)) - { - newItem.Price = Calculation.Round2Digits(price * 0.35); - } - newItem.User = user; - user.Inventory.Items.Add(newItem); - } - - good.Stock--; - - msg += $"恭喜你成功购买【${good.Name}】!" + - $"总计消费:{string.Join("、", good.Prices.Select(kv => $"{kv.Value} {kv.Key}"))}" + - $"包含物品:{string.Join("、", good.Items.Select(i => $"[{ItemSet.GetQualityTypeName(i.QualityType)}|{ItemSet.GetItemTypeName(i.ItemType)}] {i.Name}"))}"; + msg = FunGameService.StoreBuyItem(daily, good, user, buycount); } else { @@ -4678,9 +4703,9 @@ namespace Oshima.FunGame.WebAPI.Controllers } [HttpPost("dailystoreshowinfo")] - public string DailyStoreShowInfo([FromQuery] long? qq = null, [FromQuery] long? id = null) + public string DailyStoreShowInfo([FromQuery] long? uid = null, [FromQuery] long? id = null) { - long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); long goodid = id ?? 0; PluginConfig pc = new("saved", userid.ToString()); @@ -4704,13 +4729,14 @@ namespace Oshima.FunGame.WebAPI.Controllers foreach (Item item in good.Items) { count++; - itemMsg += $"[ {count} ] -> {item.ToString(false, true)}\r\n"; + Item newItem = item.Copy(); + newItem.Character = user.Inventory.MainCharacter; + newItem.SetLevel(1); + itemMsg += $"[ {count} ] {newItem.ToString(false, true)}".Trim(); } - msg += $"{good.Id}. {good.Name}\r\n" + - $"商品描述:{good.Description}\r\n" + - $"商品售价:{string.Join("、", good.Prices.Select(kv => $"{kv.Value} {kv.Key}"))}\r\n" + - $"包含物品:\r\n" + itemMsg + - $"剩余库存:{good.Stock}"; + msg = good.ToString().Split("包含物品:")[0].Trim(); + msg += $"\r\n包含物品:\r\n" + itemMsg + + $"\r\n剩余库存:{good.Stock}"; } else { @@ -4723,9 +4749,6 @@ namespace Oshima.FunGame.WebAPI.Controllers return NetworkUtility.JsonSerialize($"商品列表不存在,请刷新!"); } - user.LastTime = DateTime.Now; - pc.Add("user", user); - pc.SaveConfig(); return NetworkUtility.JsonSerialize(msg); } else diff --git a/OshimaWebAPI/Controllers/QQBotController.cs b/OshimaWebAPI/Controllers/QQBotController.cs index cb742e9..78e5ee2 100644 --- a/OshimaWebAPI/Controllers/QQBotController.cs +++ b/OshimaWebAPI/Controllers/QQBotController.cs @@ -4,6 +4,7 @@ using System.Text.Json; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Milimoe.FunGame.Core.Api.Utility; using Oshima.FunGame.WebAPI.Models; using Oshima.FunGame.WebAPI.Services; using Rebex.Security.Cryptography; @@ -20,7 +21,7 @@ namespace Oshima.FunGame.WebAPI.Controllers private RainBOTService FungameService { get; set; } = fungameService; [HttpPost] - public async Task Post([FromBody] Payload? payload) + public IActionResult Post([FromBody] Payload? payload) { if (payload is null) { @@ -38,7 +39,7 @@ namespace Oshima.FunGame.WebAPI.Controllers else if (payload.Op == 0) { // 处理其他事件 - return await HandleEventAsync(payload); + return HandleEventAsync(payload); } else { @@ -93,7 +94,7 @@ namespace Oshima.FunGame.WebAPI.Controllers return Ok(response); } - private async Task HandleEventAsync(Payload payload) + private IActionResult HandleEventAsync(Payload payload) { Logger.LogDebug("处理事件:{EventType}, 数据:{Data}", payload.EventType, payload.Data); @@ -122,7 +123,7 @@ namespace Oshima.FunGame.WebAPI.Controllers //{ // _logger.LogError("上传图片失败:{error}", error); //} - await FungameService.Handler(c2c: c2cMessage); + TaskUtility.NewTask(async () => await FungameService.Handler(c2c: c2cMessage)); } else { @@ -139,7 +140,7 @@ namespace Oshima.FunGame.WebAPI.Controllers Logger.LogInformation("收到来自群组 {groupAtMessage.GroupOpenId} 的消息:{groupAtMessage.Content}", groupAtMessage.GroupOpenId, groupAtMessage.Content); // 回复消息 //await _service.SendGroupMessageAsync(groupAtMessage.GroupOpenId, $"你发送的消息是:{groupAtMessage.Content}", msgId: groupAtMessage.Id); - await FungameService.Handler(groupAt: groupAtMessage); + TaskUtility.NewTask(async () => await FungameService.Handler(groupAt: groupAtMessage)); } else { diff --git a/OshimaWebAPI/OshimaWebAPI.cs b/OshimaWebAPI/OshimaWebAPI.cs index 8ba21ab..13fbd04 100644 --- a/OshimaWebAPI/OshimaWebAPI.cs +++ b/OshimaWebAPI/OshimaWebAPI.cs @@ -1,10 +1,13 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Milimoe.FunGame.Core.Api.Transmittal; using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Library.Common.Addon; using Oshima.Core.Configs; using Oshima.Core.Constant; +using Oshima.FunGame.OshimaServers.Service; using Oshima.FunGame.WebAPI.Constant; using Oshima.FunGame.WebAPI.Controllers; using Oshima.FunGame.WebAPI.Models; @@ -27,16 +30,14 @@ namespace Oshima.FunGame.WebAPI if (input == "test") { FunGameController controller = new(new Logger(new LoggerFactory())); - Controller.WriteLine(Controller.JSON.GetObject(controller.CreateSaved(1, "测试用户")) ?? "test"); - Controller.WriteLine(Controller.JSON.GetObject(controller.GetItemInfo_Name(1, "鸳鸯眼")) ?? "test"); - Controller.WriteLine(Controller.JSON.GetObject(controller.GetCharacterInfoFromInventory(1, 1, false)) ?? "test"); - Controller.WriteLine(string.Join("\r\n", controller.GetBoss(1))); + Controller.WriteLine(Controller.JSON.GetObject(controller.ShowDailyStore(1)) ?? "test"); } } public override void AfterLoad(WebAPIPluginLoader loader, params object[] objs) { Statics.RunningPlugin = this; + FunGameService.WebAPIPluginLoader ??= loader; Controller.NewSQLHelper(); Controller.NewMailSender(); if (objs.Length > 0 && objs[0] is WebApplicationBuilder builder) @@ -46,6 +47,11 @@ namespace Oshima.FunGame.WebAPI builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddTransient(provider => { + SQLHelper? sql = Factory.OpenFactory.GetSQLHelper(); + if (sql != null) return sql; + throw new Milimoe.FunGame.SQLServiceException(); + }); // 使用 Configure 从配置源绑定 builder.Services.Configure(builder.Configuration.GetSection("Bot")); } diff --git a/OshimaWebAPI/Services/RainBOTService.cs b/OshimaWebAPI/Services/RainBOTService.cs index 6f1ff59..bccd0c2 100644 --- a/OshimaWebAPI/Services/RainBOTService.cs +++ b/OshimaWebAPI/Services/RainBOTService.cs @@ -1,15 +1,18 @@ using System.Text.RegularExpressions; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; +using Milimoe.FunGame.Core.Api.Transmittal; using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; using Oshima.Core.Configs; +using Oshima.FunGame.OshimaServers.Service; using Oshima.FunGame.WebAPI.Constant; using Oshima.FunGame.WebAPI.Controllers; using Oshima.FunGame.WebAPI.Models; namespace Oshima.FunGame.WebAPI.Services { - public class RainBOTService(FunGameController controller, QQController qqcontroller, QQBotService service, ILogger logger) + public class RainBOTService(FunGameController controller, QQController qqcontroller, QQBotService service, ILogger logger, IMemoryCache memoryCache) { private static List FunGameItemType { get; } = ["卡包", "武器", "防具", "鞋子", "饰品", "消耗品", "魔法卡", "收藏品", "特殊物品", "任务物品", "礼包", "其他"]; private bool FunGameSimulation { get; set; } = false; @@ -17,6 +20,7 @@ namespace Oshima.FunGame.WebAPI.Services private QQController QQController { get; } = qqcontroller; private QQBotService Service { get; } = service; private ILogger Logger { get; } = logger; + private IMemoryCache MemoryCache { get; set; } = memoryCache; private async Task SendAsync(IBotMessage msg, string title, string content, int msgType = 0, object? media = null, int? msgSeq = null) { @@ -39,7 +43,7 @@ namespace Oshima.FunGame.WebAPI.Services { IBotMessage? e = null; string openid = ""; - long qq = 0; + long uid = 0; if (groupAt != null) { e = groupAt; @@ -57,29 +61,48 @@ namespace Oshima.FunGame.WebAPI.Services string isGroup = e.IsGroup ? "群聊" : "私聊"; openid = e.AuthorOpenId; - if (QQOpenID.QQAndOpenID.TryGetValue(openid, out long temp_qq)) + if (MemoryCache.TryGetValue(openid, out object? value) && value is long uidTemp) { - qq = temp_qq; + uid = uidTemp; + } + else + { + using SQLHelper? sql = Factory.OpenFactory.GetSQLHelper(); + if (sql != null) + { + sql.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sql, openid)); + if (sql.Success) + { + User user = Factory.GetUser(sql.DataSet); + uid = user.Id; + MemoryCache.Set(openid, uid, TimeSpan.FromMinutes(10)); + } + } } - if (e.Detail.StartsWith("绑定")) - { - string detail = e.Detail.Replace("绑定", ""); - string msg = ""; - if (long.TryParse(detail, out temp_qq)) - { - msg = NetworkUtility.JsonDeserialize(QQController.Bind(new(openid, temp_qq))) ?? ""; - } - else - { - msg = "绑定失败,请提供一个正确的QQ号!"; - } - await SendAsync(e, "绑定", msg); - } + //if (QQOpenID.QQAndOpenID.TryGetValue(openid, out long temp_qq)) + //{ + // qq = temp_qq; + //} + + //if (e.Detail.StartsWith("绑定")) + //{ + // string detail = e.Detail.Replace("绑定", ""); + // string msg = ""; + // if (long.TryParse(detail, out temp_qq)) + // { + // msg = NetworkUtility.JsonDeserialize(QQController.Bind(new(openid, temp_qq))) ?? ""; + // } + // else + // { + // msg = "绑定失败,请提供一个正确的QQ号!"; + // } + // await SendAsync(e, "绑定", msg); + //} if (e.Detail == "帮助" || e.Detail == "帮助1") { - await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 1 / 6 页) + await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 1 / 7 页) 1、创建存档:创建存档,生成随机一个自建角色(序号固定为1) 2、我的库存/我的背包/查看库存 [页码]:显示所有角色、物品库存,每个角色和物品都有一个专属序号 3、我的库存 <物品类型> [页码]:卡包/武器/防具/鞋子/饰品/消耗品/魔法卡等... @@ -97,7 +120,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "帮助2") { - await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 2 / 6 页) + await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 2 / 7 页) 12、装备 <角色序号> <物品序号>:装备指定物品给指定角色 13、取消装备 <角色序号> <装备槽序号>:卸下角色指定装备槽上的物品 * 装备槽序号从1开始,卡包/武器/防具/鞋子/饰品1/饰品2 @@ -114,7 +137,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "帮助3") { - await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 3 / 6 页) + await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 3 / 7 页) 22、普攻升级 [角色序号]:升级普攻等级 23、查看普攻升级 [角色序号]:查看下一次普攻升级信息 23、技能升级 <角色序号> <技能名称>:升级技能等级 @@ -132,7 +155,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "帮助4") { - await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 4 / 6 页) + await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 4 / 7 页) 33、兑换金币 <材料数>:1材料=200金币 34、还原存档:没有后悔药 35、我的主战:查看当前主战角色 @@ -148,7 +171,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "帮助5") { - await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 5 / 6 页) + await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 5 / 7 页) 43:任务列表:查看今日任务列表 44:开始任务 <任务序号> 45、任务信息:查看进行中任务的详细信息 @@ -163,7 +186,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "帮助6") { - await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 6 / 6 页) + await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 6 / 7 页) 52、我的社团:查看社团信息 53、加入社团 <社团编号>:申请加入社团 54、退出社团 @@ -175,7 +198,17 @@ namespace Oshima.FunGame.WebAPI.Services 59、社团拒绝 <@对方>/// <{参数...}>"); +62、社团设置 <设置项> <{参数...}> +发送【帮助7】查看第 7 页"); + } + + if (e.Detail == "帮助7") + { + await SendAsync(e, "饭给木", @"《饭给木》游戏指令列表(第 7 / 7 页) +63、每日商店 +64、商店查看 <商品序号> +65、商店购买 <商品序号> +66、"); } if (e.Detail.StartsWith("FunGame模拟", StringComparison.CurrentCultureIgnoreCase)) @@ -345,7 +378,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("查技能", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = NetworkUtility.JsonDeserialize(Controller.GetSkillInfo(qq, id)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetSkillInfo(uid, id)) ?? ""; if (msg != "") { await SendAsync(e, "查技能", msg); @@ -353,7 +386,7 @@ namespace Oshima.FunGame.WebAPI.Services } else { - string msg = NetworkUtility.JsonDeserialize(Controller.GetSkillInfo_Name(qq, detail)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetSkillInfo_Name(uid, detail)) ?? ""; if (msg != "") { await SendAsync(e, "查技能", msg); @@ -367,7 +400,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("查物品", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = NetworkUtility.JsonDeserialize(Controller.GetItemInfo(qq, id)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetItemInfo(uid, id)) ?? ""; if (msg != "") { await SendAsync(e, "查物品", msg); @@ -375,7 +408,7 @@ namespace Oshima.FunGame.WebAPI.Services } else { - string msg = NetworkUtility.JsonDeserialize(Controller.GetItemInfo_Name(qq, detail)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetItemInfo_Name(uid, detail)) ?? ""; if (msg != "") { await SendAsync(e, "查物品", msg); @@ -395,7 +428,7 @@ namespace Oshima.FunGame.WebAPI.Services int count = int.Parse(match.Groups[1].Value); string name = match.Groups[2].Value.Trim(); string target = match.Groups[3].Value; - long userid = qq; + long userid = uid; if (!string.IsNullOrEmpty(target)) { @@ -404,7 +437,7 @@ namespace Oshima.FunGame.WebAPI.Services if (count > 0) { - string msg = NetworkUtility.JsonDeserialize(Controller.CreateItem(qq, name, count, userid)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.CreateItem(uid, name, count, userid)) ?? ""; if (msg != "") { await SendAsync(e, "熟圣之力", msg); @@ -439,7 +472,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "创建存档") { - string msg = NetworkUtility.JsonDeserialize(Controller.CreateSaved(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.CreateSaved(name: openid)) ?? ""; if (msg != "") { await SendAsync(e, "创建存档", "\r\n" + msg); @@ -449,7 +482,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "我的存档") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowSaved(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowSaved(uid)) ?? ""; if (msg != "") { await SendAsync(e, "我的存档", "\r\n" + msg); @@ -459,7 +492,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "我的主战") { - string msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(qq, 0)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(uid, 0)) ?? ""; if (msg != "") { await SendAsync(e, "我的主战", "\r\n" + msg); @@ -469,7 +502,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "我的状态") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowMainCharacterOrSquadStatus(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowMainCharacterOrSquadStatus(uid)) ?? ""; if (msg != "") { await SendAsync(e, "我的状态", "\r\n" + msg); @@ -479,7 +512,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "小队状态" || e.Detail == "我的小队状态") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowMainCharacterOrSquadStatus(qq, true)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowMainCharacterOrSquadStatus(uid, true)) ?? ""; if (msg != "") { await SendAsync(e, "我的小队状态", "\r\n" + msg); @@ -489,7 +522,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "我的小队") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowSquad(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowSquad(uid)) ?? ""; if (msg != "") { await SendAsync(e, "我的小队", "\r\n" + msg); @@ -499,7 +532,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "清空小队") { - string msg = NetworkUtility.JsonDeserialize(Controller.ClearSquad(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ClearSquad(uid)) ?? ""; if (msg != "") { await SendAsync(e, "清空小队", "\r\n" + msg); @@ -509,7 +542,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "还原存档") { - string msg = NetworkUtility.JsonDeserialize(Controller.RestoreSaved(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.RestoreSaved(uid)) ?? ""; if (msg != "") { await SendAsync(e, "还原存档", "\r\n" + msg); @@ -519,7 +552,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "生成自建角色") { - string msg = NetworkUtility.JsonDeserialize(Controller.NewCustomCharacter(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.NewCustomCharacter(uid)) ?? ""; if (msg != "") { await SendAsync(e, "抽卡", "\r\n" + msg); @@ -529,7 +562,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "角色改名") { - string msg = NetworkUtility.JsonDeserialize(Controller.ReName(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ReName(uid)) ?? ""; if (msg != "") { await SendAsync(e, "改名", "\r\n" + msg); @@ -539,7 +572,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "角色重随") { - string msg = NetworkUtility.JsonDeserialize(Controller.RandomCustomCharacter(qq, false)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.RandomCustomCharacter(uid, false)) ?? ""; if (msg != "") { await SendAsync(e, "角色重随", "\r\n" + msg); @@ -549,7 +582,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "确认角色重随") { - string msg = NetworkUtility.JsonDeserialize(Controller.RandomCustomCharacter(qq, true)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.RandomCustomCharacter(uid, true)) ?? ""; if (msg != "") { await SendAsync(e, "角色重随", "\r\n" + msg); @@ -559,7 +592,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "取消角色重随") { - string msg = NetworkUtility.JsonDeserialize(Controller.CancelRandomCustomCharacter(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.CancelRandomCustomCharacter(uid)) ?? ""; if (msg != "") { await SendAsync(e, "角色重随", "\r\n" + msg); @@ -569,7 +602,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "抽卡") { - string msg = NetworkUtility.JsonDeserialize(Controller.DrawCard(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DrawCard(uid)) ?? ""; if (msg != "") { await SendAsync(e, "抽卡", "\r\n" + msg); @@ -579,7 +612,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "十连抽卡") { - List msgs = Controller.DrawCards(qq); + List msgs = Controller.DrawCards(uid); if (msgs.Count > 0) { await SendAsync(e, "十连抽卡", "\r\n" + string.Join("\r\n", msgs)); @@ -589,7 +622,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "材料抽卡") { - string msg = NetworkUtility.JsonDeserialize(Controller.DrawCard_Material(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DrawCard_Material(uid)) ?? ""; if (msg != "") { await SendAsync(e, "材料抽卡", "\r\n" + msg); @@ -599,7 +632,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "材料十连抽卡") { - List msgs = Controller.DrawCards_Material(qq); + List msgs = Controller.DrawCards_Material(uid); if (msgs.Count > 0) { await SendAsync(e, "材料十连抽卡", "\r\n" + string.Join("\r\n", msgs)); @@ -613,7 +646,7 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = Controller.GetInventoryInfo2(qq, page); + msgs = Controller.GetInventoryInfo2(uid, page); } else if (FunGameItemType.FirstOrDefault(detail.Contains) is string matchedType) { @@ -621,16 +654,16 @@ namespace Oshima.FunGame.WebAPI.Services string remain = detail.Replace(matchedType, "").Trim(); if (int.TryParse(remain, out page)) { - msgs = Controller.GetInventoryInfo4(qq, page, typeIndex); + msgs = Controller.GetInventoryInfo4(uid, page, typeIndex); } else { - msgs = Controller.GetInventoryInfo4(qq, 1, typeIndex); + msgs = Controller.GetInventoryInfo4(uid, 1, typeIndex); } } else { - msgs = Controller.GetInventoryInfo2(qq, 1); + msgs = Controller.GetInventoryInfo2(uid, 1); } if (msgs.Count > 0) { @@ -645,11 +678,11 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = Controller.GetInventoryInfo3(qq, page, 2, 2); + msgs = Controller.GetInventoryInfo3(uid, page, 2, 2); } else { - msgs = Controller.GetInventoryInfo3(qq, 1, 2, 2); + msgs = Controller.GetInventoryInfo3(uid, 1, 2, 2); } if (msgs.Count > 0) { @@ -664,11 +697,11 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = Controller.GetInventoryInfo5(qq, page); + msgs = Controller.GetInventoryInfo5(uid, page); } else { - msgs = Controller.GetInventoryInfo5(qq, 1); + msgs = Controller.GetInventoryInfo5(uid, 1); } if (msgs.Count > 0) { @@ -687,11 +720,11 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (strings.Length > 1 && int.TryParse(strings[1].Trim(), out int page)) { - msgs = Controller.GetInventoryInfo4(qq, page, t); + msgs = Controller.GetInventoryInfo4(uid, page, t); } else { - msgs = Controller.GetInventoryInfo4(qq, 1, t); + msgs = Controller.GetInventoryInfo4(uid, 1, t); } if (msgs.Count > 0) { @@ -707,11 +740,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(qq, seq, true)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(uid, seq, true)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(qq, 1, true)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(uid, 1, true)) ?? ""; } if (msg != "") { @@ -726,11 +759,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(qq, seq, false)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(uid, seq, false)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(qq, 1, false)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterInfoFromInventory(uid, 1, false)) ?? ""; } if (msg != "") { @@ -745,11 +778,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterSkills(qq, seq)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterSkills(uid, seq)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterSkills(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterSkills(uid, 1)) ?? ""; } if (msg != "") { @@ -764,11 +797,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterItems(qq, seq)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterItems(uid, seq)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterItems(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetCharacterItems(uid, 1)) ?? ""; } if (msg != "") { @@ -783,11 +816,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = NetworkUtility.JsonDeserialize(Controller.SetMain(qq, cid)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.SetMain(uid, cid)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.SetMain(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.SetMain(uid, 1)) ?? ""; } if (msg != "") { @@ -802,11 +835,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = NetworkUtility.JsonDeserialize(Controller.StartTraining(qq, cid)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.StartTraining(uid, cid)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.StartTraining(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.StartTraining(uid, 1)) ?? ""; } if (msg != "") { @@ -817,7 +850,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "练级信息") { - string msg = NetworkUtility.JsonDeserialize(Controller.GetTrainingInfo(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetTrainingInfo(uid)) ?? ""; if (msg != "") { await SendAsync(e, "练级信息", "\r\n" + msg); @@ -827,7 +860,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "练级结算") { - string msg = NetworkUtility.JsonDeserialize(Controller.StopTraining(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.StopTraining(uid)) ?? ""; if (msg != "") { await SendAsync(e, "练级结算", "\r\n" + msg); @@ -837,7 +870,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "任务列表") { - string msg = NetworkUtility.JsonDeserialize(Controller.CheckQuestList(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.CheckQuestList(uid)) ?? ""; if (msg != "") { await SendAsync(e, "任务列表", "\r\n" + msg); @@ -847,7 +880,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "任务信息") { - string msg = NetworkUtility.JsonDeserialize(Controller.CheckWorkingQuest(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.CheckWorkingQuest(uid)) ?? ""; if (msg != "") { await SendAsync(e, "任务信息", "\r\n" + msg); @@ -857,7 +890,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "任务结算") { - string msg = NetworkUtility.JsonDeserialize(Controller.SettleQuest(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.SettleQuest(uid)) ?? ""; if (msg != "") { await SendAsync(e, "任务结算", "\r\n" + msg); @@ -867,7 +900,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "签到") { - string msg = NetworkUtility.JsonDeserialize(Controller.SignIn(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.SignIn(uid)) ?? ""; if (msg != "") { await SendAsync(e, "签到", "\r\n" + msg); @@ -880,7 +913,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("开始任务", "").Trim(); if (int.TryParse(detail, out int index)) { - string msg = NetworkUtility.JsonDeserialize(Controller.AcceptQuest(qq, index)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.AcceptQuest(uid, index)) ?? ""; if (msg != "") { await SendAsync(e, "开始任务", msg); @@ -894,7 +927,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("我的物品", "").Trim(); if (int.TryParse(detail, out int index)) { - string msg = NetworkUtility.JsonDeserialize(Controller.GetItemInfoFromInventory(qq, index)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetItemInfoFromInventory(uid, index)) ?? ""; if (msg != "") { await SendAsync(e, "查库存物品", msg); @@ -908,7 +941,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("兑换金币", "").Trim(); if (int.TryParse(detail, out int materials)) { - string msg = NetworkUtility.JsonDeserialize(Controller.ExchangeCredits(qq, materials)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ExchangeCredits(uid, materials)) ?? ""; if (msg != "") { await SendAsync(e, "兑换金币", msg); @@ -926,7 +959,7 @@ namespace Oshima.FunGame.WebAPI.Services { if (c != -1 && i != -1) { - string msg = NetworkUtility.JsonDeserialize(Controller.UnEquipItem(qq, c, i)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.UnEquipItem(uid, c, i)) ?? ""; if (msg != "") { await SendAsync(e, "取消装备", msg); @@ -945,7 +978,7 @@ namespace Oshima.FunGame.WebAPI.Services { if (c != -1 && i != -1) { - string msg = NetworkUtility.JsonDeserialize(Controller.EquipItem(qq, c, i)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.EquipItem(uid, c, i)) ?? ""; if (msg != "") { await SendAsync(e, "装备", msg); @@ -965,7 +998,7 @@ namespace Oshima.FunGame.WebAPI.Services string s = strings[1].Trim(); if (c != -1 && s != "") { - string msg = NetworkUtility.JsonDeserialize(Controller.GetSkillLevelUpNeedy(qq, c, s)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.GetSkillLevelUpNeedy(uid, c, s)) ?? ""; if (msg != "") { await SendAsync(e, "查看技能升级", msg); @@ -985,7 +1018,7 @@ namespace Oshima.FunGame.WebAPI.Services string s = strings[1].Trim(); if (c != -1 && s != "") { - string msg = NetworkUtility.JsonDeserialize(Controller.SkillLevelUp(qq, c, s)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.SkillLevelUp(uid, c, s)) ?? ""; if (msg != "") { await SendAsync(e, "技能升级", msg); @@ -1004,7 +1037,7 @@ namespace Oshima.FunGame.WebAPI.Services { if (id1 != -1 && id2 != -1 && id3 != -1) { - string msg = NetworkUtility.JsonDeserialize(Controller.ConflateMagicCardPack(qq, [id1, id2, id3])) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ConflateMagicCardPack(uid, [id1, id2, id3])) ?? ""; if (msg != "") { await SendAsync(e, "合成魔法卡", msg); @@ -1020,11 +1053,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelUp(qq, cid)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelUp(uid, cid)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelUp(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelUp(uid, 1)) ?? ""; } if (msg != "") { @@ -1039,11 +1072,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = NetworkUtility.JsonDeserialize(Controller.GetNormalAttackLevelUpNeedy(qq, cid)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetNormalAttackLevelUpNeedy(uid, cid)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.GetNormalAttackLevelUpNeedy(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetNormalAttackLevelUpNeedy(uid, 1)) ?? ""; } if (msg != "") { @@ -1058,11 +1091,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = NetworkUtility.JsonDeserialize(Controller.NormalAttackLevelUp(qq, cid)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.NormalAttackLevelUp(uid, cid)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.NormalAttackLevelUp(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.NormalAttackLevelUp(uid, 1)) ?? ""; } if (msg != "") { @@ -1077,11 +1110,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelBreak(qq, cid)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelBreak(uid, cid)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelBreak(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.CharacterLevelBreak(uid, 1)) ?? ""; } if (msg != "") { @@ -1096,11 +1129,11 @@ namespace Oshima.FunGame.WebAPI.Services string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = NetworkUtility.JsonDeserialize(Controller.GetLevelBreakNeedy(qq, cid)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetLevelBreakNeedy(uid, cid)) ?? ""; } else { - msg = NetworkUtility.JsonDeserialize(Controller.GetLevelBreakNeedy(qq, 1)) ?? ""; + msg = NetworkUtility.JsonDeserialize(Controller.GetLevelBreakNeedy(uid, 1)) ?? ""; } if (msg != "") { @@ -1125,7 +1158,7 @@ namespace Oshima.FunGame.WebAPI.Services { if (id > 0 && id2 > 0) { - string msg = NetworkUtility.JsonDeserialize(Controller.UseItem3(qq, id, id2, isCharacter)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.UseItem3(uid, id, id2, isCharacter)) ?? ""; if (msg != "") { await SendAsync(e, "使用魔法卡", msg); @@ -1146,7 +1179,7 @@ namespace Oshima.FunGame.WebAPI.Services { string characterIdsString = match.Groups["characterIds"].Value; int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1]; - string msg = NetworkUtility.JsonDeserialize(Controller.UseItem2(qq, itemName, count, characterIds)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.UseItem2(uid, itemName, count, characterIds)) ?? ""; if (msg != "") { await SendAsync(e, "使用", msg); @@ -1163,7 +1196,7 @@ namespace Oshima.FunGame.WebAPI.Services { string characterIdsString = match.Groups["characterIds"].Value; int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1]; - string msg = NetworkUtility.JsonDeserialize(Controller.UseItem(qq, itemId, characterIds)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.UseItem(uid, itemId, characterIds)) ?? ""; if (msg != "") { await SendAsync(e, "使用", msg); @@ -1179,7 +1212,7 @@ namespace Oshima.FunGame.WebAPI.Services string itemName = match.Groups["itemName"].Value.Trim(); if (int.TryParse(match.Groups["count"].Value, out int count)) { - string msg = NetworkUtility.JsonDeserialize(Controller.UseItem2(qq, itemName, count)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.UseItem2(uid, itemName, count)) ?? ""; if (msg != "") { await SendAsync(e, "使用", msg); @@ -1194,7 +1227,7 @@ namespace Oshima.FunGame.WebAPI.Services { if (int.TryParse(match.Groups["itemId"].Value, out int itemId)) { - string msg = NetworkUtility.JsonDeserialize(Controller.UseItem(qq, itemId)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.UseItem(uid, itemId)) ?? ""; if (msg != "") { await SendAsync(e, "使用", msg); @@ -1220,7 +1253,7 @@ namespace Oshima.FunGame.WebAPI.Services ids.Add(id); } } - string msg = NetworkUtility.JsonDeserialize(Controller.DecomposeItem(qq, [.. ids])) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DecomposeItem(uid, [.. ids])) ?? ""; if (msg != "") { await SendAsync(e, "分解物品", msg); @@ -1239,7 +1272,7 @@ namespace Oshima.FunGame.WebAPI.Services string itemName = match.Groups["itemName"].Value.Trim(); if (int.TryParse(match.Groups["count"].Value, out int count)) { - string msg = NetworkUtility.JsonDeserialize(Controller.DecomposeItem2(qq, itemName, count)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DecomposeItem2(uid, itemName, count)) ?? ""; if (msg != "") { await SendAsync(e, "分解", msg); @@ -1255,7 +1288,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("品质分解", "").Trim(); if (int.TryParse(detail, out int q)) { - string msg = NetworkUtility.JsonDeserialize(Controller.DecomposeItem3(qq, q)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DecomposeItem3(uid, q)) ?? ""; if (msg != "") { await SendAsync(e, "品质分解", msg); @@ -1275,12 +1308,12 @@ namespace Oshima.FunGame.WebAPI.Services string name = strings[0].Trim(); if (count > 0) { - long userid = qq; + long userid = uid; if (strings.Length > 2 && long.TryParse(strings[2].Replace("@", "").Trim(), out long temp)) { userid = temp; } - string msg = NetworkUtility.JsonDeserialize(Controller.CreateItem(qq, name, count, userid)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.CreateItem(uid, name, count, userid)) ?? ""; if (msg != "") { await SendAsync(e, "熟圣之力", msg); @@ -1300,11 +1333,11 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = Controller.FightCustom(qq, eqq, true); + msgs = Controller.FightCustom(uid, eqq, true); } else { - msgs = Controller.FightCustom2(qq, detail.Trim(), true); + msgs = Controller.FightCustom2(uid, detail.Trim(), true); } List real = []; if (msgs.Count >= 2) @@ -1358,11 +1391,11 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = Controller.FightCustom(qq, eqq, false); + msgs = Controller.FightCustom(uid, eqq, false); } else { - msgs = Controller.FightCustom2(qq, detail.Trim(), false); + msgs = Controller.FightCustom2(uid, detail.Trim(), false); } List real = []; if (msgs.Count > 2) @@ -1409,11 +1442,11 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = Controller.FightCustomTeam(qq, eqq, true); + msgs = Controller.FightCustomTeam(uid, eqq, true); } else { - msgs = Controller.FightCustomTeam2(qq, detail.Trim(), true); + msgs = Controller.FightCustomTeam2(uid, detail.Trim(), true); } List real = []; if (msgs.Count >= 3) @@ -1487,7 +1520,7 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (int.TryParse(detail.Trim(), out int index)) { - msgs = Controller.FightBossTeam(qq, index, true); + msgs = Controller.FightBossTeam(uid, index, true); List real = []; if (msgs.Count >= 3) { @@ -1546,7 +1579,7 @@ namespace Oshima.FunGame.WebAPI.Services List msgs = []; if (int.TryParse(detail.Trim(), out int index)) { - msgs = Controller.FightBoss(qq, index, true); + msgs = Controller.FightBoss(uid, index, true); List real = []; if (msgs.Count >= 3) { @@ -1604,7 +1637,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("小队添加", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = NetworkUtility.JsonDeserialize(Controller.AddSquad(qq, c)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.AddSquad(uid, c)) ?? ""; if (msg != "") { await SendAsync(e, "小队", msg); @@ -1618,7 +1651,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("小队移除", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = NetworkUtility.JsonDeserialize(Controller.RemoveSquad(qq, c)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.RemoveSquad(uid, c)) ?? ""; if (msg != "") { await SendAsync(e, "小队", msg); @@ -1639,7 +1672,7 @@ namespace Oshima.FunGame.WebAPI.Services cindexs.Add(c); } } - string msg = NetworkUtility.JsonDeserialize(Controller.SetSquad(qq, [.. cindexs])) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.SetSquad(uid, [.. cindexs])) ?? ""; if (msg != "") { await SendAsync(e, "小队", msg); @@ -1652,7 +1685,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("加入社团", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = NetworkUtility.JsonDeserialize(Controller.JoinClub(qq, c)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.JoinClub(uid, c)) ?? ""; if (msg != "") { await SendAsync(e, "社团", msg); @@ -1670,7 +1703,7 @@ namespace Oshima.FunGame.WebAPI.Services isPublic = false; } detail = detail.Replace("私密", "").Trim(); - string msg = NetworkUtility.JsonDeserialize(Controller.CreateClub(qq, isPublic, detail)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.CreateClub(uid, isPublic, detail)) ?? ""; if (msg != "") { await SendAsync(e, "社团", msg); @@ -1680,7 +1713,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "退出社团") { - string msg = NetworkUtility.JsonDeserialize(Controller.QuitClub(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.QuitClub(uid)) ?? ""; if (msg != "") { await SendAsync(e, "社团", "\r\n" + msg); @@ -1690,7 +1723,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "我的社团") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubInfo(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubInfo(uid)) ?? ""; if (msg != "") { await SendAsync(e, "社团", "\r\n" + msg); @@ -1700,7 +1733,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "解散社团") { - string msg = NetworkUtility.JsonDeserialize(Controller.DisbandClub(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DisbandClub(uid)) ?? ""; if (msg != "") { await SendAsync(e, "社团", "\r\n" + msg); @@ -1710,7 +1743,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "查看社团成员") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubMemberList(qq, 0)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubMemberList(uid, 0)) ?? ""; if (msg != "") { await SendAsync(e, "社团", "\r\n" + msg); @@ -1720,7 +1753,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "查看社团管理") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubMemberList(qq, 1)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubMemberList(uid, 1)) ?? ""; if (msg != "") { await SendAsync(e, "社团", "\r\n" + msg); @@ -1730,7 +1763,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "查看申请人列表") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubMemberList(qq, 2)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowClubMemberList(uid, 2)) ?? ""; if (msg != "") { await SendAsync(e, "社团", "\r\n" + msg); @@ -1743,7 +1776,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("社团批准", "").Replace("@", "").Trim(); if (long.TryParse(detail, out long id)) { - string msg = NetworkUtility.JsonDeserialize(Controller.ApproveClub(qq, id, true)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ApproveClub(uid, id, true)) ?? ""; if (msg != "") { await SendAsync(e, "社团", msg); @@ -1757,7 +1790,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("社团拒绝", "").Replace("@", "").Trim(); if (long.TryParse(detail, out long id)) { - string msg = NetworkUtility.JsonDeserialize(Controller.ApproveClub(qq, id, false)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ApproveClub(uid, id, false)) ?? ""; if (msg != "") { await SendAsync(e, "社团", msg); @@ -1771,7 +1804,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("社团踢出", "").Replace("@", "").Trim(); if (long.TryParse(detail, out long id)) { - string msg = NetworkUtility.JsonDeserialize(Controller.KickClub(qq, id)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.KickClub(uid, id)) ?? ""; if (msg != "") { await SendAsync(e, "社团", msg); @@ -1803,7 +1836,7 @@ namespace Oshima.FunGame.WebAPI.Services { args = [.. strings[1..]]; } - string msg = NetworkUtility.JsonDeserialize(Controller.ChangeClub(qq, part, [.. args])) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ChangeClub(uid, part, [.. args])) ?? ""; if (msg != "") { await SendAsync(e, "社团", msg); @@ -1816,7 +1849,7 @@ namespace Oshima.FunGame.WebAPI.Services { string detail = e.Detail.Replace("社团转让", "").Replace("@", "").Trim(); List args = [detail]; - string msg = NetworkUtility.JsonDeserialize(Controller.ChangeClub(qq, "setmaster", [.. args])) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ChangeClub(uid, "setmaster", [.. args])) ?? ""; if (msg != "") { await SendAsync(e, "社团", msg); @@ -1826,7 +1859,7 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail == "每日商店") { - string msg = NetworkUtility.JsonDeserialize(Controller.ShowDailyStore(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.ShowDailyStore(uid)) ?? ""; if (msg != "") { await SendAsync(e, "商店", "\r\n" + msg); @@ -1839,7 +1872,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("商店购买", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = NetworkUtility.JsonDeserialize(Controller.DailyStoreBuy(qq, id)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DailyStoreBuy(uid, id)) ?? ""; if (msg != "") { await SendAsync(e, "商店", msg); @@ -1853,7 +1886,7 @@ namespace Oshima.FunGame.WebAPI.Services string detail = e.Detail.Replace("商店查看", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = NetworkUtility.JsonDeserialize(Controller.DailyStoreShowInfo(qq, id)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.DailyStoreShowInfo(uid, id)) ?? ""; if (msg != "") { await SendAsync(e, "商店", msg); @@ -1862,9 +1895,9 @@ namespace Oshima.FunGame.WebAPI.Services return result; } - if (qq == GeneralSettings.Master && e.Detail.StartsWith("重载FunGame", StringComparison.CurrentCultureIgnoreCase)) + if (uid == GeneralSettings.Master && e.Detail.StartsWith("重载FunGame", StringComparison.CurrentCultureIgnoreCase)) { - string msg = NetworkUtility.JsonDeserialize(Controller.Relaod(qq)) ?? ""; + string msg = NetworkUtility.JsonDeserialize(Controller.Relaod(uid)) ?? ""; if (msg != "") { await SendAsync(e, "重载FunGame", msg);