更新行动顺序表的异步支持

This commit is contained in:
milimoe 2025-04-11 01:22:15 +08:00
parent 492b96aefb
commit 6f66c47902
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
2 changed files with 19 additions and 17 deletions

View File

@ -4,7 +4,7 @@ using Oshima.FunGame.OshimaModules;
using Oshima.FunGame.OshimaServers.Service;
using Oshima.FunGame.WebAPI.Controllers;
_ = new Milimoe.FunGame.Testing.Solutions.Novels();
//_ = new Milimoe.FunGame.Testing.Solutions.Novels();
//_ = new Milimoe.FunGame.Testing.Tests.CheckDLL();
@ -24,8 +24,8 @@ FunGameSimulation.InitFunGameSimulation();
//_ = new Milimoe.FunGame.Testing.Tests.ActivityExample();
//List<string> strings = FunGameSimulation.StartSimulationGame(true, false, true);
//strings.ForEach(Console.WriteLine);
List<string> strings = await FunGameSimulation.StartSimulationGame(true, false, true);
strings.ForEach(Console.WriteLine);
//Character testc = new CustomCharacter(1, "1");
//Console.WriteLine(testc.GetInfo());

View File

@ -11,9 +11,10 @@ namespace Milimoe.FunGame.Testing.Tests
public FunGameSimulation()
{
InitCharacter();
Task.Run(async () =>
{
bool printout = true;
List<string> strs = StartGame(printout);
List<string> strs = await StartGame(printout);
if (printout == false)
{
foreach (string str in strs)
@ -23,6 +24,7 @@ namespace Milimoe.FunGame.Testing.Tests
}
Console.ReadKey();
});
}
public static List<Character> Characters { get; } = [];
@ -34,7 +36,7 @@ namespace Milimoe.FunGame.Testing.Tests
public static bool PrintOut { get; set; } = false;
public static string Msg { get; set; } = "";
public static List<string> StartGame(bool printout, bool isWeb = false)
public static async Task<List<string>> StartGame(bool printout, bool isWeb = false)
{
PrintOut = printout;
IsWeb = isWeb;
@ -57,7 +59,7 @@ namespace Milimoe.FunGame.Testing.Tests
// M = 5, W = 0, P1 = 0, P3 = 2
// M = 5, W = 1, P1 = 0, P3 = 0
List<Character> list = new(Characters);
List<Character> list = [.. Characters];
if (list.Count > 11)
{
@ -327,9 +329,9 @@ namespace Milimoe.FunGame.Testing.Tests
foreach (Character c in characters.Where(c => c != winner && c.HP > 0))
{
WriteLine("[ " + winner + " ] 对 [ " + c + " ] 造成了 99999999999 点真实伤害。");
actionQueue.DeathCalculation(winner, c);
await actionQueue.DeathCalculationAsync(winner, c);
}
actionQueue.EndGameInfo(winner);
await actionQueue.EndGameInfo(winner);
result.Add(Msg);
break;
}
@ -343,7 +345,7 @@ namespace Milimoe.FunGame.Testing.Tests
WriteLine($"=== Round {i++} ===");
WriteLine("现在是 [ " + characterToAct + " ] 的回合!");
bool isGameEnd = actionQueue.ProcessTurn(characterToAct);
bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct);
if (isGameEnd)
{
result.Add(Msg);
@ -355,7 +357,7 @@ namespace Milimoe.FunGame.Testing.Tests
}
// 模拟时间流逝
double timeLapse = actionQueue.TimeLapse();
double timeLapse = await actionQueue.TimeLapse();
totalTime += timeLapse;
-= timeLapse;