82 lines
2.7 KiB
C#
82 lines
2.7 KiB
C#
|
||
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池 精品 只能有一个
|
||
|
||
//创建随机数生成器
|
||
private readonly Random random = new();
|
||
public ChouKa()
|
||
{
|
||
// 清除控制台屏幕
|
||
Console.Clear();
|
||
do
|
||
{
|
||
Console.WriteLine("请输入抽卡次数 1-10/0返回主页");
|
||
var input = Console.ReadLine(); // 这一行会读取用户的输入
|
||
if (int.TryParse(input, out int number))
|
||
{
|
||
if (number == 0)
|
||
{
|
||
break;
|
||
}
|
||
if (number > 0 && number < 11)
|
||
{
|
||
for (int i = 0; i < number; i++)
|
||
{
|
||
Start();
|
||
}
|
||
}
|
||
}
|
||
} while (true);
|
||
// Console.WriteLine("退出抽卡系统,请按任意键结束");
|
||
// 清除控制台屏幕
|
||
Console.Clear();
|
||
}
|
||
|
||
public void Start()
|
||
{
|
||
// 生成一个1到100之间的随机数
|
||
var randomNumber = 0;
|
||
do
|
||
{
|
||
randomNumber = random.Next(1, 101); // 生成1到100之间的随机数
|
||
// Console.WriteLine(randomNumber + " " + random.NextDouble());
|
||
// 如果生成的数大于70,则有一定概率重新生成
|
||
|
||
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)] + " ");//普通抽卡结果
|
||
}
|
||
else
|
||
{
|
||
int v = random.Next(0, 6);
|
||
// 判断是否歪
|
||
if (v < waisize)
|
||
{
|
||
int v1 = new Random().Next(0, waile.Length);
|
||
Console.Write(" 歪了:" + waile[v1] + " ");
|
||
waisize--;
|
||
}
|
||
else
|
||
{
|
||
Console.Write(" 精品:" + baozan + " ");
|
||
waisize = new Random().Next(0, 6);
|
||
baodinum = random.Next(80, 91);
|
||
currentsize = 0;
|
||
}
|
||
}
|
||
}
|
||
} |