From eae54423fae40153466a1b300d22253f696f9d20 Mon Sep 17 00:00:00 2001 From: milimoe Date: Thu, 1 May 2025 02:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=96=B0=E9=98=9F=E5=88=97?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Effects/SkillEffects/提升友方行动速度.cs | 2 +- .../Effects/SkillEffects/造成封技.cs | 2 +- .../Effects/SkillEffects/造成眩晕.cs | 2 +- .../Effects/SkillEffects/降低敌方行动速度.cs | 2 +- OshimaModules/Skills/ColdBlue/嗜血本能.cs | 2 +- OshimaModules/Skills/MagicalGirl/绝对领域.cs | 2 +- OshimaModules/Skills/Mayor/精准打击.cs | 2 +- OshimaModules/Skills/NanGanyu/三重叠加.cs | 2 +- OshimaModules/Skills/NiuNan/变幻之心.cs | 2 +- OshimaModules/Skills/Oshima/力量爆发.cs | 2 +- OshimaModules/Skills/QWQAQW/迅捷之势.cs | 2 +- OshimaModules/Skills/QuDuoduo/血之狂欢.cs | 2 +- OshimaModules/Skills/XinYin/天赐之力.cs | 2 +- OshimaModules/Skills/Yang/魔法涌流.cs | 2 +- OshimaModules/Skills/dddovo/平衡强化.cs | 2 +- OshimaModules/Skills/战技/疾风步.cs | 2 +- OshimaServers/FastAutoServer.cs | 4 +- OshimaServers/Service/FunGameActionQueue.cs | 22 ++-- OshimaServers/Service/FunGameService.cs | 7 +- OshimaServers/Service/FunGameSimulation.cs | 106 +++++++++++++----- OshimaWebAPI/Controllers/FunGameController.cs | 21 ++-- OshimaWebAPI/Services/RainBOTService.cs | 64 ++++++++++- 22 files changed, 186 insertions(+), 70 deletions(-) diff --git a/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs b/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs index a0500e1..4a9ddd1 100644 --- a/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs +++ b/OshimaModules/Effects/SkillEffects/提升友方行动速度.cs @@ -45,7 +45,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects target.Effects.Add(e); e.OnEffectGained(target); e.EffectType = EffectType.Haste; - GamingQueue?.LastRound.Effects.TryAdd(target, [e.EffectType]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(target, [e.EffectType]); GamingQueue?.ChangeCharacterHardnessTime(target, -0.3, true, false); } } diff --git a/OshimaModules/Effects/SkillEffects/造成封技.cs b/OshimaModules/Effects/SkillEffects/造成封技.cs index 243fa39..27ccf1d 100644 --- a/OshimaModules/Effects/SkillEffects/造成封技.cs +++ b/OshimaModules/Effects/SkillEffects/造成封技.cs @@ -33,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects 封技 e = new(Skill, caster, false, 0, 1); enemy.Effects.Add(e); e.OnEffectGained(enemy); - GamingQueue?.LastRound.Effects.TryAdd(enemy, [e.EffectType]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(enemy, [e.EffectType]); } } } diff --git a/OshimaModules/Effects/SkillEffects/造成眩晕.cs b/OshimaModules/Effects/SkillEffects/造成眩晕.cs index ddca627..84ada44 100644 --- a/OshimaModules/Effects/SkillEffects/造成眩晕.cs +++ b/OshimaModules/Effects/SkillEffects/造成眩晕.cs @@ -35,7 +35,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects 眩晕 e = new(Skill, caster, _durative, _duration, _durationTurn); enemy.Effects.Add(e); e.OnEffectGained(enemy); - GamingQueue?.LastRound.Effects.TryAdd(enemy, [e.EffectType]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(enemy, [e.EffectType]); } } } diff --git a/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs b/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs index 993ce83..f70f17c 100644 --- a/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs +++ b/OshimaModules/Effects/SkillEffects/降低敌方行动速度.cs @@ -46,7 +46,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects e.OnEffectGained(target); e.EffectType = EffectType.Slow; e.IsDebuff = true; - GamingQueue?.LastRound.Effects.TryAdd(target, [e.EffectType]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(target, [e.EffectType]); GamingQueue?.ChangeCharacterHardnessTime(target, 0.3, true, false); } } diff --git a/OshimaModules/Skills/ColdBlue/嗜血本能.cs b/OshimaModules/Skills/ColdBlue/嗜血本能.cs index 0f16ec1..86a8b1c 100644 --- a/OshimaModules/Skills/ColdBlue/嗜血本能.cs +++ b/OshimaModules/Skills/ColdBlue/嗜血本能.cs @@ -59,7 +59,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]); } } } diff --git a/OshimaModules/Skills/MagicalGirl/绝对领域.cs b/OshimaModules/Skills/MagicalGirl/绝对领域.cs index 2dcd432..c675abd 100644 --- a/OshimaModules/Skills/MagicalGirl/绝对领域.cs +++ b/OshimaModules/Skills/MagicalGirl/绝对领域.cs @@ -72,7 +72,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.Invulnerable]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.Invulnerable]); } } } diff --git a/OshimaModules/Skills/Mayor/精准打击.cs b/OshimaModules/Skills/Mayor/精准打击.cs index f1b18f9..858412f 100644 --- a/OshimaModules/Skills/Mayor/精准打击.cs +++ b/OshimaModules/Skills/Mayor/精准打击.cs @@ -66,7 +66,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.CritBoost, EffectType.PenetrationBoost]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.CritBoost, EffectType.PenetrationBoost]); } } } diff --git a/OshimaModules/Skills/NanGanyu/三重叠加.cs b/OshimaModules/Skills/NanGanyu/三重叠加.cs index 1ce94ce..8d46541 100644 --- a/OshimaModules/Skills/NanGanyu/三重叠加.cs +++ b/OshimaModules/Skills/NanGanyu/三重叠加.cs @@ -62,7 +62,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.MPRegen, EffectType.Haste]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.MPRegen, EffectType.Haste]); } } } diff --git a/OshimaModules/Skills/NiuNan/变幻之心.cs b/OshimaModules/Skills/NiuNan/变幻之心.cs index 89f3830..5babf34 100644 --- a/OshimaModules/Skills/NiuNan/变幻之心.cs +++ b/OshimaModules/Skills/NiuNan/变幻之心.cs @@ -72,7 +72,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost]); } } } diff --git a/OshimaModules/Skills/Oshima/力量爆发.cs b/OshimaModules/Skills/Oshima/力量爆发.cs index 15f9af7..dc33c6f 100644 --- a/OshimaModules/Skills/Oshima/力量爆发.cs +++ b/OshimaModules/Skills/Oshima/力量爆发.cs @@ -66,7 +66,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost]); } } } diff --git a/OshimaModules/Skills/QWQAQW/迅捷之势.cs b/OshimaModules/Skills/QWQAQW/迅捷之势.cs index 13dff57..7bfaeb6 100644 --- a/OshimaModules/Skills/QWQAQW/迅捷之势.cs +++ b/OshimaModules/Skills/QWQAQW/迅捷之势.cs @@ -79,7 +79,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Haste, EffectType.DefenseBoost]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Haste, EffectType.DefenseBoost]); } } } diff --git a/OshimaModules/Skills/QuDuoduo/血之狂欢.cs b/OshimaModules/Skills/QuDuoduo/血之狂欢.cs index 97bab06..a539237 100644 --- a/OshimaModules/Skills/QuDuoduo/血之狂欢.cs +++ b/OshimaModules/Skills/QuDuoduo/血之狂欢.cs @@ -47,7 +47,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.Lifesteal]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.Lifesteal]); } } } diff --git a/OshimaModules/Skills/XinYin/天赐之力.cs b/OshimaModules/Skills/XinYin/天赐之力.cs index bb62677..650d099 100644 --- a/OshimaModules/Skills/XinYin/天赐之力.cs +++ b/OshimaModules/Skills/XinYin/天赐之力.cs @@ -87,7 +87,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.PenetrationBoost]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.PenetrationBoost]); } } } diff --git a/OshimaModules/Skills/Yang/魔法涌流.cs b/OshimaModules/Skills/Yang/魔法涌流.cs index 74e7f0f..3fda2c5 100644 --- a/OshimaModules/Skills/Yang/魔法涌流.cs +++ b/OshimaModules/Skills/Yang/魔法涌流.cs @@ -73,7 +73,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DefenseBoost]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DefenseBoost]); } } } diff --git a/OshimaModules/Skills/dddovo/平衡强化.cs b/OshimaModules/Skills/dddovo/平衡强化.cs index 95138f4..ae3ae19 100644 --- a/OshimaModules/Skills/dddovo/平衡强化.cs +++ b/OshimaModules/Skills/dddovo/平衡强化.cs @@ -68,7 +68,7 @@ namespace Oshima.FunGame.OshimaModules.Skills caster.Effects.Add(this); OnEffectGained(caster); } - GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]); + GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]); } } } diff --git a/OshimaModules/Skills/战技/疾风步.cs b/OshimaModules/Skills/战技/疾风步.cs index 1825efa..59d6115 100644 --- a/OshimaModules/Skills/战技/疾风步.cs +++ b/OshimaModules/Skills/战技/疾风步.cs @@ -78,7 +78,7 @@ namespace Oshima.FunGame.OshimaModules.Skills { if (!caster.Effects.Contains(this)) { - GamingQueue?.LastRound.Effects.Add(caster, [EffectType]); + GamingQueue?.LastRound.ApplyEffects.Add(caster, [EffectType]); 首次伤害 = true; 破隐一击 = false; RemainDuration = Duration; diff --git a/OshimaServers/FastAutoServer.cs b/OshimaServers/FastAutoServer.cs index 3cfd026..dc39498 100644 --- a/OshimaServers/FastAutoServer.cs +++ b/OshimaServers/FastAutoServer.cs @@ -167,7 +167,7 @@ namespace Oshima.FunGame.OshimaServers SendAllGamingMessage(obj, data, c.GetInfo()); } - ActionQueue actionQueue = new(inGameCharacters, false, (str) => + MixGamingQueue actionQueue = new(inGameCharacters, (str) => { SendAllGamingMessage(obj, data, str); }); @@ -332,7 +332,7 @@ namespace Oshima.FunGame.OshimaServers } } - public static void 空投(ActionQueue queue, double totalTime) + public static void 空投(GamingQueue queue, double totalTime) { Item[] 这次发放的空投; if (totalTime == 0) diff --git a/OshimaServers/Service/FunGameActionQueue.cs b/OshimaServers/Service/FunGameActionQueue.cs index 6685ace..0a1725a 100644 --- a/OshimaServers/Service/FunGameActionQueue.cs +++ b/OshimaServers/Service/FunGameActionQueue.cs @@ -7,7 +7,7 @@ namespace Oshima.FunGame.OshimaServers.Service { public class FunGameActionQueue { - public ActionQueue ActionQueue { get; set; } = new(); + public GamingQueue GamingQueue { get; set; } = new(); public bool IsWeb { get; set; } = false; public bool PrintOut { get; set; } = false; public bool DeathMatchRoundDetail { get; set; } = false; @@ -15,7 +15,7 @@ namespace Oshima.FunGame.OshimaServers.Service private string _msg = ""; - public async Task> StartGame(List characters, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) + public async Task> StartGame(List characters, int maxRespawnTimes = 0, int maxScoreToWin = 0, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) { Result.Clear(); PrintOut = printout; @@ -30,7 +30,11 @@ namespace Oshima.FunGame.OshimaServers.Service if (PrintOut) Console.WriteLine(); // 创建顺序表并排序 - ActionQueue actionQueue = new(characters, false, WriteLine); + MixGamingQueue actionQueue = new(characters, WriteLine) + { + MaxRespawnTimes = maxRespawnTimes, + MaxScoreToWin = maxScoreToWin + }; actionQueue.SetCharactersToAIControl(false, characters); foreach (Character dead in characters) { @@ -40,7 +44,7 @@ namespace Oshima.FunGame.OshimaServers.Service actionQueue.Eliminated.Add(dead); } } - ActionQueue = actionQueue; + GamingQueue = actionQueue; if (PrintOut) Console.WriteLine(); // 总游戏时长 @@ -156,7 +160,7 @@ namespace Oshima.FunGame.OshimaServers.Service } // 赛后统计 - FunGameService.GetCharacterRating(actionQueue.CharacterStatistics, false, actionQueue.EliminatedTeams); + FunGameService.GetCharacterRating(actionQueue.CharacterStatistics, false, []); // 统计技术得分,评选 MVP Character? mvp = actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key).FirstOrDefault(); @@ -244,7 +248,7 @@ namespace Oshima.FunGame.OshimaServers.Service List characters = [.. teams.SelectMany(t => t.Members)]; // 创建顺序表并排序 - ActionQueue actionQueue = new(characters, true, WriteLine) + TeamGamingQueue actionQueue = new(characters, WriteLine) { MaxRespawnTimes = maxRespawnTimes, MaxScoreToWin = maxScoreToWin @@ -258,7 +262,7 @@ namespace Oshima.FunGame.OshimaServers.Service actionQueue.Eliminated.Add(dead); } } - ActionQueue = actionQueue; + GamingQueue = actionQueue; if (PrintOut) Console.WriteLine(); // 总游戏时长 @@ -424,9 +428,9 @@ namespace Oshima.FunGame.OshimaServers.Service if (PrintOut) Console.WriteLine(str); } - public static async Task> NewAndStartGame(List characters, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) + public static async Task> NewAndStartGame(List characters, int maxRespawnTimes = 0, int maxScoreToWin = 0, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) { - return await new FunGameActionQueue().StartGame(characters, printout, isWeb, deathMatchRoundDetail, showRoundEndDetail, showAllRound); + return await new FunGameActionQueue().StartGame(characters, maxRespawnTimes, maxScoreToWin, printout, isWeb, deathMatchRoundDetail, showRoundEndDetail, showAllRound); } public static async Task> NewAndStartTeamGame(List teams, int maxRespawnTimes = 0, int maxScoreToWin = 0, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) diff --git a/OshimaServers/Service/FunGameService.cs b/OshimaServers/Service/FunGameService.cs index d1705d0..206a109 100644 --- a/OshimaServers/Service/FunGameService.cs +++ b/OshimaServers/Service/FunGameService.cs @@ -1447,10 +1447,7 @@ namespace Oshima.FunGame.OshimaServers.Service if (team is null) { baseScore += stats.Kills * 0.1; - if (stats.Deaths == 0) - { - baseScore += 0.5; - } + baseScore -= stats.Deaths * 0.05; } else { @@ -1458,7 +1455,7 @@ namespace Oshima.FunGame.OshimaServers.Service } // 伤害贡献 - double logDamageContribution = Math.Log(1 + (stats.TotalDamage / (stats.TotalTakenDamage + 1))); + double logDamageContribution = Math.Log(1 + (stats.TotalDamage / (stats.TotalTakenDamage + 1.75))); // 存活时间贡献 double liveTimeContribution = Math.Log(1 + (stats.LiveTime / (stats.TotalTakenDamage + 0.01) * 100)); diff --git a/OshimaServers/Service/FunGameSimulation.cs b/OshimaServers/Service/FunGameSimulation.cs index a6ecc96..e64e832 100644 --- a/OshimaServers/Service/FunGameSimulation.cs +++ b/OshimaServers/Service/FunGameSimulation.cs @@ -1,6 +1,7 @@ using System.Text; using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Model; using Oshima.FunGame.OshimaModules.Effects.OpenEffects; @@ -14,6 +15,7 @@ namespace Oshima.FunGame.OshimaServers.Service public static Dictionary TeamCharacterStatistics { get; } = []; public static PluginConfig StatsConfig { get; } = new("FunGameSimulation", nameof(CharacterStatistics)); public static PluginConfig TeamStatsConfig { get; } = new("FunGameSimulation", nameof(TeamCharacterStatistics)); + public static PluginConfig LastRecordConfig { get; } = new("FunGameSimulation", "LastRecord"); public static bool IsRuning { get; set; } = false; public static bool IsWeb { get; set; } = false; public static bool PrintOut { get; set; } = false; @@ -24,6 +26,7 @@ namespace Oshima.FunGame.OshimaServers.Service { CharacterStatistics.Clear(); TeamCharacterStatistics.Clear(); + LastRecordConfig.Clear(); foreach (Character c in FunGameConstant.Characters) { @@ -54,7 +57,7 @@ namespace Oshima.FunGame.OshimaServers.Service } } - public static async Task> StartSimulationGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false) + public static async Task> StartSimulationGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false, int maxRespawnTimesMix = 1) { PrintOut = printout; IsWeb = isWeb; @@ -64,6 +67,7 @@ namespace Oshima.FunGame.OshimaServers.Service if (IsRuning) return ["游戏正在模拟中,请勿重复请求!"]; List result = []; + List lastRecord = []; Msg = ""; IsRuning = true; @@ -123,11 +127,25 @@ namespace Oshima.FunGame.OshimaServers.Service } // 创建顺序表并排序 - ActionQueue actionQueue = new(characters, isTeam, WriteLine); + GamingQueue actionQueue; + MixGamingQueue? mgq = null; + TeamGamingQueue? tgq = null; if (isTeam) { - actionQueue.MaxRespawnTimes = -1; - actionQueue.MaxScoreToWin = 30; + tgq = new TeamGamingQueue(characters, WriteLine) + { + MaxRespawnTimes = -1, + MaxScoreToWin = 30 + }; + actionQueue = tgq; + } + else + { + mgq = new MixGamingQueue(characters, WriteLine) + { + MaxRespawnTimes = maxRespawnTimesMix + }; + actionQueue = mgq; } if (PrintOut) Console.WriteLine(); @@ -177,7 +195,7 @@ namespace Oshima.FunGame.OshimaServers.Service if (PrintOut) Console.WriteLine(); // 团队模式 - if (isTeam) + if (isTeam && actionQueue is TeamGamingQueue tg) { Msg = "=== 团队模式随机分组 ===\r\n\r\n"; // 打乱角色列表 @@ -201,12 +219,12 @@ namespace Oshima.FunGame.OshimaServers.Service } // 添加到团队字典 - actionQueue.AddTeam("队伍一", group1); - actionQueue.AddTeam("队伍二", group2); + tg.AddTeam("队伍一", group1); + tg.AddTeam("队伍二", group2); - foreach (string team in actionQueue.Teams.Keys) + foreach (string team in tg.Teams.Keys) { - WriteLine($"团队【{team}】的成员:\r\n{string.Join("\r\n", actionQueue.Teams[team].Members)}\r\n"); + WriteLine($"团队【{team}】的成员:\r\n{string.Join("\r\n", tg.Teams[team].Members)}\r\n"); } result.Add(Msg); } @@ -235,6 +253,11 @@ namespace Oshima.FunGame.OshimaServers.Service int i = 1; while (i < maxRound) { + if (i != 1) + { + lastRecord.Add(actionQueue.LastRound.ToString()); + } + Msg = ""; if (i == maxRound - 1) { @@ -259,8 +282,8 @@ namespace Oshima.FunGame.OshimaServers.Service WriteLine("[ " + winner + " ] 对 [ " + c + " ] 造成了 99999999999 点真实伤害。"); await actionQueue.DeathCalculationAsync(winner, c); } - await actionQueue.EndGameInfo(winner); result.Add(Msg); + mgq?.EndGameInfo(winner); break; } } @@ -272,13 +295,14 @@ namespace Oshima.FunGame.OshimaServers.Service if (characterToAct != null) { WriteLine($"=== Round {i++} ==="); - WriteLine("现在是 [ " + characterToAct + (isTeam ? "(" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + ")" : "") + " ] 的回合!"); + WriteLine("现在是 [ " + characterToAct + (tgq != null ? "(" + (tgq.GetTeam(characterToAct)?.Name ?? "") + ")" : "") + " ] 的回合!"); bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct); if (isGameEnd) { result.Add(Msg); + lastRecord.Add(actionQueue.LastRound.ToString()); break; } @@ -292,7 +316,7 @@ namespace Oshima.FunGame.OshimaServers.Service roundMsg = Msg; if (!deathMatchRoundDetail) { - roundMsg = actionQueue.LastRound.ToString().Trim() + $"\r\n{(isTeam ? $"比分:{string.Join(" / ", actionQueue.Teams.Values.Select(t => $"{t.Name}({t.Score})"))},击杀来自{actionQueue.GetTeam(actionQueue.LastRound.Actor)}" : "")}\r\n"; + roundMsg = actionQueue.LastRound.ToString().Trim() + $"\r\n{(tgq != null ? $"比分:{string.Join(" / ", tgq.Teams.Values.Select(t => $"{t.Name}({t.Score})"))},击杀来自{tgq.GetTeam(tgq.LastRound.Actor)}" : "")}\r\n"; } Msg = ""; } @@ -351,7 +375,7 @@ namespace Oshima.FunGame.OshimaServers.Service } // 赛后统计 - FunGameService.GetCharacterRating(actionQueue.CharacterStatistics, isTeam, actionQueue.EliminatedTeams); + FunGameService.GetCharacterRating(actionQueue.CharacterStatistics, isTeam, tgq != null ? tgq.EliminatedTeams : []); // 统计技术得分,评选 MVP Character? mvp = actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key).FirstOrDefault(); @@ -360,7 +384,7 @@ namespace Oshima.FunGame.OshimaServers.Service { CharacterStatistics stats = actionQueue.CharacterStatistics[mvp]; stats.MVPs++; - mvpBuilder.AppendLine($"{(isTeam ? "[ " + actionQueue.GetTeamFromEliminated(mvp)?.Name + " ] " : "")}[ {mvp.ToStringWithLevel()} ]"); + mvpBuilder.AppendLine($"{(tgq != null ? "[ " + tgq.GetTeamFromEliminated(mvp)?.Name + " ] " : "")}[ {mvp.ToStringWithLevel()} ]"); mvpBuilder.AppendLine($"技术得分:{stats.Rating:0.0#} / 击杀数:{stats.Kills} / 助攻数:{stats.Assists}{(actionQueue.MaxRespawnTimes != 0 ? " / 死亡数:" + stats.Deaths : "")}"); mvpBuilder.AppendLine($"存活时长:{stats.LiveTime:0.##} / 存活回合数:{stats.LiveRound} / 行动回合数:{stats.ActionTurn}"); mvpBuilder.AppendLine($"控制时长:{stats.ControlTime:0.##} / 总计治疗:{stats.TotalHeal:0.##}"); @@ -379,20 +403,32 @@ namespace Oshima.FunGame.OshimaServers.Service else { StringBuilder ratingBuilder = new(); - if (isTeam) + if (tgq != null) { ratingBuilder.AppendLine($"=== 赛后数据 ==="); - foreach (Team team in actionQueue.EliminatedTeams) + foreach (Team team in tgq.EliminatedTeams) { ratingBuilder.AppendLine($"☆--- [ {team} ] ---☆"); - foreach (Character character in actionQueue.CharacterStatistics.Where(d => team.Members.Contains(d.Key)) + foreach (Character character in tgq.CharacterStatistics.Where(d => team.Members.Contains(d.Key)) .OrderByDescending(d => d.Value.Rating).Select(d => d.Key)) { - CharacterStatistics stats = actionQueue.CharacterStatistics[character]; + CharacterStatistics stats = tgq.CharacterStatistics[character]; ratingBuilder.AppendLine($"[ {stats.Rating:0.0#} ] {character}({stats.Kills} / {stats.Assists} / {stats.Deaths})"); } } } + else if (mgq != null) + { + ratingBuilder.AppendLine($"=== 赛后数据 ==="); + foreach (Character statCharacter in actionQueue.CharacterStatistics + .OrderBy(kv => kv.Value.Deaths) + .ThenByDescending(kv => kv.Value.Rating) + .ThenByDescending(kv => kv.Value.Kills).Select(kv => kv.Key)) + { + CharacterStatistics stats = actionQueue.CharacterStatistics[statCharacter]; + ratingBuilder.AppendLine($"[ {stats.Rating:0.0#} ] {statCharacter}({stats.Kills} / {stats.Assists} / {stats.Deaths})"); + } + } WriteLine("=== 本场比赛最佳角色 ==="); Msg = $"=== 本场比赛最佳角色 ===\r\n"; WriteLine(mvpBuilder.ToString() + "\r\n\r\n" + ratingBuilder.ToString()); @@ -404,14 +440,14 @@ namespace Oshima.FunGame.OshimaServers.Service } } - if (isTeam) + if (tgq != null) { - foreach (Character character in actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key)) + foreach (Character character in tgq.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key)) { StringBuilder builder = new(); - CharacterStatistics stats = actionQueue.CharacterStatistics[character]; - builder.AppendLine($"{(isWeb ? count + "." : ("[ " + actionQueue.GetTeamFromEliminated(character)?.Name + " ]" ?? ""))} [ {character.ToStringWithLevel()} ]"); - builder.AppendLine($"技术得分:{stats.Rating:0.0#} / 击杀数:{stats.Kills} / 助攻数:{stats.Assists}{(actionQueue.MaxRespawnTimes != 0 ? " / 死亡数:" + stats.Deaths : "")}"); + CharacterStatistics stats = tgq.CharacterStatistics[character]; + builder.AppendLine($"{(isWeb ? count + "." : ("[ " + tgq.GetTeamFromEliminated(character)?.Name + " ]" ?? ""))} [ {character.ToStringWithLevel()} ]"); + builder.AppendLine($"技术得分:{stats.Rating:0.0#} / 击杀数:{stats.Kills} / 助攻数:{stats.Assists}{(tgq.MaxRespawnTimes != 0 ? " / 死亡数:" + stats.Deaths : "")}"); builder.AppendLine($"存活时长:{stats.LiveTime:0.##} / 存活回合数:{stats.LiveRound} / 行动回合数:{stats.ActionTurn}"); builder.AppendLine($"控制时长:{stats.ControlTime:0.##} / 总计治疗:{stats.TotalHeal:0.##}"); builder.AppendLine($"总计伤害:{stats.TotalDamage:0.##} / 总计物理伤害:{stats.TotalPhysicalDamage:0.##} / 总计魔法伤害:{stats.TotalMagicDamage:0.##}"); @@ -464,16 +500,17 @@ namespace Oshima.FunGame.OshimaServers.Service } result.Add(Msg); + lastRecord.Add(Msg); // 显示每个角色的信息 if (isWeb) { - if (isTeam) + if (tgq != null) { top = 1; - for (i = actionQueue.EliminatedTeams.Count - 1; i >= 0; i--) + for (i = tgq.EliminatedTeams.Count - 1; i >= 0; i--) { - Team team = actionQueue.EliminatedTeams[i]; + Team team = tgq.EliminatedTeams[i]; string topTeam = ""; if (top == 1) { @@ -493,7 +530,9 @@ namespace Oshima.FunGame.OshimaServers.Service } foreach (Character character in team.Members) { - result.Add($"== {topTeam}团队 [ {team.Name} ] ==\r\n== 角色:[ {character} ] ==\r\n{character.GetInfo()}"); + string msg = $"== {topTeam}团队 [ {team.Name} ] ==\r\n== 角色:[ {character} ] ==\r\n{character.GetInfo()}"; + result.Add(msg); + lastRecord.Add(msg); } top++; } @@ -503,7 +542,9 @@ namespace Oshima.FunGame.OshimaServers.Service for (i = actionQueue.Eliminated.Count - 1; i >= 0; i--) { Character character = actionQueue.Eliminated[i]; - result.Add($"=== 角色 [ {character} ] ===\r\n{character.GetInfo()}"); + string msg = $"=== 角色 [ {character} ] ===\r\n{character.GetInfo()}"; + result.Add(msg); + lastRecord.Add(msg); } } } @@ -531,6 +572,13 @@ namespace Oshima.FunGame.OshimaServers.Service } } + lock (LastRecordConfig) + { + LastRecordConfig.Add("last", result); + LastRecordConfig.Add("full", lastRecord); + LastRecordConfig.SaveConfig(); + } + IsRuning = false; } @@ -550,7 +598,7 @@ namespace Oshima.FunGame.OshimaServers.Service if (PrintOut) Console.WriteLine(str); } - public static void 空投(ActionQueue queue, int mQuality, int wQuality, int aQuality, int sQuality, int acQuality) + public static void 空投(GamingQueue queue, int mQuality, int wQuality, int aQuality, int sQuality, int acQuality) { foreach (Character character in queue.Queue) { diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index ef03752..da55fa9 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -31,12 +31,19 @@ namespace Oshima.FunGame.WebAPI.Controllers [AllowAnonymous] [HttpGet("test")] - public async Task> GetTest([FromQuery] bool? isweb = null, [FromQuery] bool? isteam = null, [FromQuery] bool? showall = null) + public async Task> GetTest([FromQuery] bool? isweb = null, [FromQuery] bool? isteam = null, [FromQuery] bool? showall = null, [FromQuery] int? maxRespawnTimesMix = null) { - bool web = isweb ?? true; - bool team = isteam ?? false; - bool all = showall ?? false; - return await FunGameSimulation.StartSimulationGame(false, web, team, all); + return await FunGameSimulation.StartSimulationGame(false, isweb ?? true, isteam ?? false, showall ?? false, maxRespawnTimesMix ?? 1); + } + + [AllowAnonymous] + [HttpGet("last")] + public string[] GetLast([FromQuery] bool full = false) + { + PluginConfig LastRecordConfig = new("FunGameSimulation", "LastRecord"); + LastRecordConfig.LoadConfig(); + string get = full ? "full" : "last"; + return LastRecordConfig.Get(get) ?? []; } [AllowAnonymous] @@ -1874,7 +1881,7 @@ namespace Oshima.FunGame.WebAPI.Controllers { user1.Inventory.MainCharacter.Recovery(EP: 200); user2.Inventory.MainCharacter.Recovery(EP: 200); - return await FunGameActionQueue.NewAndStartGame([user1.Inventory.MainCharacter, user2.Inventory.MainCharacter], false, false, false, false, showAllRound); + return await FunGameActionQueue.NewAndStartGame([user1.Inventory.MainCharacter, user2.Inventory.MainCharacter], 0, 0, false, false, false, false, showAllRound); } else { @@ -3462,7 +3469,7 @@ namespace Oshima.FunGame.WebAPI.Controllers } Character boss2 = CharacterBuilder.Build(boss, false, true, null, FunGameConstant.AllItems, FunGameConstant.AllSkills, false); - List msgs = await FunGameActionQueue.NewAndStartGame([user.Inventory.MainCharacter, boss2], false, false, false, false, showAllRound); + List msgs = await FunGameActionQueue.NewAndStartGame([user.Inventory.MainCharacter, boss2], 0, 0, false, false, false, false, showAllRound); if (boss2.HP <= 0) { diff --git a/OshimaWebAPI/Services/RainBOTService.cs b/OshimaWebAPI/Services/RainBOTService.cs index a875eb3..9085d77 100644 --- a/OshimaWebAPI/Services/RainBOTService.cs +++ b/OshimaWebAPI/Services/RainBOTService.cs @@ -221,7 +221,7 @@ namespace Oshima.FunGame.WebAPI.Services if (!FunGameSimulation) { FunGameSimulation = true; - List msgs = await Controller.GetTest(false); + List msgs = await Controller.GetTest(false, maxRespawnTimesMix: 0); List real = []; int remain = 7; string merge = ""; @@ -263,6 +263,66 @@ namespace Oshima.FunGame.WebAPI.Services } return result; } + + if (e.Detail.StartsWith("混战模拟")) + { + int maxRespawnTimesMix = 1; + string detail = e.Detail.Replace("混战模拟", "").Trim(); + if (int.TryParse(detail, out int times)) + { + maxRespawnTimesMix = times; + } + if (!FunGameSimulation) + { + FunGameSimulation = true; + List msgs = await Controller.GetTest(false, maxRespawnTimesMix: maxRespawnTimesMix); + List real = []; + int remain = 7; + string merge = ""; + for (int i = 0; i < msgs.Count - 2; i++) + { + remain--; + merge += msgs[i] + "\r\n"; + if (remain == 0) + { + real.Add(merge); + merge = ""; + if ((msgs.Count - i - 3) < 7) + { + remain = msgs.Count - i - 3; + } + else remain = 7; + } + } + if (msgs.Count > 2) + { + real.Add(msgs[^2]); + real.Add(msgs[^1]); + } + if (real.Count >= 3) + { + real = real[^3..]; + } + int count = 1; + foreach (string msg in real) + { + await SendAsync(e, "饭给木", msg.Trim(), msgSeq: count++); + await Task.Delay(5500); + } + FunGameSimulation = false; + } + else + { + await SendAsync(e, "饭给木", "游戏正在模拟中,请勿重复请求!"); + } + return result; + } + + if (e.Detail == "上次的完整日志") + { + await SendAsync(e, "饭给木", string.Join("\r\n", Controller.GetLast())); + return result; + } if (e.Detail.StartsWith("FunGame团队模拟", StringComparison.CurrentCultureIgnoreCase)) { @@ -2004,7 +2064,7 @@ namespace Oshima.FunGame.WebAPI.Services } return result; } - + if (e.Detail == "毕业礼包") { string msg = Controller.CreateGiftBox(uid, "毕业礼包");