From 24040bdc34db3bdee28da868a66458d9fa1620ec Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Tue, 14 Oct 2025 21:01:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/GroupJumpRopeContext.cs | 30 +++++++++++++++++++ .../Views/JumpRope/GroupJumpRope.xaml.cs | 2 ++ 2 files changed, 32 insertions(+) diff --git a/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs b/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs index 1f08581..3a6e077 100644 --- a/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs +++ b/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs @@ -9,6 +9,8 @@ namespace Dto { public class GroupJumpRopeContext { + // 静态字段,保存排名列表 + public static List RankList { get; set; } = new List(); public List<(double XNorm, double YNorm)> CirclePositions { get; private set; } public List UserList { get; private set; } public List UserNumberList { get; private set; } @@ -34,5 +36,33 @@ namespace Dto Sports = new List(); } + + // 更新排行榜方法 + 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; } } } diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs index 61790e2..707300b 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs @@ -263,6 +263,8 @@ namespace Wpf_AiSportsMicrospace.Views x.ImageState = "1"; }); + _groupJumpRopeContext.UpdateRankList(); + IsGameStarted = false; Utils.StopBackgroundMusic(); }