使用新队列,添加新接口

This commit is contained in:
milimoe 2025-05-01 02:26:14 +08:00
parent 26509a0839
commit eae54423fa
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
22 changed files with 186 additions and 70 deletions

View File

@ -45,7 +45,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects
target.Effects.Add(e); target.Effects.Add(e);
e.OnEffectGained(target); e.OnEffectGained(target);
e.EffectType = EffectType.Haste; 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); GamingQueue?.ChangeCharacterHardnessTime(target, -0.3, true, false);
} }
} }

View File

@ -33,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects
e = new(Skill, caster, false, 0, 1); e = new(Skill, caster, false, 0, 1);
enemy.Effects.Add(e); enemy.Effects.Add(e);
e.OnEffectGained(enemy); e.OnEffectGained(enemy);
GamingQueue?.LastRound.Effects.TryAdd(enemy, [e.EffectType]); GamingQueue?.LastRound.ApplyEffects.TryAdd(enemy, [e.EffectType]);
} }
} }
} }

View File

@ -35,7 +35,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects
e = new(Skill, caster, _durative, _duration, _durationTurn); e = new(Skill, caster, _durative, _duration, _durationTurn);
enemy.Effects.Add(e); enemy.Effects.Add(e);
e.OnEffectGained(enemy); e.OnEffectGained(enemy);
GamingQueue?.LastRound.Effects.TryAdd(enemy, [e.EffectType]); GamingQueue?.LastRound.ApplyEffects.TryAdd(enemy, [e.EffectType]);
} }
} }
} }

View File

@ -46,7 +46,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.SkillEffects
e.OnEffectGained(target); e.OnEffectGained(target);
e.EffectType = EffectType.Slow; e.EffectType = EffectType.Slow;
e.IsDebuff = true; e.IsDebuff = true;
GamingQueue?.LastRound.Effects.TryAdd(target, [e.EffectType]); GamingQueue?.LastRound.ApplyEffects.TryAdd(target, [e.EffectType]);
GamingQueue?.ChangeCharacterHardnessTime(target, 0.3, true, false); GamingQueue?.ChangeCharacterHardnessTime(target, 0.3, true, false);
} }
} }

View File

@ -59,7 +59,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]);
} }
} }
} }

View File

@ -72,7 +72,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.Invulnerable]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.Invulnerable]);
} }
} }
} }

View File

@ -66,7 +66,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.CritBoost, EffectType.PenetrationBoost]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.CritBoost, EffectType.PenetrationBoost]);
} }
} }
} }

View File

@ -62,7 +62,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.MPRegen, EffectType.Haste]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.MPRegen, EffectType.Haste]);
} }
} }
} }

View File

@ -72,7 +72,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost]);
} }
} }
} }

View File

@ -66,7 +66,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost]);
} }
} }
} }

View File

@ -79,7 +79,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Haste, EffectType.DefenseBoost]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Haste, EffectType.DefenseBoost]);
} }
} }
} }

View File

@ -47,7 +47,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.Lifesteal]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.Lifesteal]);
} }
} }
} }

View File

@ -87,7 +87,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.PenetrationBoost]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.PenetrationBoost]);
} }
} }
} }

View File

@ -73,7 +73,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DefenseBoost]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DefenseBoost]);
} }
} }
} }

View File

@ -68,7 +68,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
caster.Effects.Add(this); caster.Effects.Add(this);
OnEffectGained(caster); OnEffectGained(caster);
} }
GamingQueue?.LastRound.Effects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]); GamingQueue?.LastRound.ApplyEffects.TryAdd(caster, [EffectType.DamageBoost, EffectType.Lifesteal]);
} }
} }
} }

View File

