78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using Wpf_AiSportsMicrospace.MyUserControl;
|
|
using Yztob.AiSports.Postures.Sports;
|
|
|
|
namespace Dto
|
|
{
|
|
public class WhackAMoleContext
|
|
{
|
|
// 静态字段,保存排名列表
|
|
public static List<RankItem> RankList { get; set; } = new List<RankItem>();
|
|
public List<(double XNorm, double YNorm)> CirclePositions { get; set; } = new List<(double XNorm, double YNorm)>();
|
|
public List<WhackAMoleUserControl> UserList { get; private set; }
|
|
public List<string> UserNumberList { get; private set; }
|
|
public List<SportBase> Sports { get; private set; }
|
|
public List<string> UserNameList { get; private set; } = new()
|
|
{
|
|
"游客-A", "游客-B", "游客-C", "游客-D", "游客-E", "游客-F", "游客-G", "游客-H", "游客-I", "游客-F", "游客-J"
|
|
};
|
|
public WhackAMoleContext()
|
|
{
|
|
CirclePositions = new List<(double XNorm, double YNorm)>
|
|
{
|
|
(403.2, 950.4 ),
|
|
(691.2, 626.4 ),
|
|
(960, 950.4 ),
|
|
(1228.8, 626.4 ),
|
|
(1497.6, 950.4),
|
|
(1766.4, 626.4)
|
|
};
|
|
|
|
UserList = new List<WhackAMoleUserControl>();
|
|
UserNumberList = new List<string>();
|
|
Sports = new List<SportBase>();
|
|
|
|
}
|
|
|
|
// 更新地鼠排行榜方法
|
|
public List<RankItem> UpdateWhackAMoleRankList()
|
|
{
|
|
var rankList = UserNumberList
|
|
.Select((numStr, index) => new
|
|
{
|
|
Index = index,
|
|
Name = UserNameList[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();
|
|
|
|
RankList = rankList;
|
|
|
|
return rankList;
|
|
}
|
|
}
|
|
|
|
// 地鼠排名项
|
|
public class WhackAMoleRankItem
|
|
{
|
|
public int Rank { get; set; }
|
|
public string Name { get; set; }
|
|
public int Number { get; set; }
|
|
public double Score { get; set; }
|
|
}
|
|
}
|
|
|