diff --git a/OshimaCore/Controllers/FunGameController.cs b/OshimaCore/Controllers/FunGameController.cs index 7b078af..f55a83e 100644 --- a/OshimaCore/Controllers/FunGameController.cs +++ b/OshimaCore/Controllers/FunGameController.cs @@ -27,7 +27,7 @@ namespace Oshima.Core.Controllers bool web = isweb ?? true; bool team = isteam ?? false; bool all = showall ?? false; - return FunGameSimulation.StartGame(false, web, team, all); + return FunGameActionQueue.StartSimulationGame(false, web, team, all); } [HttpGet("stats")] @@ -36,7 +36,7 @@ namespace Oshima.Core.Controllers if (id != null && id > 0 && id <= FunGameService.Characters.Count) { Character character = FunGameService.Characters[Convert.ToInt32(id) - 1]; - if (FunGameSimulation.CharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) + if (FunGameActionQueue.CharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) { StringBuilder builder = new(); @@ -66,14 +66,14 @@ namespace Oshima.Core.Controllers builder.AppendLine($"总计前三数:{stats.Top3s}"); builder.AppendLine($"总计败场数:{stats.Loses}"); - List names = [.. FunGameSimulation.CharacterStatistics.OrderByDescending(kv => kv.Value.MVPs).Select(kv => kv.Key.GetName())]; + List names = [.. FunGameActionQueue.CharacterStatistics.OrderByDescending(kv => kv.Value.MVPs).Select(kv => kv.Key.GetName())]; builder.AppendLine($"MVP次数:{stats.MVPs}(#{names.IndexOf(character.GetName()) + 1})"); - names = [.. FunGameSimulation.CharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key.GetName())]; + names = [.. FunGameActionQueue.CharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key.GetName())]; builder.AppendLine($"胜率:{stats.Winrates * 100:0.##}%(#{names.IndexOf(character.GetName()) + 1})"); builder.AppendLine($"前三率:{stats.Top3rates * 100:0.##}%"); - names = [.. FunGameSimulation.CharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key.GetName())]; + names = [.. FunGameActionQueue.CharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key.GetName())]; builder.AppendLine($"技术得分:{stats.Rating:0.0#}(#{names.IndexOf(character.GetName()) + 1})"); builder.AppendLine($"上次排名:{stats.LastRank} / 场均名次:{stats.AvgRank:0.##}"); @@ -90,7 +90,7 @@ namespace Oshima.Core.Controllers if (id != null && id > 0 && id <= FunGameService.Characters.Count) { Character character = FunGameService.Characters[Convert.ToInt32(id) - 1]; - if (FunGameSimulation.TeamCharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) + if (FunGameActionQueue.TeamCharacterStatistics.TryGetValue(character, out CharacterStatistics? stats) && stats != null) { StringBuilder builder = new(); @@ -120,11 +120,11 @@ namespace Oshima.Core.Controllers builder.AppendLine($"总计胜场数:{stats.Wins}"); builder.AppendLine($"总计败场数:{stats.Loses}"); - List names = [.. FunGameSimulation.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.MVPs).Select(kv => kv.Key.GetName())]; + List names = [.. FunGameActionQueue.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.MVPs).Select(kv => kv.Key.GetName())]; builder.AppendLine($"MVP次数:{stats.MVPs}(#{names.IndexOf(character.GetName()) + 1})"); - names = [.. FunGameSimulation.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key.GetName())]; + names = [.. FunGameActionQueue.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key.GetName())]; builder.AppendLine($"胜率:{stats.Winrates * 100:0.##}%(#{names.IndexOf(character.GetName()) + 1})"); - names = [.. FunGameSimulation.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key.GetName())]; + names = [.. FunGameActionQueue.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key.GetName())]; builder.AppendLine($"技术得分:{stats.Rating:0.0#}(#{names.IndexOf(character.GetName()) + 1})"); return NetworkUtility.JsonSerialize(builder.ToString()); @@ -140,11 +140,11 @@ namespace Oshima.Core.Controllers if (team) { List strings = []; - IEnumerable ratings = FunGameSimulation.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key); + IEnumerable ratings = FunGameActionQueue.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key); foreach (Character character in ratings) { StringBuilder builder = new(); - CharacterStatistics stats = FunGameSimulation.TeamCharacterStatistics[character]; + CharacterStatistics stats = FunGameActionQueue.TeamCharacterStatistics[character]; builder.AppendLine(character.ToString()); builder.AppendLine($"总计参赛数:{stats.Plays}"); builder.AppendLine($"总计冠军数:{stats.Wins}"); @@ -158,11 +158,11 @@ namespace Oshima.Core.Controllers else { List strings = []; - IEnumerable ratings = FunGameSimulation.CharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key); + IEnumerable ratings = FunGameActionQueue.CharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key); foreach (Character character in ratings) { StringBuilder builder = new(); - CharacterStatistics stats = FunGameSimulation.CharacterStatistics[character]; + CharacterStatistics stats = FunGameActionQueue.CharacterStatistics[character]; builder.AppendLine(character.ToString()); builder.AppendLine($"总计参赛数:{stats.Plays}"); builder.AppendLine($"总计冠军数:{stats.Wins}"); @@ -184,11 +184,11 @@ namespace Oshima.Core.Controllers if (team) { List strings = []; - IEnumerable ratings = FunGameSimulation.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key); + IEnumerable ratings = FunGameActionQueue.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key); foreach (Character character in ratings) { StringBuilder builder = new(); - CharacterStatistics stats = FunGameSimulation.TeamCharacterStatistics[character]; + CharacterStatistics stats = FunGameActionQueue.TeamCharacterStatistics[character]; builder.AppendLine(character.ToString()); builder.AppendLine($"总计参赛数:{stats.Plays}"); builder.AppendLine($"总计冠军数:{stats.Wins}"); @@ -202,11 +202,11 @@ namespace Oshima.Core.Controllers else { List strings = []; - IEnumerable ratings = FunGameSimulation.CharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key); + IEnumerable ratings = FunGameActionQueue.CharacterStatistics.OrderByDescending(kv => kv.Value.Rating).Select(kv => kv.Key); foreach (Character character in ratings) { StringBuilder builder = new(); - CharacterStatistics stats = FunGameSimulation.CharacterStatistics[character]; + CharacterStatistics stats = FunGameActionQueue.CharacterStatistics[character]; builder.AppendLine(character.ToString()); builder.AppendLine($"总计参赛数:{stats.Plays}"); builder.AppendLine($"总计冠军数:{stats.Wins}"); @@ -1285,13 +1285,73 @@ namespace Oshima.Core.Controllers } } + [HttpPost("fightcustom")] + public List FightCustom([FromQuery] long? qq = null, [FromQuery] long? eqq = null) + { + try + { + long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + long enemyid = eqq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11)); + + PluginConfig pc = new("saved", userid.ToString()); + pc.LoadConfig(); + + PluginConfig pc2 = new("saved", enemyid.ToString()); + pc2.LoadConfig(); + + User? user1 = null, user2 = null; + + if (pc.Count > 0) + { + user1 = FunGameService.GetUser(pc); + } + else + { + return [noSaved]; + } + + if (pc2.Count > 0) + { + user2 = FunGameService.GetUser(pc2); + } + else + { + return [$"对方貌似还没有创建存档呢!"]; + } + + if (user1 != null && user2 != null) + { + Character? character1 = user1.Inventory.Characters.FirstOrDefault(c => c.Id == user1.Id); + if (character1 is null) + { + return [$"你似乎没有自建角色,请发送【生成自建角色】创建!"]; + } + Character? character2 = user2.Inventory.Characters.FirstOrDefault(c => c.Id == user2.Id); + if (character2 is null) + { + return [$"对方似乎还没有自建角色,请发送【生成自建角色】创建!"]; + } + + return FunGameActionQueue.StartGame([character1, character2], false, false, false, false); + } + else + { + return [$"决斗发起失败!"]; + } + } + catch (Exception e) + { + return [e.ToString()]; + } + } + [HttpGet("reload")] public string Relaod([FromQuery] long? master = null) { if (master != null && master == GeneralSettings.Master) { FunGameService.Reload(); - FunGameSimulation.InitFunGame(); + FunGameActionQueue.InitFunGame(); return NetworkUtility.JsonSerialize("FunGame已重新加载。"); } return NetworkUtility.JsonSerialize("提供的参数不正确。"); diff --git a/OshimaCore/OshimaWebAPI.cs b/OshimaCore/OshimaWebAPI.cs index 8cbec41..b5338c6 100644 --- a/OshimaCore/OshimaWebAPI.cs +++ b/OshimaCore/OshimaWebAPI.cs @@ -20,7 +20,7 @@ namespace Oshima.Core.WebAPI { if (input.StartsWith("fungametest")) { - FunGameSimulation.StartGame(true, true); + FunGameActionQueue.StartSimulationGame(true, true); } // OSM鎸囦护 if (input.Length >= 4 && input[..4].Equals(".osm", StringComparison.CurrentCultureIgnoreCase)) @@ -43,7 +43,7 @@ namespace Oshima.Core.WebAPI SayNo.InitSayNo(); Ignore.InitIgnore(); FunGameService.InitFunGame(); - FunGameSimulation.InitFunGame(); + FunGameActionQueue.InitFunGame(); Task taskTime = Task.Factory.StartNew(async () => { bool check9 = true; diff --git a/OshimaCore/Utils/FunGameSimulation.cs b/OshimaCore/Utils/FunGameActionQueue.cs similarity index 70% rename from OshimaCore/Utils/FunGameSimulation.cs rename to OshimaCore/Utils/FunGameActionQueue.cs index f030281..7e48b1b 100644 --- a/OshimaCore/Utils/FunGameSimulation.cs +++ b/OshimaCore/Utils/FunGameActionQueue.cs @@ -8,12 +8,12 @@ using Oshima.FunGame.OshimaModules.Skills; namespace Oshima.Core.Utils { - public class FunGameSimulation + public class FunGameActionQueue { public static Dictionary CharacterStatistics { get; } = []; public static Dictionary TeamCharacterStatistics { get; } = []; - public static PluginConfig StatsConfig { get; } = new(nameof(FunGameSimulation), nameof(CharacterStatistics)); - public static PluginConfig TeamStatsConfig { get; } = new(nameof(FunGameSimulation), nameof(TeamCharacterStatistics)); + public static PluginConfig StatsConfig { get; } = new("FunGameSimulation", nameof(CharacterStatistics)); + public static PluginConfig TeamStatsConfig { get; } = new("FunGameSimulation", nameof(TeamCharacterStatistics)); public static bool IsRuning { get; set; } = false; public static bool IsWeb { get; set; } = false; public static bool PrintOut { get; set; } = false; @@ -54,7 +54,7 @@ namespace Oshima.Core.Utils } } - public static List StartGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false) + public static List StartSimulationGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false) { PrintOut = printout; IsWeb = isWeb; @@ -114,201 +114,7 @@ namespace Oshima.Core.Utils Character c = characters[index]; c.Level = clevel; c.NormalAttack.Level = mlevel; - - //IEnumerable magics = Magics.OrderBy(x => Random.Shared.Next()).Take(3); - //foreach (Skill magic in magics) - //{ - // Skill m = magic.Copy(); - // m.Character = c; - // m.Level = mlevel; - // c.Skills.Add(m); - //} - - Skill 鐤鹃姝 = new 鐤鹃姝(c) - { - Level = slevel - }; - c.Skills.Add(鐤鹃姝); - - if (c == character1) - { - Skill META椹 = new META椹(c) - { - Level = 1 - }; - c.Skills.Add(META椹); - - Skill 鍔涢噺鐖嗗彂 = new 鍔涢噺鐖嗗彂(c) - { - Level = mlevel - }; - c.Skills.Add(鍔涢噺鐖嗗彂); - } - - if (c == character2) - { - Skill 蹇冪伒涔嬬伀 = new 蹇冪伒涔嬬伀(c) - { - Level = 1 - }; - c.Skills.Add(蹇冪伒涔嬬伀); - - Skill 澶╄祼涔嬪姏 = new 澶╄祼涔嬪姏(c) - { - Level = slevel - }; - c.Skills.Add(澶╄祼涔嬪姏); - } - - if (c == character3) - { - Skill 榄旀硶闇囪崱 = new 榄旀硶闇囪崱(c) - { - Level = 1 - }; - c.Skills.Add(榄旀硶闇囪崱); - - Skill 榄旀硶娑屾祦 = new 榄旀硶娑屾祦(c) - { - Level = slevel - }; - c.Skills.Add(榄旀硶娑屾祦); - } - - if (c == character4) - { - Skill 鐏佃兘鍙嶅皠 = new 鐏佃兘鍙嶅皠(c) - { - Level = 1 - }; - c.Skills.Add(鐏佃兘鍙嶅皠); - - Skill 涓夐噸鍙犲姞 = new 涓夐噸鍙犲姞(c) - { - Level = slevel - }; - c.Skills.Add(涓夐噸鍙犲姞); - } - - if (c == character5) - { - Skill 鏅烘収涓庡姏閲 = new 鏅烘収涓庡姏閲(c) - { - Level = 1 - }; - c.Skills.Add(鏅烘収涓庡姏閲); - - Skill 鍙樺够涔嬪績 = new 鍙樺够涔嬪績(c) - { - Level = slevel - }; - c.Skills.Add(鍙樺够涔嬪績); - } - - if (c == character6) - { - Skill 鑷村懡鎵撳嚮 = new 鑷村懡鎵撳嚮(c) - { - Level = 1 - }; - c.Skills.Add(鑷村懡鎵撳嚮); - - Skill 绮惧噯鎵撳嚮 = new 绮惧噯鎵撳嚮(c) - { - Level = slevel - }; - c.Skills.Add(绮惧噯鎵撳嚮); - } - - if (c == character7) - { - Skill 姣佺伃涔嬪娍 = new 姣佺伃涔嬪娍(c) - { - Level = 1 - }; - c.Skills.Add(姣佺伃涔嬪娍); - - Skill 缁濆棰嗗煙 = new 缁濆棰嗗煙(c) - { - Level = slevel - }; - c.Skills.Add(缁濆棰嗗煙); - } - - if (c == character8) - { - Skill 鏋鎵撳嚮 = new 鏋鎵撳嚮(c) - { - Level = 1 - }; - c.Skills.Add(鏋鎵撳嚮); - - Skill 鑳介噺姣佺伃 = new 鑳介噺姣佺伃(c) - { - Level = slevel - }; - c.Skills.Add(鑳介噺姣佺伃); - } - - if (c == character9) - { - Skill 鐮撮嚋娌夎垷 = new 鐮撮嚋娌夎垷(c) - { - Level = 1 - }; - c.Skills.Add(鐮撮嚋娌夎垷); - - Skill 杩呮嵎涔嬪娍 = new 杩呮嵎涔嬪娍(c) - { - Level = slevel - }; - c.Skills.Add(杩呮嵎涔嬪娍); - } - - if (c == character10) - { - Skill 绱Н涔嬪帇 = new 绱Н涔嬪帇(c) - { - Level = 1 - }; - c.Skills.Add(绱Н涔嬪帇); - - Skill 鍡滆鏈兘 = new 鍡滆鏈兘(c) - { - Level = slevel - }; - c.Skills.Add(鍡滆鏈兘); - } - - if (c == character11) - { - Skill 鏁忔嵎涔嬪垉 = new 鏁忔嵎涔嬪垉(c) - { - Level = 1 - }; - c.Skills.Add(鏁忔嵎涔嬪垉); - - Skill 骞宠 寮哄寲 = new 骞宠 寮哄寲(c) - { - Level = slevel - }; - c.Skills.Add(骞宠 寮哄寲); - } - - if (c == character12) - { - Skill 寮辫呯寧鎵 = new 寮辫呯寧鎵(c) - { - Level = 1 - }; - c.Skills.Add(寮辫呯寧鎵); - - Skill 琛涔嬬媯娆 = new 琛涔嬬媯娆(c) - { - Level = slevel - }; - c.Skills.Add(琛涔嬬媯娆); - } + FunGameService.AddCharacterSkills(c, 1, slevel, slevel); } // 鍒涘缓椤哄簭琛ㄥ苟鎺掑簭 @@ -753,6 +559,366 @@ namespace Oshima.Core.Utils } } + public static List StartGame(List characters, bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false) + { + PrintOut = printout; + IsWeb = isWeb; + DeathMatchRoundDetail = deathMatchRoundDetail; + try + { + if (IsRuning) return ["娓告垙姝e湪杩涜涓紝璇峰嬁閲嶅璇锋眰锛"]; + + List result = []; + Msg = ""; + + IsRuning = true; + + if (PrintOut) Console.WriteLine(); + if (PrintOut) Console.WriteLine("Start!!!"); + if (PrintOut) Console.WriteLine(); + + // 鍒涘缓椤哄簭琛ㄥ苟鎺掑簭 + ActionQueue actionQueue = new(characters, isTeam, WriteLine); + if (isTeam) + { + actionQueue.MaxRespawnTimes = -1; + actionQueue.MaxScoreToWin = 30; + } + if (PrintOut) Console.WriteLine(); + + // 鎬绘父鎴忔椂闀 + double totalTime = 0; + + // 鏄剧ず瑙掕壊淇℃伅 + if (PrintOut) characters.ForEach(c => Console.WriteLine(c.GetInfo())); + + // 鍥㈤槦妯″紡 + if (isTeam) + { + Msg = "=== 鍥㈤槦妯″紡闅忔満鍒嗙粍 ===\r\n\r\n"; + // 鎵撲贡瑙掕壊鍒楄〃 + List shuffledCharacters = [.. characters.OrderBy(c => Random.Shared.Next())]; + + // 鍒涘缓涓や釜鍥㈤槦 + List group1 = []; + List group2 = []; + + // 灏嗚鑹蹭氦鏇垮垎閰嶅埌涓や釜鍥㈤槦涓 + for (int cid = 0; cid < shuffledCharacters.Count; cid++) + { + if (cid % 2 == 0) + { + group1.Add(shuffledCharacters[cid]); + } + else + { + group2.Add(shuffledCharacters[cid]); + } + } + + // 娣诲姞鍒板洟闃熷瓧鍏 + actionQueue.AddTeam("闃熶紞涓", group1); + actionQueue.AddTeam("闃熶紞浜", group2); + + foreach (string team in actionQueue.Teams.Keys) + { + WriteLine($"鍥㈤槦銆恵team}銆戠殑鎴愬憳锛歕r\n{string.Join("\r\n", actionQueue.Teams[team].Members)}\r\n"); + } + result.Add(Msg); + } + + // 鏄剧ず鍒濆椤哄簭琛 + actionQueue.DisplayQueue(); + if (PrintOut) Console.WriteLine(); + + // 鎬诲洖鍚堟暟 + int maxRound = isTeam ? 9999 : 999; + + // 闅忔満鍥炲悎濂栧姳 + Dictionary> roundRewards = GenerateRoundRewards(maxRound); + + int i = 1; + while (i < maxRound) + { + Msg = ""; + if (i == maxRound - 1) + { + if (isTeam) + { + WriteLine("涓ら槦鎵撳埌澶╂槒鍦版殫锛屾祦灞浜嗭紒锛"); + break; + } + else + { + WriteLine($"=== 缁堝眬瀹″垽 ==="); + Dictionary 浠栦滑鐨勮閲忕櫨鍒嗘瘮 = []; + foreach (Character c in characters) + { + 浠栦滑鐨勮閲忕櫨鍒嗘瘮.TryAdd(c, c.HP / c.MaxHP); + } + double max = 浠栦滑鐨勮閲忕櫨鍒嗘瘮.Values.Max(); + Character winner = 浠栦滑鐨勮閲忕櫨鍒嗘瘮.Keys.Where(c => 浠栦滑鐨勮閲忕櫨鍒嗘瘮[c] == max).First(); + WriteLine("[ " + winner + " ] 鎴愪负浜嗗ぉ閫変箣浜猴紒锛"); + foreach (Character c in characters.Where(c => c != winner && c.HP > 0)) + { + WriteLine("[ " + winner + " ] 瀵 [ " + c + " ] 閫犳垚浜 99999999999 鐐圭湡瀹炰激瀹炽"); + actionQueue.DeathCalculation(winner, c); + } + actionQueue.EndGameInfo(winner); + result.Add(Msg); + break; + } + } + + // 妫鏌ユ槸鍚︽湁瑙掕壊鍙互琛屽姩 + Character? characterToAct = actionQueue.NextCharacter(); + + // 澶勭悊鍥炲悎 + if (characterToAct != null) + { + // 鑾峰彇鍥炲悎濂栧姳 + List skillRewards = []; + if (roundRewards.TryGetValue(i, out List? effectList) && effectList != null) + { + skillRewards = new(effectList); + } + + WriteLine($"=== Round {i++} ==="); + WriteLine("鐜板湪鏄 [ " + characterToAct + (isTeam ? "锛" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "锛" : "") + " ] 鐨勫洖鍚堬紒"); + + // 瀹為檯鐨勫洖鍚堝鍔 + List realSkillRewards = []; + if (skillRewards.Count > 0) + { + foreach (Skill skill in skillRewards) + { + Dictionary effectArgs = []; + if (RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary? dict) && dict != null) + { + effectArgs = new(dict); + } + Dictionary args = new() + { + { "skill", skill }, + { "values", effectArgs } + }; + skill.GamingQueue = actionQueue; + skill.Effects.Add(Factory.OpenFactory.GetInstance(skill.Id, "", args)); + skill.Character = characterToAct; + skill.Level = 1; + actionQueue.LastRound.RoundRewards.Add(skill); + WriteLine($"[ {characterToAct} ] 鑾峰緱浜嗗洖鍚堝鍔憋紒{skill.Description}".Trim()); + if (skill.IsActive) + { + actionQueue.LastRound.Targets.Add(characterToAct); + skill.OnSkillCasted(actionQueue, characterToAct, [characterToAct]); + } + else + { + characterToAct.Skills.Add(skill); + realSkillRewards.Add(skill); + } + } + } + + bool isGameEnd = actionQueue.ProcessTurn(characterToAct); + + if (realSkillRewards.Count > 0) + { + foreach (Skill skill in realSkillRewards) + { + foreach (Effect e in skill.Effects) + { + e.OnEffectLost(characterToAct); + characterToAct.Effects.Remove(e); + } + characterToAct.Skills.Remove(skill); + skill.Character = null; + } + } + + if (isGameEnd) + { + result.Add(Msg); + break; + } + + actionQueue.DisplayQueue(); + WriteLine(""); + } + + string roundMsg = ""; + if (actionQueue.LastRound.HasKill) + { + 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"; + } + Msg = ""; + } + + // 妯℃嫙鏃堕棿娴侀 + double timeLapse = actionQueue.TimeLapse(); + totalTime += timeLapse; + + if (roundMsg != "") + { + if ((isTeam && deathMatchRoundDetail || !isTeam) && isWeb) + { + roundMsg += "\r\n" + Msg; + } + result.Add(roundMsg); + } + } + + if (PrintOut) + { + Console.WriteLine("--- End ---"); + Console.WriteLine($"鎬绘父鎴忔椂闀匡細{totalTime:0.##}"); + Console.WriteLine(""); + } + + // 璧涘悗缁熻 + GetCharacterRating(actionQueue.CharacterStatistics, isTeam, actionQueue.EliminatedTeams); + int top = isWeb ? actionQueue.CharacterStatistics.Count : 4; // 鍥炴墽澶氬皯涓鑹茬殑缁熻淇℃伅 + int count = 1; + if (isWeb) + { + WriteLine("=== 鎶鏈緱鍒嗘帓琛屾 ==="); // 杩欐槸杈撳嚭鍦ㄧ晫闈笂鐨 + Msg = $"=== 鎶鏈緱鍒嗘帓琛屾 TOP{top} ===\r\n"; // 杩欎釜鏄笅涓鏉$粰Result鍥炴墽鐨勬爣棰橈紝瑕嗙洊鎺変笂闈㈡柟娉曢噷鐨勮祴鍊间簡 + } + else + { + //WriteLine("=== 鏈満姣旇禌鏈浣宠鑹 ==="); + //Msg = $"=== 鏈満姣旇禌鏈浣宠鑹 ===\r\n"; + //// 缁熻鎶鏈緱鍒 + //Character? character = actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key).FirstOrDefault(); + //if (character != null) + //{ + // CharacterStatistics stats = actionQueue.CharacterStatistics[character]; + // stats.MVPs++; + // StringBuilder builder = new(); + // builder.AppendLine($"{(isWeb ? count + "." : (isTeam ? "[ " + actionQueue.GetTeamFromEliminated(character)?.Name + " ]" ?? " " : ""))}[ {character.ToStringWithLevel()} ]"); + // builder.AppendLine($"鎶鏈緱鍒嗭細{stats.Rating:0.##} / 鍑绘潃鏁帮細{stats.Kills} / 鍔╂敾鏁帮細{stats.Assists}{(actionQueue.MaxRespawnTimes != 0 ? " / 姝讳骸鏁帮細" + stats.Deaths : "")}"); + // builder.AppendLine($"瀛樻椿鏃堕暱锛歿stats.LiveTime} / 瀛樻椿鍥炲悎鏁帮細{stats.LiveRound} / 琛屽姩鍥炲悎鏁帮細{stats.ActionTurn}"); + // builder.AppendLine($"鎬昏浼ゅ锛歿stats.TotalDamage} / 鎬昏鐗╃悊浼ゅ锛歿stats.TotalPhysicalDamage} / 鎬昏榄旀硶浼ゅ锛歿stats.TotalMagicDamage}"); + // builder.AppendLine($"鎬绘壙鍙椾激瀹筹細{stats.TotalTakenDamage} / 鎬绘壙鍙楃墿鐞嗕激瀹筹細{stats.TotalTakenPhysicalDamage} / 鎬绘壙鍙楅瓟娉曚激瀹筹細{stats.TotalTakenMagicDamage}"); + // builder.Append($"姣忕浼ゅ锛歿stats.DamagePerSecond} / 姣忓洖鍚堜激瀹筹細{stats.DamagePerTurn}"); + // WriteLine(builder.ToString()); + //} + } + + if (PrintOut) + { + Console.WriteLine(); + Console.WriteLine("=== 鎶鏈緱鍒嗘帓琛屾 ==="); + } + + Msg = "=== 鎶鏈緱鍒嗘帓琛屾 ===\r\n"; + + if (isTeam) + { + foreach (Character character in actionQueue.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.##} / 鍑绘潃鏁帮細{stats.Kills} / 鍔╂敾鏁帮細{stats.Assists}{(actionQueue.MaxRespawnTimes != 0 ? " / 姝讳骸鏁帮細" + stats.Deaths : "")}"); + builder.AppendLine($"瀛樻椿鏃堕暱锛歿stats.LiveTime} / 瀛樻椿鍥炲悎鏁帮細{stats.LiveRound} / 琛屽姩鍥炲悎鏁帮細{stats.ActionTurn}"); + builder.AppendLine($"鎬昏浼ゅ锛歿stats.TotalDamage} / 鎬昏鐗╃悊浼ゅ锛歿stats.TotalPhysicalDamage} / 鎬昏榄旀硶浼ゅ锛歿stats.TotalMagicDamage}"); + builder.AppendLine($"鎬绘壙鍙椾激瀹筹細{stats.TotalTakenDamage} / 鎬绘壙鍙楃墿鐞嗕激瀹筹細{stats.TotalTakenPhysicalDamage} / 鎬绘壙鍙楅瓟娉曚激瀹筹細{stats.TotalTakenMagicDamage}"); + builder.Append($"姣忕浼ゅ锛歿stats.DamagePerSecond} / 姣忓洖鍚堜激瀹筹細{stats.DamagePerTurn}"); + if (count++ <= top) + { + WriteLine(builder.ToString()); + } + else + { + if (PrintOut) Console.WriteLine(builder.ToString()); + } + } + } + else + { + foreach (Character character in actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key)) + { + StringBuilder builder = new(); + CharacterStatistics stats = actionQueue.CharacterStatistics[character]; + builder.AppendLine($"{(isWeb ? count + ". " : "")}[ {character.ToStringWithLevel()} ]"); + builder.AppendLine($"鎶鏈緱鍒嗭細{stats.Rating:0.##} / 鍑绘潃鏁帮細{stats.Kills} / 鍔╂敾鏁帮細{stats.Assists}{(actionQueue.MaxRespawnTimes != 0 ? " / 姝讳骸鏁帮細" + stats.Deaths : "")}"); + builder.AppendLine($"瀛樻椿鏃堕暱锛歿stats.LiveTime} / 瀛樻椿鍥炲悎鏁帮細{stats.LiveRound} / 琛屽姩鍥炲悎鏁帮細{stats.ActionTurn}"); + builder.AppendLine($"鎬昏浼ゅ锛歿stats.TotalDamage} / 鎬昏鐗╃悊浼ゅ锛歿stats.TotalPhysicalDamage} / 鎬昏榄旀硶浼ゅ锛歿stats.TotalMagicDamage}"); + builder.AppendLine($"鎬绘壙鍙椾激瀹筹細{stats.TotalTakenDamage} / 鎬绘壙鍙楃墿鐞嗕激瀹筹細{stats.TotalTakenPhysicalDamage} / 鎬绘壙鍙楅瓟娉曚激瀹筹細{stats.TotalTakenMagicDamage}"); + builder.Append($"姣忕浼ゅ锛歿stats.DamagePerSecond} / 姣忓洖鍚堜激瀹筹細{stats.DamagePerTurn}"); + if (count++ <= top) + { + WriteLine(builder.ToString()); + } + else + { + if (PrintOut) Console.WriteLine(builder.ToString()); + } + } + } + + result.Add(Msg); + + // 鏄剧ず姣忎釜瑙掕壊鐨勪俊鎭 + if (isWeb) + { + if (isTeam) + { + top = 1; + for (i = actionQueue.EliminatedTeams.Count - 1; i >= 0; i--) + { + Team team = actionQueue.EliminatedTeams[i]; + string topTeam = ""; + if (top == 1) + { + topTeam = "鍐犲啗"; + } + if (top == 2) + { + topTeam = "浜氬啗"; + } + if (top == 3) + { + topTeam = "瀛e啗"; + } + if (top > 3) + { + topTeam = $"绗 {top} 鍚"; + } + foreach (Character character in team.Members) + { + result.Add($"== {topTeam}鍥㈤槦 [ {team.Name} ] ==\r\n== 瑙掕壊锛歔 {character} ] ==\r\n{character.GetInfo()}"); + } + top++; + } + } + else + { + for (i = actionQueue.Eliminated.Count - 1; i >= 0; i--) + { + Character character = actionQueue.Eliminated[i]; + result.Add($"=== 瑙掕壊 [ {character} ] ===\r\n{character.GetInfo()}"); + } + } + } + + IsRuning = false; + + return result; + } + catch (Exception ex) + { + IsRuning = false; + Console.WriteLine(ex); + return [ex.ToString()]; + } + } + public static void WriteLine(string str) { Msg += str + "\r\n"; diff --git a/OshimaCore/Utils/FunGameService.cs b/OshimaCore/Utils/FunGameService.cs index 7d15f75..29d3f1b 100644 --- a/OshimaCore/Utils/FunGameService.cs +++ b/OshimaCore/Utils/FunGameService.cs @@ -471,6 +471,7 @@ namespace Oshima.Core.Utils if (has.Any() && has.First() is Character character) { realItem.Character = character; + realItem.User = user; } } user.Inventory.Items.Add(realItem); diff --git a/OshimaModules/Skills/榄旀硶/娆″厓涓婂崌.cs b/OshimaModules/Skills/榄旀硶/娆″厓涓婂崌.cs index cc8d392..d3e4ed6 100644 --- a/OshimaModules/Skills/榄旀硶/娆″厓涓婂崌.cs +++ b/OshimaModules/Skills/榄旀硶/娆″厓涓婂崌.cs @@ -17,7 +17,7 @@ namespace Oshima.FunGame.OshimaModules.Skills public 娆″厓涓婂崌(Character? character = null) : base(SkillType.Magic, character) { Effects.Add(new 閫犳垚鐪╂檿(this, true, 15, 0)); - Effects.Add(new 鍩轰簬鏀诲嚮鍔涚殑浼ゅ_甯﹀熀纭浼ゅ(this, 80, 55, 0.5, 0.3)); + Effects.Add(new 鍩轰簬鏀诲嚮鍔涚殑浼ゅ_甯﹀熀纭浼ゅ(this, 40, 40, 0.5, 0.3)); } } }