ModelingDebug/Chouka.cs

105 lines
3.5 KiB
C#
Raw Permalink Normal View History

2024-08-25 09:55:05 +00:00

namespace Debug;
public class ChouKa
{
// 10 20 30 50 60 70 80 90
int currentsize = 0;
int baodinum = 70; //第一次保底80 往后就用随机数80 ~ 90
int waisize = 0; //歪的几率 第一次肯定不歪
string[] putong = ["1", "2", "3"];//普通物品
string[] waile = ["薄荷", "铁锈会员10天"];// 设置歪的物品
string baozan = "name";//设置本次UP池 精品 只能有一个
//普通物品抽中数量
int putongsize = 0;
//精品物品抽中数量
int baozansize = 0;
//歪物品抽中数量
int waisize_A = 0, waisize_B = 0;
2024-08-25 09:55:05 +00:00
//创建随机数生成器
private readonly Random random = new();
string message = $"普通抽卡概率:{70}%\n精品抽卡概率{30}%\n歪概率{10}%\n" +
"保底 80~90";
2024-08-25 09:55:05 +00:00
public ChouKa()
{
// 清除控制台屏幕
Program.IsWhile = true;
2024-08-25 09:55:05 +00:00
Console.Clear();
while (Program.IsWhile)
2024-08-25 09:55:05 +00:00
{
ModeSwitch.New("抽卡系统", ["返回首页", "普通抽卡*1", "普通抽卡*10"], (a) =>
2024-08-25 09:55:05 +00:00
{
switch (a)
2024-08-25 09:55:05 +00:00
{
case 0:
Program.IsWhile = false;
break;
case 1:
2024-08-25 09:55:05 +00:00
Start();
break;
case 2:
for (int i = 0; i < 10; i++)
{
Start();
}
break;
2024-08-25 09:55:05 +00:00
}
}, message + "\n" + "当前保底:" + baodinum + "\n当前歪概率" + waisize + "\n当前普通概率" + (100 - baodinum) +
$"\n普通物品{putongsize} 精品物品:{baozansize} 歪物品:薄荷{waisize_A} 铁锈会员10天{waisize_B}\n");
}
_ = new Program();
2024-08-25 09:55:05 +00:00
}
public void Start()
{
// 生成一个1到100之间的随机数
var randomNumber = 0;
do
{
randomNumber = random.Next(1, 101); // 生成1到100之间的随机数
// Console.WriteLine(randomNumber + " " + random.NextDouble());
// 如果生成的数大于70则有一定概率重新生成
2024-08-25 09:55:05 +00:00
if (randomNumber > baodinum && random.NextDouble() > currentsize / 100)
{
randomNumber = -1; // 使用-1作为标记表示需要重新生成
}
} while (randomNumber == -1); // 如果标记为-1则重新生成
currentsize++;
if (randomNumber < baodinum && currentsize < baodinum)
{
// Console.Write(" 普通:" + putong[new Random().Next(0, putong.Length)] + " ");//普通抽卡结果
putongsize++;
2024-08-25 09:55:05 +00:00
}
else
{
int v = random.Next(0, 6);
// 判断是否歪
if (v < waisize)
{
int v1 = new Random().Next(0, waile.Length);
// Console.Write(" 歪了:" + waile[v1] + " ");
if (v1 == 0)
{
waisize_A++;
}
else
{
waisize_B++;
}
2024-08-25 09:55:05 +00:00
waisize--;
}
else
{
// Console.Write(" 精品:" + baozan + " ");
baozansize++;
2024-08-25 09:55:05 +00:00
waisize = new Random().Next(0, 6);
baodinum = random.Next(80, 91);
currentsize = 0;
}
}
}
}