前言
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;
}
和作者的脑糊一样乱