From c3a9437fc8fa8f668c2b111a96b1e0644f6c7aa4 Mon Sep 17 00:00:00 2001 From: lishuo Date: Thu, 1 Feb 2024 10:09:34 +0800 Subject: [PATCH] =?UTF-8?q?Random=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8F=AA?= =?UTF-8?q?=E5=8F=96=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hander/MapRecordRankingHander.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Hander/MapRecordRankingHander.cs b/Hander/MapRecordRankingHander.cs index 5eac80e..e744149 100644 --- a/Hander/MapRecordRankingHander.cs +++ b/Hander/MapRecordRankingHander.cs @@ -36,30 +36,31 @@ namespace OnlineUserPool.Hander UpdateVirtualTime = DateTime.Now; } } + + private Random rand = new Random(); //根据当前时段计算虚拟总人数 private int ComputeTop() { - var rand = new Random(); var hour = DateTime.Now.Hour;//当前点数 - int offset = 1;//少:1 中:3 多:10 + int top = 1;//少:1 中:3 多:10 if (hour <= 6) { - offset = rand.Next((int)(0.8 * START), (int)(1.2 * START)); + top = rand.Next((int)(0.8 * START), (int)(1.2 * START)); } if (hour > 6 && hour <= 18) { - offset = rand.Next((int)(0.8 * OFFSET), (int)(1.2 * MEDIUM)); + top = rand.Next((int)(0.8 * OFFSET), (int)(1.2 * MEDIUM)); } if (hour >= 18 && hour <= 22) { - offset = rand.Next((int)(0.8 * LARGE), (int)(1.2 * LARGE)); + top = rand.Next((int)(0.8 * LARGE), (int)(1.2 * LARGE)); } if (hour > 22 && hour <= 24) { - offset = rand.Next((int)(0.8 * SMALL), (int)(1.2 * SMALL)); + top = rand.Next((int)(0.8 * SMALL), (int)(1.2 * SMALL)); } - return offset; + return top; } ///