优化抽卡系统逻辑,重构输入处理,清理无用代码并调整输出信息
This commit is contained in:
parent
76d31e8bf2
commit
a80a9280f1
68
Chouka.cs
68
Chouka.cs
|
@ -10,35 +10,47 @@ public class ChouKa
|
|||
string[] waile = ["薄荷", "铁锈会员10天"];// 设置歪的物品
|
||||
string baozan = "name";//设置本次UP池 精品 只能有一个
|
||||
|
||||
|
||||
//普通物品抽中数量
|
||||
int putongsize = 0;
|
||||
//精品物品抽中数量
|
||||
int baozansize = 0;
|
||||
//歪物品抽中数量
|
||||
int waisize_A = 0, waisize_B = 0;
|
||||
//创建随机数生成器
|
||||
private readonly Random random = new();
|
||||
string message = $"普通抽卡概率:{70}%\n精品抽卡概率:{30}%\n歪概率:{10}%\n" +
|
||||
|
||||
"保底 80~90";
|
||||
|
||||
public ChouKa()
|
||||
{
|
||||
// 清除控制台屏幕
|
||||
Program.IsWhile = true;
|
||||
Console.Clear();
|
||||
do
|
||||
while (Program.IsWhile)
|
||||
{
|
||||
Console.WriteLine("请输入抽卡次数 1-10/0返回主页");
|
||||
var input = Console.ReadLine(); // 这一行会读取用户的输入
|
||||
if (int.TryParse(input, out int number))
|
||||
ModeSwitch.New("抽卡系统", ["返回首页", "普通抽卡*1", "普通抽卡*10"], (a) =>
|
||||
{
|
||||
if (number == 0)
|
||||
switch (a)
|
||||
{
|
||||
_ = new Program();
|
||||
break;
|
||||
}
|
||||
if (number > 0 && number < 11)
|
||||
{
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
case 0:
|
||||
Program.IsWhile = false;
|
||||
break;
|
||||
case 1:
|
||||
Start();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
// Console.WriteLine("退出抽卡系统,请按任意键结束");
|
||||
// 清除控制台屏幕
|
||||
Console.Clear();
|
||||
}, message + "\n" + "当前保底:" + baodinum + "\n当前歪概率:" + waisize + "\n当前普通概率:" + (100 - baodinum) +
|
||||
$"\n普通物品:{putongsize} 精品物品:{baozansize} 歪物品:薄荷{waisize_A} 铁锈会员10天{waisize_B}\n");
|
||||
}
|
||||
_ = new Program();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
|
@ -48,8 +60,8 @@ public class ChouKa
|
|||
do
|
||||
{
|
||||
randomNumber = random.Next(1, 101); // 生成1到100之间的随机数
|
||||
// Console.WriteLine(randomNumber + " " + random.NextDouble());
|
||||
// 如果生成的数大于70,则有一定概率重新生成
|
||||
// Console.WriteLine(randomNumber + " " + random.NextDouble());
|
||||
// 如果生成的数大于70,则有一定概率重新生成
|
||||
|
||||
if (randomNumber > baodinum && random.NextDouble() > currentsize / 100)
|
||||
{
|
||||
|
@ -59,7 +71,8 @@ public class ChouKa
|
|||
currentsize++;
|
||||
if (randomNumber < baodinum && currentsize < baodinum)
|
||||
{
|
||||
Console.Write(" 普通:" + putong[new Random().Next(0, putong.Length)] + " ");//普通抽卡结果
|
||||
// Console.Write(" 普通:" + putong[new Random().Next(0, putong.Length)] + " ");//普通抽卡结果
|
||||
putongsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -68,12 +81,21 @@ public class ChouKa
|
|||
if (v < waisize)
|
||||
{
|
||||
int v1 = new Random().Next(0, waile.Length);
|
||||
Console.Write(" 歪了:" + waile[v1] + " ");
|
||||
// Console.Write(" 歪了:" + waile[v1] + " ");
|
||||
if (v1 == 0)
|
||||
{
|
||||
waisize_A++;
|
||||
}
|
||||
else
|
||||
{
|
||||
waisize_B++;
|
||||
}
|
||||
waisize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write(" 精品:" + baozan + " ");
|
||||
// Console.Write(" 精品:" + baozan + " ");
|
||||
baozansize++;
|
||||
waisize = new Random().Next(0, 6);
|
||||
baodinum = random.Next(80, 91);
|
||||
currentsize = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user