【游戏角色抽签】第五人格随机角色娱乐赛抽签系统

 根据赛事需要,被抽中但是没有使用的角色可以投回总池重新被抽中,增加一段代码即可解决。

if(Round<=Number_BO){
	//如果被抽中没被使用,则视为没被抽中,下一轮可以被抽中 
	for(i=0;i<5;i++){
		if(Character[Number_Chosen[0][i]].IsChosen==1&&Character[Number_Chosen[0][i]].IsUsed==0){
			Character[Number_Chosen[0][i].IsChosen=0;
		} 
	} 
}

 纯业余爱好,为了校内游戏社团的娱乐赛写的一款抽签器哈哈哈哈哈,大佬轻喷……

用到的技术都是比较基础的用法拼拼凑凑的,前端也是极简的风格。不过感觉这个框架应该够用,如果能帮到类似用途的朋友就行。

娱乐赛规则参考这个视频:

南大IDV随机角色BP规则介绍


不过这个程序已经迭代到第二个版本了,比起第一个版本,从代码来讲,用宏定义和结构体来写,增加可读性和修改参数的便利性;从功能来讲,在加赛期间不再显示全部被抽中的角色,而是只显示被使用过的角色,这一点和视频有所出入。

/* 
	Name: 第五人格随机角色抽取系统 
	Copyright: Fushu
	Author: Fushu
	Date: 27/01/24 12:12
	Description: 
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>

//窗口大小(行数45,每行字符数130),程序会在刷新页面同时维护,避免排版错误 
		#define Size_Window			"mode con cols=130 lines=45"	

//赛事信息 
		#define Text_Title			"**大学2024寒假娱乐赛 常规赛阶段"
		#define Coordinate_X_Title	5
		#define Coordinate_Y_Title	2
	//5代表深品色,可自行修改 
		#define Color_Title			5	
	//BO数,默认常规赛为3,决赛可修改为5 
		#define Number_BO			3
		#define Coordinate_Y_Round	5 

	//角色名称所占字节宽度 
		#define Lenth_Name	12
	//比赛求生者和监管者池人数及名单,名单用英文逗号','隔开和结尾
		#define Number_Survivor	41
		#define List_Survivor 	"医生,律师,“慈善家”,园丁,魔术师,冒险家,佣兵,空军,机械师,前锋,盲女,祭司,调香师,牛仔,舞女,先知,入殓师,勘探员,咒术师,野人,杂技演员,大副,调酒师,邮差,守墓人,“囚徒”,昆虫学者,画家,击球手,玩具商,病患,“心理学家”,“小女孩”,哭泣小丑,教授,古董商,作曲家,记者,飞行家,拉拉队员,幸运儿,"
		#define Number_Hunter	27
		#define List_Hunter 	"厂长,小丑,鹿头,“杰克”,蜘蛛,红蝶,黄衣之主,宿伞之魂,摄影师,疯眼,梦之女巫,爱哭鬼,孽蜥,红夫人,26号守卫,“使徒”,小提琴家,雕刻家,“博士”,破轮,渔女,蜡像师,“噩梦”,“记录员”,隐士,守夜人,歌剧演员,"

//排版信息 
	//队定角色栏坐标
		#define Coordinate_Y_Team		8
	//公选角色栏坐标
		#define Coordinate_Y_Public		15
	//状态栏坐标 
		#define Coordinate_Y_StatusBar	23
	//总池横坐标
		#define Coordinate_X_Pool		0
	//总池纵坐标
		#define Coordinate_Y_Pool		29
	//求生者总池每行个数
		#define Column_Pool_Survivor	6
	//监管者总池每行个数 
		#define Column_Pool_Hunter		4

	//背景 
		#define Color_Background		15
	//普通文本 
		#define Color_CommonText		0
	//状态栏文本 
		#define Color_StatusBarText		8
	//抽中公用求生者 
		#define Color_Chosen_Survivor	9
	//抽中公用监管者 
		#define Color_Chosen_Hunter		12
	//已分配给各队但未确定 
		#define	Color_Unsure		13
	//选定公用求生者 
		#define Color_Used_Survivor		9
	//选定公用监管者 
		#define Color_Used_Hunter		12
	//池中可选求生者  
		#define Color_Pool_Survivor		1
	//池中可选监管者 
		#define Color_Pool_Hunter		4
	//池中不可选角色 
		#define Color_Pool_Unselectable	7	
	
	//清空状态栏 
		#define StatusBarClear	TextPrintF("                                                                                     ", Coordinate_X_Title, Coordinate_Y_StatusBar, Color_Background, Color_Background)

//子函数列表 
	//准备工作 
	void WelcomeF();			//加载页 
	void Character_Register(); 	//游戏角色名单注册 
	void Initialize_Page();		//页面初始化 
	void ThanksF(); 			//结束页 
	//屏幕排版 
	void gotoXY(int x, int y); 
	void TextColorF(int color_text, int color_background); 
	void TextPrintF(char *text, int coordinate_x, int coordinate_y, int color_text, int color_background); 
	void PagePrintF(); 
	//随机功能 
	int ChooseF(int side);		//side: 1=求生者;2=监管者 

//全局参数声明 
	int IsGameGoOn=1;		//主循环开关 
	int Round=1; 			//游戏轮次 
	char VoidName[13]="  [      ]  ";
	struct  str_Character	//角色名单 
	{
		int type;					//类型: 0=未定义;1=求生者;2=监管者
		int IsChosen;				//是否被抽中过: 0=no;1=yes 
		int IsUsed;					//是否被使用过: 0=no;1=yes 
		char name[Lenth_Name+1];	//中文名称 
	} Character[90];
	
	char *StatusBar;			//状态栏 
	int Number_Chosen[3][5];	//[0赛事;1主场;2客场][0监管者;1~4求生者] 
	int seed;					//随机数种子 
	
//主函数 
int main(){

	int i, j, temp;
	
	WelcomeF();
	PagePrintF(); 
	system("pause");
	
	while(IsGameGoOn){
		if(Round==1)	//获取随机种子 
		{
			MessageBox(NULL, "请由主场队伍提供一串五位数种子,用于随机选取", "全局种子", MB_OK | MB_ICONASTERISK);
				StatusBar="请输入种子:_____ (五位数)";
				PagePrintF();
				
				gotoXY(Coordinate_X_Title + 12, Coordinate_Y_StatusBar);
				Sleep(100);
				gotoXY(Coordinate_X_Title + 12, Coordinate_Y_StatusBar);
				Sleep(100);
				gotoXY(Coordinate_X_Title + 12, Coordinate_Y_StatusBar);
				gotoXY(Coordinate_X_Title + 12, Coordinate_Y_StatusBar);
				scanf("%d", &seed);
				
				srand(time(NULL) + seed);
				srand(time(NULL) % rand() + seed); 
				Sleep(500);
		} 
		
		if(Round<=Number_BO)	//正赛期间抽取角色 
		{
			StatusBar="准备就绪,可以进行抽取。";
			PagePrintF();
			
			//赛事方抽取环节 
			MessageBox(NULL, "现在抽取第一位求生者", "赛事方抽取角色", MB_OK | MB_ICONASTERISK);
				temp=ChooseF(1);
				Number_Chosen[0][1]=temp;
				Character[temp].IsChosen=1;
				TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 1 * Lenth_Name, Coordinate_Y_Public + 2, Color_Chosen_Survivor, Color_Background);
				TextPrintF(Character[temp].name, Coordinate_X_Pool + (temp  -  1) % Column_Pool_Survivor * Lenth_Name, Coordinate_Y_Pool + (temp - 1)/Column_Pool_Survivor * 2, Color_Pool_Unselectable, Color_Background);
				//先临时覆写,完成后统一刷新页面 
				
			MessageBox(NULL, "现在抽取第二位求生者", "赛事方抽取公用角色", MB_OK | MB_ICONASTERISK);
				temp=ChooseF(1);
				Number_Chosen[0][2]=temp;
				Character[temp].IsChosen=1;
				TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 2 * Lenth_Name, Coordinate_Y_Public + 2, Color_Chosen_Survivor, Color_Background);
				TextPrintF(Character[temp].name, Coordinate_X_Pool + (temp - 1) % Column_Pool_Survivor * Lenth_Name, Coordinate_Y_Pool + (temp - 1)/Column_Pool_Survivor * 2, Color_Pool_Unselectable, Color_Background);
								
			MessageBox(NULL, "现在抽取第三位求生者", "赛事方抽取公用角色", MB_OK | MB_ICONASTERISK);
				temp=ChooseF(1);
				Number_Chosen[0][3]=temp;
				Character[temp].IsChosen=1;
				TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 3 * Lenth_Name, Coordinate_Y_Public + 2, Color_Chosen_Survivor, Color_Background);
				TextPrintF(Character[temp].name, Coordinate_X_Pool + (temp - 1) % Column_Pool_Survivor * Lenth_Name, Coordinate_Y_Pool + (temp - 1)/Column_Pool_Survivor * 2, Color_Pool_Unselectable, Color_Background);
								
			MessageBox(NULL, "现在抽取第四位求生者", "赛事方抽取公用角色", MB_OK | MB_ICONASTERISK);
				temp=ChooseF(1);
				Number_Chosen[0][4]=temp;
				Character[temp].IsChosen=1;
				TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 4 * Lenth_Name, Coordinate_Y_Public + 2, Color_Chosen_Survivor, Color_Background);
				TextPrintF(Character[temp].name, Coordinate_X_Pool + (temp - 1) % Column_Pool_Survivor * Lenth_Name, Coordinate_Y_Pool + (temp - 1)/Column_Pool_Survivor * 2, Color_Pool_Unselectable, Color_Background);
								
			MessageBox(NULL, "现在抽取监管者", "赛事方抽取公用角色", MB_OK | MB_ICONASTERISK);
				temp=ChooseF(2);
				Number_Chosen[0][0]=temp;
				Character[temp].IsChosen=1;
				TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2, Coordinate_Y_Public + 2, Color_Chosen_Hunter, Color_Background);
				TextPrintF(Character[temp].name, Coordinate_X_Pool + Column_Pool_Survivor * Lenth_Name + 10 + (temp - Number_Survivor - 1) % Column_Pool_Hunter * Lenth_Name, Coordinate_Y_Pool + (temp - Number_Survivor - 1)/Column_Pool_Hunter * 2, Color_Pool_Unselectable, Color_Background);
			
			//赛事方抽取结果转写到两队待定 
			for(i=0;i<5;i++){
				Number_Chosen[1][i]=Number_Chosen[2][i]=Number_Chosen[0][i]; 
			}
				
				StatusBar = "抽取完毕,进入重抽环节。";
				PagePrintF(); 
				system("pause");
			
			//两队重抽环节 
			if(MessageBox(NULL, "主场队伍是否重抽监管者?", "主场队伍重抽角色", MB_YESNO | MB_ICONQUESTION)==6){
				StatusBar = "主场队伍求生者阵容锁定,正在重抽监管者...";
				PagePrintF(); 
				
				MessageBox(NULL, "现在抽取监管者", "主场队伍重抽角色", MB_OK | MB_ICONASTERISK);
					temp=ChooseF(2);
					Number_Chosen[1][0]=temp;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2, Coordinate_Y_Team + 2, Color_Chosen_Hunter, Color_Background);
			} 
			else if(MessageBox(NULL, "主场队伍是否重抽求生者?", "主场队伍重抽角色", MB_YESNO | MB_ICONQUESTION)==6){
				StatusBar = "主场队伍监管者阵容锁定,正在重抽求生者...";
				PagePrintF(); 
				
				if(MessageBox(NULL, "是否重抽第一位求生者", "主场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[1][1]=temp;
					Character[temp].IsChosen=1;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 0 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
				if(MessageBox(NULL, "是否重抽第二位求生者", "主场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[1][2]=temp;
					Character[temp].IsChosen=1;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 1 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
				if(MessageBox(NULL, "是否重抽第三位求生者", "主场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[1][3]=temp;
					Character[temp].IsChosen=1;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 2 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
				if(MessageBox(NULL, "是否重抽第四位求生者", "主场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[1][4]=temp;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 3 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
			} 
			
			for(i=0;i<5;i++){
					Character[Number_Chosen[1][i]].IsChosen=0;	//让客场队伍有机会与主场队伍重抽的角色相同,但是不会重抽到公用角色 
					Character[Number_Chosen[0][i]].IsChosen=1;
				}
			StatusBar = "主场队伍阵容确定,客场队伍重抽。";
			PagePrintF();
			
			if(MessageBox(NULL, "客场队伍是否重抽监管者?", "客场队伍重抽角色", MB_YESNO | MB_ICONQUESTION)==6){
				StatusBar = "客场队伍求生者阵容锁定,正在重抽监管者...";
				PagePrintF(); 
				
				MessageBox(NULL, "现在抽取监管者", "客场队伍重抽角色", MB_OK | MB_ICONASTERISK);
					temp=ChooseF(2);
					Number_Chosen[2][0]=temp;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 5 * Lenth_Name, Coordinate_Y_Team + 2, Color_Chosen_Hunter, Color_Background);
			} 
			else if(MessageBox(NULL, "客场队伍是否重抽求生者?", "客场队伍重抽角色", MB_YESNO | MB_ICONQUESTION)==6){
				StatusBar = "主场队伍监管者阵容锁定,正在重抽求生者...";
				PagePrintF(); 
				
				if(MessageBox(NULL, "是否重抽第一位求生者", "客场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[2][1]=temp;
					Character[temp].IsChosen=1;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 5 * Lenth_Name + 0 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
				if(MessageBox(NULL, "是否重抽第二位求生者", "客场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[2][2]=temp;
					Character[temp].IsChosen=1;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 5 * Lenth_Name + 1 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
				if(MessageBox(NULL, "是否重抽第三位求生者", "客场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[2][3]=temp;
					Character[temp].IsChosen=1;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 5 * Lenth_Name + 2 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
				if(MessageBox(NULL, "是否重抽第四位求生者", "客场队伍重抽角色", MB_OKCANCEL | MB_ICONASTERISK)==1){
					temp=ChooseF(1);
					Number_Chosen[2][4]=temp;
					Character[temp].IsUsed=1; 
					TextPrintF(Character[temp].name, Coordinate_X_Title + Lenth_Name / 2 + 5 * Lenth_Name + 3 * Lenth_Name, Coordinate_Y_Team + 4, Color_Chosen_Survivor, Color_Background);
				} 
			} 
			
			//将两队最终选中的角色标记为“已用”“已选”,不可再被选中 
			for(i=1;i<3;i++){
				for(j=0;j<5;j++){
					Character[Number_Chosen[i][j]].IsChosen=1; 
					Character[Number_Chosen[i][j]].IsUsed=1; 
				} 
			} 
			StatusBar = "角色抽取完毕。客场队伍禁图、主场队伍选图、客场队伍选边,然后比赛开始。比赛完成后,"; 
			PagePrintF();
			system("pause");
		} 
		
		else	//加赛期间,只展示可选角色,不随机抽取 
		{
			StatusBar = "可选角色展示如下。请各队自行选角色,客场队伍禁图、主场队伍选图、客场队伍选边,然后比赛开始。比赛完成后";
			PagePrintF();
			system("pause");
		} 
		
		//询问是否进行下一场比赛,如果是加赛,则对进行处理数据 
		if(MessageBox(NULL, "是否进行下一局比赛?", "下一局比赛", MB_YESNO | MB_ICONQUESTION)==6){
			Round++;
			if(Round==Number_BO + 1){
				for(i=1;i<Number_Survivor + Number_Hunter + 1;i++){
					Character[i].IsChosen=1 - Character[i].IsUsed;
				} 
			} 
			Initialize_Page();
			PagePrintF();
		} 
		else	IsGameGoOn=0;
	} 
	ThanksF();
	return 0;
} 

//将角色名字符串赋值给结构体数组 
void Character_Register(){
	int i, j, temp=0; 
	char NameTemp[Lenth_Name+1];
	char SurvivorNameList[] = List_Survivor;
	char HunterNameList[] = List_Hunter;
	
	//0号默认为空角色 
	Character[0].type=0;
	for(i=0;i<Lenth_Name+1;i++){
		Character[0].name[i]=VoidName[i];
	}
	Character[0].IsChosen=0;
	Character[0].IsUsed=1;
	
	//登记求生者 
	for(i=1;i<Number_Survivor + 1;i++){
		Character[i].type=0;
		for(j=0; SurvivorNameList[temp]!=','; j++, temp++){NameTemp[j]=SurvivorNameList[temp];}
		NameTemp[j]='\0';
		//将角色名按照12字符的宽度居中处理,下同 
		for(j=0;j<6 - strlen(NameTemp) / 2;j++){
			Character[i].name[j]=' ';
		} 
		for(j=0;j<strlen(NameTemp);j++){
			Character[i].name[j + 6 - strlen(NameTemp) / 2]=NameTemp[j];
		} 
		for(j=0;j<6 - strlen(NameTemp) / 2;j++){
			Character[i].name[j + 6 + strlen(NameTemp) / 2]=' ';
		} 
		Character[i].name[Lenth_Name]='\0'; 
		temp++;
	} 
	
	temp=0;
	//登记监管者 
	for(i=Number_Survivor + 1;i<Number_Survivor + Number_Hunter + 1;i++){
		Character[i].type=0;
		for(j=0; HunterNameList[temp]!=','; j++, temp++){NameTemp[j]=HunterNameList[temp];}
		NameTemp[j]='\0';
		
		for(j=0;j<6 - strlen(NameTemp) / 2;j++){
			Character[i].name[j]=' ';
		} 
		for(j=0;j<strlen(NameTemp);j++){
			Character[i].name[j + 6 - strlen(NameTemp) / 2]=NameTemp[j];
		} 
		for(j=0;j<6 - strlen(NameTemp) / 2;j++){
			Character[i].name[j + 6 + strlen(NameTemp) / 2]=' ';
		} 
		Character[i].name[Lenth_Name+1]='\0'; 
		temp++;
	} 
	
	for(i=1;i<Number_Survivor + Number_Hunter;i++){
		Character[i].IsChosen=0;
		Character[i].IsUsed=0;
	} 
} 

//初始化页面数据 
void Initialize_Page(){
	int i, j;
	for(i=0;i<3;i++){
		for(j=0;j<5;j++){
			Number_Chosen[i][j]=0;
		} 
	} 
	StatusBar = "加载完毕,"; 
} 

//欢迎页 
void WelcomeF(){
	system(Size_Window);
	system("color 08");
	Sleep(300);
	
	TextPrintF("...第五人格随机角色抽取系统...", 48, 18, 8, 0);
	TextPrintF("by Fushu", 90, 30, 3, 0);
	TextPrintF(" ", 120, 42, 0, 0);
	Sleep(100);
	
	TextPrintF("...第五人格随机角色抽取系统...", 48, 18, 7, 0);
	TextPrintF(" ", 120, 42, 0, 0);
	Sleep(100);
	
	TextPrintF("...第五人格随机角色抽取系统...", 48, 18, 15, 0);
	TextPrintF(" ", 120, 42, 0, 0);
		
	Character_Register();
	Initialize_Page(); 
	Sleep(1000);
		
	TextPrintF("...第五人格随机角色抽取系统...", 48, 18, 7, 0);
	TextPrintF(" ", 120, 42, 0, 0);
	Sleep(100);
	
	TextPrintF("...第五人格随机角色抽取系统...", 48, 18, 8, 0);
	TextPrintF(" ", 120, 42, 0, 0);
	
	system("cls");
	system("color F5");
	Sleep(500);
} 

//结束页 
void ThanksF(){
	system(Size_Window);
	system("color 08");
	Sleep(500);
	TextPrintF("系统关闭,感谢您的使用喵~", 50, 20, 15, 0);
	Sleep(5000);
} 

//工作页面渲染 
void PagePrintF(){
	int i, j, temp;
	system(Size_Window); 
	system("cls");
	//显示赛事标题 
	TextPrintF(Text_Title, Coordinate_X_Title, Coordinate_Y_Title, Color_Title, Color_Background);
	//显示局次 
	switch(Round){
		case 1:	TextPrintF("※第一局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
		case 2:	if(Round<=Number_BO){
					TextPrintF("※第二局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
				} 
		case 3:	if(Round<=Number_BO){
					TextPrintF("※第三局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
				} 
		case 4:	if(Round<=Number_BO){
					TextPrintF("※第四局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
				} 
		case 5:	if(Round<=Number_BO){
					TextPrintF("※第五局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
				} 
		default:	switch(Round-Number_BO){
						case 1:		TextPrintF("※加一局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
						case 2:		TextPrintF("※加二局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
						case 3:		TextPrintF("※加三局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
						case 4:		TextPrintF("※加四局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
						case 5:		TextPrintF("※加五局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break;
						default:	TextPrintF("※加N局※", Coordinate_X_Title, Coordinate_Y_Round, Color_CommonText, Color_Background); break; 
					}
	} 
	//显示区域 
	TextPrintF("【主场队】选定角色", Coordinate_X_Title, Coordinate_Y_Team, Color_CommonText, Color_Background);
	TextPrintF("【客场队】选定角色", Coordinate_X_Title + 5 * Lenth_Name, Coordinate_Y_Team, Color_CommonText, Color_Background);
	TextPrintF("【赛事方】抽取公用角色", Coordinate_X_Title, Coordinate_Y_Public, Color_CommonText, Color_Background);
	//显示选定角色
	TextPrintF(Character[Number_Chosen[1][0]].name, Coordinate_X_Title + Lenth_Name / 2, Coordinate_Y_Team + 2, Character[Number_Chosen[1][0]].IsUsed ? Color_Used_Hunter: Color_Unsure, Color_Background);
	for(i=1;i<5;i++){
		TextPrintF(Character[Number_Chosen[1][i]].name, Coordinate_X_Title + Lenth_Name / 2 + (i - 1) * Lenth_Name, Coordinate_Y_Team + 4, Character[Number_Chosen[1][i]].IsUsed ? Color_Used_Survivor : Color_Unsure, Color_Background);
	} 
	TextPrintF(Character[Number_Chosen[2][0]].name, Coordinate_X_Title + Lenth_Name / 2 + 5 * Lenth_Name, Coordinate_Y_Team + 2, Character[Number_Chosen[2][0]].IsUsed ? Color_Used_Hunter : Color_Unsure, Color_Background);
	for(i=1;i<5;i++){
		TextPrintF(Character[Number_Chosen[2][i]].name, Coordinate_X_Title + Lenth_Name / 2 + 5 * Lenth_Name + (i - 1) * Lenth_Name, Coordinate_Y_Team + 4, Character[Number_Chosen[2][i]].IsUsed ? Color_Used_Survivor : Color_Unsure, Color_Background);
	} 
	TextPrintF(Character[Number_Chosen[0][0]].name, Coordinate_X_Title + Lenth_Name / 2, Coordinate_Y_Public + 2, Color_Chosen_Hunter, Color_Background);
	for(i=1;i<5;i++){
		TextPrintF(Character[Number_Chosen[0][i]].name, Coordinate_X_Title + Lenth_Name / 2 + i * Lenth_Name, Coordinate_Y_Public + 2, Color_Chosen_Survivor, Color_Background);
	} 
	
	//显示总池角色 
	for(i=1;i<Number_Survivor + 1;i++){
		TextPrintF(Character[i].name, Coordinate_X_Pool + (i - 1) % Column_Pool_Survivor * Lenth_Name, Coordinate_Y_Pool + (i - 1)/Column_Pool_Survivor * 2, Character[i].IsChosen ? Color_Pool_Unselectable : Color_Pool_Survivor, Color_Background);
	} 
	for(i=Number_Survivor + 1;i<Number_Survivor + Number_Hunter + 1;i++){
		TextPrintF(Character[i].name, Coordinate_X_Pool + Column_Pool_Survivor * Lenth_Name + 10 + (i - Number_Survivor - 1)  %  Column_Pool_Hunter * Lenth_Name, Coordinate_Y_Pool + (i - Number_Survivor - 1)/Column_Pool_Hunter * 2, Character[i].IsChosen ? Color_Pool_Unselectable : Color_Pool_Hunter, Color_Background);
	} 
	
	Sleep(20);
	StatusBarClear;
	TextPrintF(StatusBar, Coordinate_X_Title, Coordinate_Y_StatusBar, Color_StatusBarText, Color_Background);
} 

//从指定行列覆盖
void gotoXY(int x, int y) 
{
	COORD pos = {x, y} ;
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut, pos);
} 


//设置字体颜色 
void TextColorF(int color_text, int color_background)
{
    if(color_text>=0&&color_text<=15&&color_background>=0&&color_background<=15){
        //参数在0-15的范围颜色 
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_text + color_background * 0x10);
    } 
	else{
        //默认的字体颜色是黑色 
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 00);
    } 
} 

//集成式输入 
void TextPrintF(char *text, int coordinate_x, int coordinate_y, int color_text, int color_background){
	gotoXY(coordinate_x, coordinate_y);
	TextColorF(color_text, color_background);
	printf(text);
} 

//随机抽取号码 
int ChooseF(int side){
	int num=0, t;
	//抽取求生者 
	if(side==1){
		num = 1 + rand() % Number_Survivor;
		for(t=0; t<50 && Character[num].IsChosen; t++){
			num=1 + rand() % Number_Survivor;
		}
		while(t++<50 + Number_Survivor && Character[num].IsChosen){
			num = 1 + (num + 1) % Number_Survivor;
		}
	} 
	//抽取监管者 
	else{
		num = 1 + Number_Survivor + rand() % Number_Hunter;
		for(t=0; t<50 && Character[num].IsChosen; t++){
			num = 1 + Number_Survivor + rand() % Number_Hunter;
		}
		while(t++<50 + Number_Hunter && Character[num].IsChosen){
			num = 1 + Number_Survivor + (num + 1) % Number_Hunter;
		}
	}
	//若全部已抽,返回0号空角色 
	if(Character[num].IsChosen)	num=0;
	return num;
}

欢迎讨论,多谢担待🤝🤝🤝

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值