This commit is contained in:
tanglong 2025-10-14 21:01:49 +08:00
parent 2865ece26e
commit 24040bdc34
2 changed files with 32 additions and 0 deletions

View File

@ -9,6 +9,8 @@ namespace Dto
{ {
public class GroupJumpRopeContext public class GroupJumpRopeContext
{ {
// 静态字段,保存排名列表
public static List<RankItem> RankList { get; set; } = new List<RankItem>();
public List<(double XNorm, double YNorm)> CirclePositions { get; private set; } public List<(double XNorm, double YNorm)> CirclePositions { get; private set; }
public List<SportUserItem> UserList { get; private set; } public List<SportUserItem> UserList { get; private set; }
public List<string> UserNumberList { get; private set; } public List<string> UserNumberList { get; private set; }
@ -34,5 +36,33 @@ namespace Dto
Sports = new List<SportBase>(); Sports = new List<SportBase>();
} }
// 更新排行榜方法
public void UpdateRankList()
{
RankList = UserNumberList
.Select((numStr, index) => new
{
Index = index,
Name = UseNameList[index],
Number = int.TryParse(numStr, out var n) ? n : 0
})
.OrderByDescending(x => x.Number)
.Select((x, rank) => new RankItem
{
Rank = rank + 1,
Name = x.Name,
Number = x.Number
})
.ToList();
}
}
// 排名项
public class RankItem
{
public int Rank { get; set; }
public string Name { get; set; }
public int Number { get; set; }
} }
} }

View File

@ -263,6 +263,8 @@ namespace Wpf_AiSportsMicrospace.Views
x.ImageState = "1"; x.ImageState = "1";
}); });
_groupJumpRopeContext.UpdateRankList();
IsGameStarted = false; IsGameStarted = false;
Utils.StopBackgroundMusic(); Utils.StopBackgroundMusic();
} }