C/C++教程

c++实现明日方舟抽卡系统(包含保底,统计以及血统鉴定)

本文主要是介绍c++实现明日方舟抽卡系统(包含保底,统计以及血统鉴定),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

        明日方舟的抽奖系统的c++实现,一开始想的随机数实现,就是每一段数的范围代表不同的星级,其中概率分为40%,50%,8%,2%,首先随机数如下,取0~999

  a=rank()%1000;  

        随后就是十抽保底机制了,对于这种,鄙人是先bool一个变量看前十抽保底是否生效,如果生效了那就 返回1,抽到六星,五星均返回值1。

       一旦抽卡次数达到了10,且还未有六星,五星出现,那么在四星,三星的判断下,加以个返回五星的语句,据如同这样。

else if(a>99+o&&a<600+o)  //这是四星判断的地方。
				{
					
					if(ten==9&&shichou==0)  //这里是判断是否到十抽且前是否有六星或者五星
					{
						k++;     //这里是统计五星个数。
						shichou=1;//保底生效
						wu(0);	//进入五星抽奖
						wushi++;//五十抽保底机制,如果没有六星就自增。
					}
					else  //前面的条件未成立
					{
					si(0);  //进入四星抽奖
					r++;  //统计四星
					wushi++;  //五十抽保底机制
					ten++;      //十抽保底机制
					}

        这样十抽保底就实现了,后面则是五十抽开始的保底机制。五十抽以后未抽到6星则概率增加,所以鄙人定义了一个变量,让它记录6星保底是否生效,如果生效,那它就变化。

        代码如下:

if(a>=0&&a<(20+o))  //这里是判断是否6星
				{
					liu(0);  //进入六星抽奖
					j++;  //六星统计
					if(shichou==0)shichou=1;   //前十抽保底机制,有了六星就失效了。
					wushi=0;  //五十抽保底归O
					o=0;   //五十抽保底增加概率归O
				}

      当未抽到六星时候,且五十抽保底(变量wushi>50)则下面公式:

if(wushi>50)o=(wushi-50)*20;

      使五十抽保底开始。 

      这样到了九十九抽未有6星(黑到极致),一定百抽到达你身边(这样好像也是反向百抽的欧皇呢)。

      而通过随机数,也可以实现一些干员UP的环境。这里就不多阐述了。

      直接上所有代码!

#include<bits/stdc++.h>
using namespace std;

int ten;
int wushi;
int o;
int a,j,k,r,h,huan,n;
bool shichou;
void san(int x)
{
	x=rand()%16;  //三星干员
	string l[16]={"芬","香草","翎羽","玫兰莎","卡缇","米格鲁","克洛斯","炎熔","芙蓉","安塞尔","史都华德","梓兰","空爆",
	"月见夜","斑点","泡普卡"};
	if(huan==0){
	cout<<l[x];
	printf("[★★★]");
	huan++;
	}
	else if(huan==4)
	{
	cout<<' '<<l[x];
	printf("[★★★]\n");
	huan=0;
	}
	else 
	{
	cout<<' '<<l[x];
	printf("[★★★]");
	huan++;
	}
	 return; 
}
void si(int x)
{
	x=rand()%41;  //四星干员
	string l[41]={"夜烟","远山","杰西卡","流星","白雪","清道夫","红豆","杜宾","缠丸","霜叶","慕斯","砾","暗索","末药",
	"调香师","角峰","蛇尾箱","古米","深海色","地灵","阿消","猎蜂","格雷伊","苏苏洛","桃金娘","红云","梅","安比尔",
	"宴","刻刀","波登可","卡达","孑","酸糖","芳汀","泡泡","杰克","松果","豆苗","深靛","罗比菈塔"}; 
	if(huan==0){
	cout<<l[x];
	printf("[★★★★]");
	huan++;
	}
	else if(huan==4)
	{
	cout<<' '<<l[x];
	printf("[★★★★]\n");
	huan=0;
	}
	else 
	{
	cout<<' '<<l[x];
	printf("[★★★★]");
	huan++;
	}
	return; 
}
void wu(int x)
{
	x=rand()%60;  //五星干员
string l[60]={"白面鸮","凛冬","德克萨斯","芙兰卡","拉普兰德","幽灵鲨","蓝毒","白金","陨星","天火","梅尔","赫默",
"华法琳","临光","红","雷蛇","可颂","普罗旺斯","守林人","崖心","初雪","真理","空","狮蝎","食铁兽","夜魔","诗怀雅",
"格劳克斯","星极","送葬人","槐琥","苇草","布洛卡","灰喉","吽","惊蛰","摄砂","巫恋","极境","石棉","月禾","莱因哈特",
"断崖","蜜蜡","贾维","安哲拉","燧石","四月","奥斯塔","絮雨","卡夫卡","爱丽丝","乌有","熔泉","赤东","绮良","羽毛笔",
"桑葚","灰毫","浊清"};
if(huan==0){
	cout<<l[x];
	printf("[★★★★★]");
	huan++;
	}
	else if(huan==4)
	{
	cout<<' '<<l[x];
	printf("[★★★★★]\n");
	huan=0;
	}
	else 
	{cout<<' '<<l[x];
	printf("[★★★★★]");
	huan++;
	}
	return; 
}
void liu(int x)
{
	x=rand()%38; //六星干员
	string l[38]={"能天使","推进之王","伊芙利特","艾雅法拉","安洁莉娜","闪灵","夜莺","星熊","塞雷娅","银灰",
	"斯卡蒂","陈","黑","赫拉格","麦哲伦","莫斯提马","煌","阿","刻俄柏","风笛","傀影","温蒂","早露","玲兰",
	"棘刺","森蚺","史尔特尔","瑕光","泥岩","山","空弦","嵯峨","凯尔希","帕拉斯","水月","琴柳","远牙","焰尾"};
	if(huan==0){
    cout<<l[x];
	printf("[★★★★★★]");
	huan++;
	}
	else if(huan==4)
	{
	cout<<' '<<l[x];
	printf("[★★★★★★]\n");
	huan=0;
	}
	else 
	{
	cout<<' '<<l[x];
	printf("[★★★★★★]");
	huan++;
	}
	return; 
}
void choujiang(int  x)
{
	double dd;
	dd=double(j)*4+double(k);
	dd/=n;   
	printf("欧皇鉴定啦~~~~~~\n经过检验,你是");  //随便搞得-v-
	if(dd>=0.4)
	{
		cout<<"超级欧皇!! 可恶啊,我好羡慕!!!,你已经超越了人类了(不做人了)\n"; 
	 } 
	 else if(dd>=0.3&&dd<0.4)
	 {
	 	cout<<"欧皇! 真牛逼,你已经超过了绝大多数人,真贵族血脉!\n"; 
	  } 
	  else if(dd>=0.2&&dd<0.3)
	  {
	  	cout<<"欧洲人! 你还挺幸运的,慕了。\n";
	   } 
	   else if(dd>=0.09&&dd<0.2)
	   {
	   	cout<<"亚洲人, 我们都是黄皮肤。\n";
	   }
	   else if(dd>0.07&&dd<0.09) 
	   {
	   	cout<<"非洲人 ,诶呀,没事的,氪就解决了"; 
	   }
	   else
	   {
	   	cout<<"非酋!!!哈哈哈哈哈哈哈,回家吧酋长!\n";
	   }
	 return; 
}
int main()
{
	printf("这里是简简单单的明日方舟抽奖系统,有保底机制。\n"
	"请输入你想抽奖的次数(输入0结束)\n");
	while(scanf("%d",&n)!=EOF)
	{
		//string str="weeee";
	//	cout<<str.substr();
	shichou=0;
	ten=0,wushi=0; 
		j=0,k=0,r=0,huan=0,h=0;
		if(n==0)break;
		else if(n<0){
			printf("请输入正确的数字:\n");
			continue; 
	    }
        else
		{
			for(int i=0;i<n;i++)
			{
				a=rand()%1000;
				if(a>=0&&a<(20+o))
				{
					liu(0);
					j++;
					if(shichou==0)shichou=1;
					wushi=0;
					o=0;
				}
				else if(a>19+o&&a<100+o)
				{
					wu(0);
					k++;
					if(shichou==0)shichou=1;
					wushi++;
				}
				else if(a>99+o&&a<600+o)
				{
					
					if(ten==9&&shichou==0)
					{
						k++;
						shichou=1;
						wu(0);	
						wushi++;
					}
					else
					{
					si(0);
					r++;
					wushi++;
					ten++;
					}
				}
				else
				{
					if(ten==9&&shichou==0)
					{
						shichou=1;
						wu(0);
						k++;
						wushi++;
					}
					else
					{
					san(0);
					h++;
					wushi++;
					ten++;
					}	
				}
				if(wushi>50)o=(wushi-50)*20;
			}
			}	
			cout<<endl;
			cout<<"总计:"<<endl;
			printf("六星总数目:%d  五星总数目:%d  四星总数目:%d  三星总数目:%d。\n",j,k,r,h); 
			n*=10;
		    printf("消耗合成玉:%d,折合源石: %.2lf\n\n",n*60,double(n)/3);
		    n/=10;
		    if(n<10)
		    {
		    	printf("\n因为次数不足,所以无法做欧皇鉴定\n是否继续?如继续,请输入次数,反之输入0\n\n"); 
			}
			else
			{
				choujiang(n); 
				printf("\n是否继续?如继续,请输入次数,反之输入0\n\n");
			 } 
 } 
 return 0;
}

挺简单的,如果有优化务必评论,我还在学习,我要学习!!

这篇关于c++实现明日方舟抽卡系统(包含保底,统计以及血统鉴定)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!