UNO小游戏

前言

Hello大家好我是文宇.

这个代码没写完,才刚写完抽卡,还没写出卡和特殊效果

正文

上才艺

​
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
bool can = 1;
int colorsz1[25];
int cardsz1[25];
int colorsz2[25];
int cardsz2[25];
int onecard;
int onecolor;
int cardaa;
int coloraa;
int sj;
int j;
int sr;
string player1;
string player2;
void rule() {
	cout << "规则:\n";
	cout << "┌┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐\n";
	cout << "┆ 1.输入牌的位置出牌                         ┆\n";
	cout << "┆ 2.只可以出与当前桌面颜色或数字相同的卡牌   ┆\n";
	cout << "┆ 3.10号卡可以使你的下家增加2张牌            ┆\n";
	cout << "┆ 4.11号卡可以使你的下家无法出牌一回         ┆\n";
	cout << "┆ 5.12号卡可以转换当前颜色                   ┆\n";
	cout << "┆ 6.13号卡可以转换当前颜色,并让下家增加4张牌 ┆\n";
	cout << "┆ 7.其余1~9号卡没有特殊效果                  ┆\n";
	cout << "┆ 8.谁的牌先打完谁就赢了                     ┆\n";
	cout << "┆ 9.明牌打                                   ┆\n";
	cout << "┆ 10.手牌上限为25张                          ┆\n";
	cout << "┆ 11.当你的手牌为25张时你就输了              ┆\n";
	cout << "┆ 12.开局有6张牌                             ┆\n";
	cout << "┆ 13.牌显示为0为空位                         ┆\n";
	cout << "└┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┘\n";
	return;
}
void statr() {
	cout << "     --------欢迎来到uno游戏---------\n";
	rule();
	cout << "请输入玩家1的名字:";
	cin >> player1;
	cout << "\n请输入玩家2的名字:";
	cin >> player2;
	system("cls");
	cout << "游戏开始\n";
	cout << "洗牌ing\n";
	return;
}
void carda() {
	srand(time(0)*time(0));
	sj = rand() % 13 + 1;
	cardaa = sj;
	sj = rand() % 4 + 1;
	coloraa = sj;
	return;
}
void cards1() {
	for (int i = 0; i <= 6; i++) {
		srand(time(0)*time(0));
		sj = rand() % 13 + 1;
		cardsz1[i] = sj;
		sj = rand() % 4 + 1;
		if (sj == 1) {
			colorsz1[i] = 1;
		}
		if (sj == 2) {
			colorsz1[i] = 2;
		}
		if (sj == 3) {
			colorsz1[i] = 3;
		}
		if (sj == 4) {
			colorsz1[i] = 4;
		}
		_sleep(1000);
	}
	return;
}
void cards2() {
	for (int i = 0; i <= 6; i++) {
		srand(time(0)*time(0));
		sj = rand() % 13 + 1;
		cardsz2[i] = sj;
		sj = rand() % 4 + 1;
		if (sj == 1) {
			colorsz2[i] = 1;
		}
		if (sj == 2) {
			colorsz2[i] = 2;
		}
		if (sj == 3) {
			colorsz2[i] = 3;
		}
		if (sj == 4) {
			colorsz2[i] = 4;
		}
		_sleep(1000);
	}
	return;
}
bool allZero1() {
	int total = 0;
	for (int i = 0; i < 25; i++) {
		if (cardsz1[i] == 0) {
			total++;
		}
	}

	if (total == 25) {
		return true;
	}
	return false;
}
bool allZero2() {
	int total = 0;
	for (int i = 0; i < 25; i++) {
		if (cardsz2[i] == 0) {
			total++;
		}
	}
	if (total == 25) {
		return true;
	}
	return false;
}
void onecards() {
	srand(time(0)*time(0));
	sj = rand() % 13 + 1;
	onecard = sj;
	sj = rand() % 4 + 1;
	onecolor = sj;
	return;

}
void display() {
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	cout << "玩家1的手牌是:";
	for (int i = 1; i <= 25; i++) {
		if (colorsz1[i] == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); //red
		if (colorsz1[i] == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); //green
		if (colorsz1[i] == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE); //blue
		if (colorsz1[i] == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); //yellow
		cout << cardsz1[i] << ' ';
	}
	cout << "\n\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	cout << "玩家2的手牌是:";
	for (int i = 1; i <= 25; i++) {
		if (colorsz2[i] == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); //red
		if (colorsz2[i] == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); //green
		if (colorsz2[i] == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE); //blue
		if (colorsz2[i] == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); //yellow
		cout << cardsz2[i] << ' ';
	}
	cout << "\n\n";
	return;
}
int main() {
	statr();
	cards1();
	cards2();
	onecards();
	while (1) {
		display();
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		cout << "\n当前桌面上的牌为:";
		if (onecolor == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); //red
		if (onecolor == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); //green
		if (onecolor == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE); //blue
		if (onecolor == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); //yellow
		cout << onecard << "\n";
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    }
	return 0;
}

​

和作者的脑糊一样乱

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

文宇炽筱

有一个打赏就多写十篇文章

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值