@ -78,7 +78,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
{ {
if (!caster.Effects.Contains(this)) if (!caster.Effects.Contains(this))
{ {
GamingQueue?.LastRound.Effects.Add(caster, [EffectType]); GamingQueue?.LastRound.ApplyEffects.Add(caster, [EffectType]);
= true; = true;
= false; = false;
RemainDuration = Duration; RemainDuration = Duration;

View File

@ -167,7 +167,7 @@ namespace Oshima.FunGame.OshimaServers
SendAllGamingMessage(obj, data, c.GetInfo()); SendAllGamingMessage(obj, data, c.GetInfo());
} }
ActionQueue actionQueue = new(inGameCharacters, false, (str) => MixGamingQueue actionQueue = new(inGameCharacters, (str) =>
{ {
SendAllGamingMessage(obj, data, 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[] ; Item[] ;
if (totalTime == 0) if (totalTime == 0)

View File

@ -7,7 +7,7 @@ namespace Oshima.FunGame.OshimaServers.Service
{ {
public class FunGameActionQueue public class FunGameActionQueue
{ {
public ActionQueue ActionQueue { get; set; } = new(); public GamingQueue GamingQueue { get; set; } = new();
public bool IsWeb { get; set; } = false; public bool IsWeb { get; set; } = false;
public bool PrintOut { get; set; } = false; public bool PrintOut { get; set; } = false;
public bool DeathMatchRoundDetail { get; set; } = false; public bool DeathMatchRoundDetail { get; set; } = false;
@ -15,7 +15,7 @@ namespace Oshima.FunGame.OshimaServers.Service
private string _msg = ""; private string _msg = "";
public async Task<List<string>> StartGame(List<Character> characters, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) public async Task<List<string>> StartGame(List<Character> characters, int maxRespawnTimes = 0, int maxScoreToWin = 0, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false)
{ {
Result.Clear(); Result.Clear();
PrintOut = printout; PrintOut = printout;
@ -30,7 +30,11 @@ namespace Oshima.FunGame.OshimaServers.Service
if (PrintOut) Console.WriteLine(); if (PrintOut) Console.WriteLine();
// 创建顺序表并排序 // 创建顺序表并排序
ActionQueue actionQueue = new(characters, false, WriteLine); MixGamingQueue actionQueue = new(characters, WriteLine)
{
MaxRespawnTimes = maxRespawnTimes,
MaxScoreToWin = maxScoreToWin
};
actionQueue.SetCharactersToAIControl(false, characters); actionQueue.SetCharactersToAIControl(false, characters);
foreach (Character dead in characters) foreach (Character dead in characters)
{ {
@ -40,7 +44,7 @@ namespace Oshima.FunGame.OshimaServers.Service
actionQueue.Eliminated.Add(dead); actionQueue.Eliminated.Add(dead);
} }
} }
ActionQueue = actionQueue; GamingQueue = actionQueue;
if (PrintOut) Console.WriteLine(); 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 // 统计技术得分,评选 MVP
Character? mvp = actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key).FirstOrDefault(); Character? mvp = actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key).FirstOrDefault();
@ -244,7 +248,7 @@ namespace Oshima.FunGame.OshimaServers.Service
List<Character> characters = [.. teams.SelectMany(t => t.Members)]; List<Character> characters = [.. teams.SelectMany(t => t.Members)];
// 创建顺序表并排序 // 创建顺序表并排序
ActionQueue actionQueue = new(characters, true, WriteLine) TeamGamingQueue actionQueue = new(characters, WriteLine)
{ {
MaxRespawnTimes = maxRespawnTimes, MaxRespawnTimes = maxRespawnTimes,
MaxScoreToWin = maxScoreToWin MaxScoreToWin = maxScoreToWin
@ -258,7 +262,7 @@ namespace Oshima.FunGame.OshimaServers.Service
actionQueue.Eliminated.Add(dead); actionQueue.Eliminated.Add(dead);
} }
} }
ActionQueue = actionQueue; GamingQueue = actionQueue;
if (PrintOut) Console.WriteLine(); if (PrintOut) Console.WriteLine();
// 总游戏时长 // 总游戏时长
@ -424,9 +428,9 @@ namespace Oshima.FunGame.OshimaServers.Service
if (PrintOut) Console.WriteLine(str); if (PrintOut) Console.WriteLine(str);
} }
public static async Task<List<string>> NewAndStartGame(List<Character> characters, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false) public static async Task<List<string>> NewAndStartGame(List<Character> 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<List<string>> NewAndStartTeamGame(List<Team> 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<List<string>> NewAndStartTeamGame(List<Team> teams, int maxRespawnTimes = 0, int maxScoreToWin = 0, bool printout = false, bool isWeb = false, bool deathMatchRoundDetail = false, bool showRoundEndDetail = false, bool showAllRound = false)

View File

@ -1447,10 +1447,7 @@ namespace Oshima.FunGame.OshimaServers.Service
if (team is null) if (team is null)
{ {
baseScore += stats.Kills * 0.1; baseScore += stats.Kills * 0.1;
if (stats.Deaths == 0) baseScore -= stats.Deaths * 0.05;
{
baseScore += 0.5;
}
} }
else 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)); double liveTimeContribution = Math.Log(1 + (stats.LiveTime / (stats.TotalTakenDamage + 0.01) * 100));

View File

@ -1,6 +1,7 @@
using System.Text; using System.Text;
using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Model; using Milimoe.FunGame.Core.Model;
using Oshima.FunGame.OshimaModules.Effects.OpenEffects; using Oshima.FunGame.OshimaModules.Effects.OpenEffects;
@ -14,6 +15,7 @@ namespace Oshima.FunGame.OshimaServers.Service
public static Dictionary<Character, CharacterStatistics> TeamCharacterStatistics { get; } = []; public static Dictionary<Character, CharacterStatistics> TeamCharacterStatistics { get; } = [];
public static PluginConfig StatsConfig { get; } = new("FunGameSimulation", nameof(CharacterStatistics)); public static PluginConfig StatsConfig { get; } = new("FunGameSimulation", nameof(CharacterStatistics));
public static PluginConfig TeamStatsConfig { get; } = new("FunGameSimulation", nameof(TeamCharacterStatistics)); 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 IsRuning { get; set; } = false;
public static bool IsWeb { get; set; } = false; public static bool IsWeb { get; set; } = false;
public static bool PrintOut { get; set; } = false; public static bool PrintOut { get; set; } = false;
@ -24,6 +26,7 @@ namespace Oshima.FunGame.OshimaServers.Service
{ {
CharacterStatistics.Clear(); CharacterStatistics.Clear();
TeamCharacterStatistics.Clear(); TeamCharacterStatistics.Clear();
LastRecordConfig.Clear();
foreach (Character c in FunGameConstant.Characters) foreach (Character c in FunGameConstant.Characters)
{ {
@ -54,7 +57,7 @@ namespace Oshima.FunGame.OshimaServers.Service
} }
} }
public static async Task<List<string>> StartSimulationGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false) public static async Task<List<string>> StartSimulationGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false, int maxRespawnTimesMix = 1)
{ {
PrintOut = printout; PrintOut = printout;
IsWeb = isWeb; IsWeb = isWeb;
@ -64,6 +67,7 @@ namespace Oshima.FunGame.OshimaServers.Service
if (IsRuning) return ["游戏正在模拟中,请勿重复请求!"]; if (IsRuning) return ["游戏正在模拟中,请勿重复请求!"];
List<string> result = []; List<string> result = [];
List<string> lastRecord = [];
Msg = ""; Msg = "";
IsRuning = true; 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) if (isTeam)
{ {
actionQueue.MaxRespawnTimes = -1; tgq = new TeamGamingQueue(characters, WriteLine)
actionQueue.MaxScoreToWin = 30; {
MaxRespawnTimes = -1,
MaxScoreToWin = 30
};
actionQueue = tgq;
}
else
{
mgq = new MixGamingQueue(characters, WriteLine)
{
MaxRespawnTimes = maxRespawnTimesMix
};
actionQueue = mgq;
} }
if (PrintOut) Console.WriteLine(); if (PrintOut) Console.WriteLine();
@ -177,7 +195,7 @@ namespace Oshima.FunGame.OshimaServers.Service
if (PrintOut) Console.WriteLine(); if (PrintOut) Console.WriteLine();
// 团队模式 // 团队模式
if (isTeam) if (isTeam && actionQueue is TeamGamingQueue tg)
{ {
Msg = "=== 团队模式随机分组 ===\r\n\r\n"; Msg = "=== 团队模式随机分组 ===\r\n\r\n";
// 打乱角色列表 // 打乱角色列表
@ -201,12 +219,12 @@ namespace Oshima.FunGame.OshimaServers.Service
} }
// 添加到团队字典 // 添加到团队字典
actionQueue.AddTeam("队伍一", group1); tg.AddTeam("队伍一", group1);
actionQueue.AddTeam("队伍二", group2); 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); result.Add(Msg);
} }
@ -235,6 +253,11 @@ namespace Oshima.FunGame.OshimaServers.Service
int i = 1; int i = 1;
while (i < maxRound) while (i < maxRound)
{ {
if (i != 1)
{
lastRecord.Add(actionQueue.LastRound.ToString());
}
Msg = ""; Msg = "";
if (i == maxRound - 1) if (i == maxRound - 1)
{ {
@ -259,8 +282,8 @@ namespace Oshima.FunGame.OshimaServers.Service
WriteLine("[ " + winner + " ] 对 [ " + c + " ] 造成了 99999999999 点真实伤害。"); WriteLine("[ " + winner + " ] 对 [ " + c + " ] 造成了 99999999999 点真实伤害。");
await actionQueue.DeathCalculationAsync(winner, c); await actionQueue.DeathCalculationAsync(winner, c);
} }
await actionQueue.EndGameInfo(winner);
result.Add(Msg); result.Add(Msg);
mgq?.EndGameInfo(winner);
break; break;
} }
} }
@ -272,13 +295,14 @@ namespace Oshima.FunGame.OshimaServers.Service
if (characterToAct != null) if (characterToAct != null)
{ {
WriteLine($"=== Round {i++} ==="); WriteLine($"=== Round {i++} ===");
WriteLine("现在是 [ " + characterToAct + (isTeam ? "" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "" : "") + " ] 的回合!"); WriteLine("现在是 [ " + characterToAct + (tgq != null ? "" + (tgq.GetTeam(characterToAct)?.Name ?? "") + "" : "") + " ] 的回合!");
bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct); bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct);
if (isGameEnd) if (isGameEnd)
{ {
result.Add(Msg); result.Add(Msg);
lastRecord.Add(actionQueue.LastRound.ToString());
break; break;
} }
@ -292,7 +316,7 @@ namespace Oshima.FunGame.OshimaServers.Service
roundMsg = Msg; roundMsg = Msg;
if (!deathMatchRoundDetail) 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 = ""; 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 // 统计技术得分,评选 MVP
Character? mvp = actionQueue.CharacterStatistics.OrderByDescending(d => d.Value.Rating).Select(d => d.Key).FirstOrDefault(); 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]; CharacterStatistics stats = actionQueue.CharacterStatistics[mvp];
stats.MVPs++; 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.Rating:0.0#} / 击杀数:{stats.Kills} / 助攻数:{stats.Assists}{(actionQueue.MaxRespawnTimes != 0 ? " / " + stats.Deaths : "")}");
mvpBuilder.AppendLine($"存活时长:{stats.LiveTime:0.##} / 存活回合数:{stats.LiveRound} / 行动回合数:{stats.ActionTurn}"); mvpBuilder.AppendLine($"存活时长:{stats.LiveTime:0.##} / 存活回合数:{stats.LiveRound} / 行动回合数:{stats.ActionTurn}");
mvpBuilder.AppendLine($"控制时长:{stats.ControlTime:0.##} / 总计治疗:{stats.TotalHeal:0.##}"); mvpBuilder.AppendLine($"控制时长:{stats.ControlTime:0.##} / 总计治疗:{stats.TotalHeal:0.##}");
@ -379,20 +403,32 @@ namespace Oshima.FunGame.OshimaServers.Service
else else
{ {
StringBuilder ratingBuilder = new(); StringBuilder ratingBuilder = new();
if (isTeam) if (tgq != null)
{ {
ratingBuilder.AppendLine($"=== 赛后数据 ==="); ratingBuilder.AppendLine($"=== 赛后数据 ===");
foreach (Team team in actionQueue.EliminatedTeams) foreach (Team team in tgq.EliminatedTeams)
{ {
ratingBuilder.AppendLine($"☆--- [ {team} ] ---☆"); 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)) .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}"); 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("=== 本场比赛最佳角色 ==="); WriteLine("=== 本场比赛最佳角色 ===");
Msg = $"=== 本场比赛最佳角色 ===\r\n"; Msg = $"=== 本场比赛最佳角色 ===\r\n";
WriteLine(mvpBuilder.ToString() + "\r\n\r\n" + ratingBuilder.ToString()); 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(); StringBuilder builder = new();
CharacterStatistics stats = actionQueue.CharacterStatistics[character]; CharacterStatistics stats = tgq.CharacterStatistics[character];
builder.AppendLine($"{(isWeb ? count + "." : ("[ " + actionQueue.GetTeamFromEliminated(character)?.Name + " ]" ?? ""))} [ {character.ToStringWithLevel()} ]"); builder.AppendLine($"{(isWeb ? count + "." : ("[ " + tgq.GetTeamFromEliminated(character)?.Name + " ]" ?? ""))} [ {character.ToStringWithLevel()} ]");
builder.AppendLine($"技术得分:{stats.Rating:0.0#} / 击杀数:{stats.Kills} / 助攻数:{stats.Assists}{(actionQueue.MaxRespawnTimes != 0 ? " / " + stats.Deaths : "")}"); 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.LiveTime:0.##} / 存活回合数:{stats.LiveRound} / 行动回合数:{stats.ActionTurn}");
builder.AppendLine($"控制时长:{stats.ControlTime:0.##} / 总计治疗:{stats.TotalHeal:0.##}"); builder.AppendLine($"控制时长:{stats.ControlTime:0.##} / 总计治疗:{stats.TotalHeal:0.##}");
builder.AppendLine($"总计伤害:{stats.TotalDamage:0.##} / 总计物理伤害:{stats.TotalPhysicalDamage:0.##} / 总计魔法伤害:{stats.TotalMagicDamage:0.##}"); builder.AppendLine($"总计伤害:{stats.TotalDamage:0.##} / 总计物理伤害:{stats.TotalPhysicalDamage:0.##} / 总计魔法伤害:{stats.TotalMagicDamage:0.##}");
@ -464,16 +500,17 @@ namespace Oshima.FunGame.OshimaServers.Service
} }
result.Add(Msg); result.Add(Msg);
lastRecord.Add(Msg);
// 显示每个角色的信息 // 显示每个角色的信息
if (isWeb) if (isWeb)
{ {
if (isTeam) if (tgq != null)
{ {
top = 1; 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 = ""; string topTeam = "";
if (top == 1) if (top == 1)
{ {
@ -493,7 +530,9 @@ namespace Oshima.FunGame.OshimaServers.Service
} }
foreach (Character character in team.Members) 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++; top++;
} }
@ -503,7 +542,9 @@ namespace Oshima.FunGame.OshimaServers.Service
for (i = actionQueue.Eliminated.Count - 1; i >= 0; i--) for (i = actionQueue.Eliminated.Count - 1; i >= 0; i--)
{ {
Character character = actionQueue.Eliminated[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; IsRuning = false;
} }
@ -550,7 +598,7 @@ namespace Oshima.FunGame.OshimaServers.Service
if (PrintOut) Console.WriteLine(str); 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) foreach (Character character in queue.Queue)
{ {

View File

@ -31,12 +31,19 @@ namespace Oshima.FunGame.WebAPI.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpGet("test")] [HttpGet("test")]
public async Task<List<string>> GetTest([FromQuery] bool? isweb = null, [FromQuery] bool? isteam = null, [FromQuery] bool? showall = null) public async Task<List<string>> GetTest([FromQuery] bool? isweb = null, [FromQuery] bool? isteam = null, [FromQuery] bool? showall = null, [FromQuery] int? maxRespawnTimesMix = null)
{ {
bool web = isweb ?? true; return await FunGameSimulation.StartSimulationGame(false, isweb ?? true, isteam ?? false, showall ?? false, maxRespawnTimesMix ?? 1);
bool team = isteam ?? false; }
bool all = showall ?? false;
return await FunGameSimulation.StartSimulationGame(false, web, team, all); [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<string[]>(get) ?? [];
} }
[AllowAnonymous] [AllowAnonymous]
@ -1874,7 +1881,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
{ {
user1.Inventory.MainCharacter.Recovery(EP: 200); user1.Inventory.MainCharacter.Recovery(EP: 200);
user2.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 else
{ {
@ -3462,7 +3469,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
} }
Character boss2 = CharacterBuilder.Build(boss, false, true, null, FunGameConstant.AllItems, FunGameConstant.AllSkills, false); Character boss2 = CharacterBuilder.Build(boss, false, true, null, FunGameConstant.AllItems, FunGameConstant.AllSkills, false);
List<string> msgs = await FunGameActionQueue.NewAndStartGame([user.Inventory.MainCharacter, boss2], false, false, false, false, showAllRound); List<string> msgs = await FunGameActionQueue.NewAndStartGame([user.Inventory.MainCharacter, boss2], 0, 0, false, false, false, false, showAllRound);
if (boss2.HP <= 0) if (boss2.HP <= 0)
{ {

View File

@ -221,7 +221,7 @@ namespace Oshima.FunGame.WebAPI.Services
if (!FunGameSimulation) if (!FunGameSimulation)
{ {
FunGameSimulation = true; FunGameSimulation = true;
List<string> msgs = await Controller.GetTest(false); List<string> msgs = await Controller.GetTest(false, maxRespawnTimesMix: 0);
List<string> real = []; List<string> real = [];
int remain = 7; int remain = 7;
string merge = ""; string merge = "";
@ -263,6 +263,66 @@ namespace Oshima.FunGame.WebAPI.Services
} }
return result; 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<string> msgs = await Controller.GetTest(false, maxRespawnTimesMix: maxRespawnTimesMix);
List<string> 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)) if (e.Detail.StartsWith("FunGame团队模拟", StringComparison.CurrentCultureIgnoreCase))
{ {
@ -2004,7 +2064,7 @@ namespace Oshima.FunGame.WebAPI.Services
} }
return result; return result;
} }
if (e.Detail == "毕业礼包") if (e.Detail == "毕业礼包")
{ {
string msg = Controller.CreateGiftBox(uid, "毕业礼包"); string msg = Controller.CreateGiftBox(uid, "毕业礼包");