修复赛马BUG,添加共斗

This commit is contained in:
milimoe 2025-08-01 01:35:22 +08:00
parent 4cfc56df38
commit 6299259b96
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0

View File

@ -10,19 +10,32 @@ namespace Milimoe.FunGame.Testing.Tests
public static void HorseTest1() public static void HorseTest1()
{ {
List<string> msgs = []; List<string> msgs = [];
Room room = Factory.GetRoom(1, "1", gameMap: "1");
room.Name = "赛马房间";
Dictionary<User, int> points = [];
for (int i = 0; i < 9; i++)
{
User user = Factory.GetUser();
user.Id = i;
user.Username = FunGameService.GenerateRandomChineseUserName();
room.UserAndIsReady.Add(user, true);
points[user] = 0;
if (i == 0) room.RoomMaster = user;
}
int plays = 0;
while (true) while (true)
{ {
Room room = Factory.GetRoom(1, "1", gameMap: "1"); plays++;
room.Name = "赛马房间"; Dictionary<long, int> racingPoints = HorseRacing.RunHorseRacing(msgs, room);
for (int i = 0; i < 5; i++) foreach (long userId in racingPoints.Keys)
{ {
User user = Factory.GetUser(); if (points.Keys.FirstOrDefault(u => u.Id == userId) is User user)
user.Username = FunGameService.GenerateRandomChineseUserName(); {
room.UserAndIsReady.Add(user, true); points[user] += racingPoints[userId];
if (i == 0) room.RoomMaster = user; }
} }
HorseRacing.RunHorseRacing(msgs, room);
Console.WriteLine(string.Join("\r\n", msgs)); Console.WriteLine(string.Join("\r\n", msgs));
Console.WriteLine($"\r\n====赛马积分排行榜====\r\n比赛场次{plays} 场\r\n" + string.Join("\r\n", points.OrderByDescending(kv => kv.Value).Select((kv, index) => (index + 1) + ". " + kv.Key + "" + kv.Value + " 分")));
if (Console.ReadKey().Key == ConsoleKey.Escape) if (Console.ReadKey().Key == ConsoleKey.Escape)
{ {
break; break;