diff --git a/OshimaModules/Regions/OshimaRegion.cs b/OshimaModules/Regions/OshimaRegion.cs index ffbfbbf..993a1ec 100644 --- a/OshimaModules/Regions/OshimaRegion.cs +++ b/OshimaModules/Regions/OshimaRegion.cs @@ -53,28 +53,40 @@ namespace Oshima.FunGame.OshimaModules.Regions builder.AppendLine($"温度:{Temperature} ℃"); builder.AppendLine($"{Description}"); + if (Areas.Count > 0) + { + builder.AppendLine($"== 区域 =="); + builder.AppendLine(string.Join("、", Areas)); + } + if (Characters.Count > 0) { builder.AppendLine($"== 头目 =="); - builder.AppendLine(string.Join(",", Characters.Select(c => c.Name))); + builder.AppendLine(string.Join("、", Characters.Select(c => c.Name))); } if (Units.Count > 0) { builder.AppendLine($"== 生物 =="); - builder.AppendLine(string.Join(",", Units.Select(u => u.Name))); + builder.AppendLine(string.Join("、", Units.Select(u => u.Name))); } if (Crops.Count > 0) { builder.AppendLine($"== 作物 =="); - builder.AppendLine(string.Join(",", Crops.Select(i => i.Name + ":" + i.Description + "\"" + i.BackgroundStory + "\""))); + builder.AppendLine(string.Join("、", Crops.Select(i => i.Name + ":" + i.Description + "\"" + i.BackgroundStory + "\""))); + } + + if (NPCs.Count > 0) + { + builder.AppendLine($"== NPC =="); + builder.AppendLine(string.Join("、", NPCs)); } if (Items.Count > 0) { builder.AppendLine($"== 掉落 =="); - builder.AppendLine(string.Join(",", Items.Select(i => + builder.AppendLine(string.Join("、", Items.Select(i => { string itemquality = ItemSet.GetQualityTypeName(i.QualityType); string itemtype = ItemSet.GetItemTypeName(i.ItemType) + (i.ItemType == ItemType.Weapon && i.WeaponType != WeaponType.None ? "-" + ItemSet.GetWeaponTypeName(i.WeaponType) : ""); @@ -83,6 +95,13 @@ namespace Oshima.FunGame.OshimaModules.Regions }))); } + Dictionary quests = ContinuousQuestList.Union(ImmediateQuestList).Union(ProgressiveQuestList).ToDictionary(); + if (quests.Count > 0) + { + builder.AppendLine($"== 任务 =="); + builder.AppendLine(string.Join("、", quests.Select(q => $"{q.Key}:{q.Value.Description}"))); + } + builder.AppendLine($"探索难度:{CharacterSet.GetRarityTypeName(Difficulty)}"); return builder.ToString().Trim(); diff --git a/OshimaServers/Model/Cooperative.cs b/OshimaServers/Model/Cooperative.cs index 98b41e5..d81c43d 100644 --- a/OshimaServers/Model/Cooperative.cs +++ b/OshimaServers/Model/Cooperative.cs @@ -122,8 +122,8 @@ namespace Oshima.FunGame.OshimaServers.Model // 开始战斗 Team team1 = new($"房间{room.Roomid}", characters.Values); Team team2 = new($"{region.Name}", enemys); - FunGameActionQueue actionQueue = new(); - List gameMsgs = await actionQueue.StartTeamGame([team1, team2], showAllRound: true); + FunGameActionQueue actionQueue = await FunGameActionQueue.NewAndStartTeamGame([team1, team2], showAllRound: true); + List gameMsgs = actionQueue.Result; if (gameMsgs.Count > 15) { gameMsgs = gameMsgs[^15..]; diff --git a/OshimaServers/Service/FunGameActionQueue.cs b/OshimaServers/Service/FunGameActionQueue.cs index 57ab7e5..ee10d87 100644 --- a/OshimaServers/Service/FunGameActionQueue.cs +++ b/OshimaServers/Service/FunGameActionQueue.cs @@ -16,7 +16,7 @@ namespace Oshima.FunGame.OshimaServers.Service private string _msg = ""; - 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) + public List 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; @@ -229,7 +229,7 @@ namespace Oshima.FunGame.OshimaServers.Service } } - public async Task> StartTeamGame(List teams, int maxRespawnTimes = 0, int maxScoreToWin = 0, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) + public List StartTeamGame(List teams, 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; @@ -426,14 +426,18 @@ namespace Oshima.FunGame.OshimaServers.Service if (PrintOut) Console.WriteLine(str); } - 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) + 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, maxRespawnTimes, maxScoreToWin, printout, isWeb, deathMatchRoundDetail, showRoundEndDetail, showAllRound); + FunGameActionQueue actionQueue = new(); + await Task.Run(() => actionQueue.StartGame(characters, maxRespawnTimes, maxScoreToWin, printout, isWeb, deathMatchRoundDetail, showRoundEndDetail, showAllRound)); + return actionQueue; } - 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) + 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) { - return await new FunGameActionQueue().StartTeamGame(teams, maxRespawnTimes, maxScoreToWin, printout, isWeb, deathMatchRoundDetail, showRoundEndDetail, showAllRound); + FunGameActionQueue actionQueue = new(); + await Task.Run(() => actionQueue.StartTeamGame(teams, maxRespawnTimes, maxScoreToWin, printout, isWeb, deathMatchRoundDetail, showRoundEndDetail, showAllRound)); + return actionQueue; } } } diff --git a/OshimaServers/Service/FunGameService.cs b/OshimaServers/Service/FunGameService.cs index 998f7fb..08cd123 100644 --- a/OshimaServers/Service/FunGameService.cs +++ b/OshimaServers/Service/FunGameService.cs @@ -1785,7 +1785,7 @@ namespace Oshima.FunGame.OshimaServers.Service CharacterStatistics[]? teammateStats = null; if (isTeam) { - team = teams.Where(t => t.IsOnThisTeam(character)).FirstOrDefault(); + team = teams.FirstOrDefault(t => t.IsOnThisTeam(character)); if (team != null) { teammateStats = [.. statistics.Where(kv => team.Members.Contains(kv.Key)).Select(kv => kv.Value)]; @@ -2940,8 +2940,8 @@ namespace Oshima.FunGame.OshimaServers.Service // 开始战斗 Team team1 = new($"{user.Username}的探索小队", squad); Team team2 = new($"{region.Name}", enemys); - FunGameActionQueue actionQueue = new(); - List msgs = await actionQueue.StartTeamGame([team1, team2], showAllRound: true); + FunGameActionQueue actionQueue = await FunGameActionQueue.NewAndStartTeamGame([team1, team2], showAllRound: true); + List msgs = actionQueue.Result; if (msgs.Count > 2) { msgs = msgs[^2..]; @@ -3884,8 +3884,8 @@ namespace Oshima.FunGame.OshimaServers.Service _ => "" } + "秘境"; Team team2 = new(team2Name, enemys); - FunGameActionQueue actionQueue = new(); - List msgs = await actionQueue.StartTeamGame([team1, team2], showAllRound: true); + FunGameActionQueue actionQueue = await FunGameActionQueue.NewAndStartTeamGame([team1, team2], showAllRound: true); + List msgs = actionQueue.Result; if (msgs.Count > 2) { msgs = msgs[^2..]; diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index 69c7070..18fda4f 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -2095,7 +2095,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], 0, 0, false, false, false, false, showAllRound); + return (await FunGameActionQueue.NewAndStartGame([user1.Inventory.MainCharacter, user2.Inventory.MainCharacter], 0, 0, false, false, false, false, showAllRound)).Result; } else { @@ -2191,7 +2191,7 @@ namespace Oshima.FunGame.WebAPI.Controllers } Team team1 = new($"{user1.Username}的小队", squad1); Team team2 = new($"{user2.Username}的小队" + (userid == enemyid ? "2" : ""), squad2); - return await FunGameActionQueue.NewAndStartTeamGame([team1, team2], 0, 0, false, false, false, false, showAllRound); + return (await FunGameActionQueue.NewAndStartTeamGame([team1, team2], 0, 0, false, false, false, false, showAllRound)).Result; } else { @@ -4127,7 +4127,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], 0, 0, false, false, false, false, showAllRound); + List msgs = (await FunGameActionQueue.NewAndStartGame([user.Inventory.MainCharacter, boss2], 0, 0, false, false, false, false, showAllRound)).Result; if (boss2.HP <= 0) { @@ -4397,7 +4397,7 @@ namespace Oshima.FunGame.WebAPI.Controllers 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 = await FunGameActionQueue.NewAndStartTeamGame([team1, team2], showAllRound: showAllRound); + List msgs = (await FunGameActionQueue.NewAndStartTeamGame([team1, team2], showAllRound: showAllRound)).Result; if (boss2.HP <= 0) {