#include <bits/stdc++.h>
#include <windows.h>
#include <ctime>
using namespace std;
struct guest1 {
int x = 1, y = 1;
int skill = 0, skillB = 0, live = 3;
} guest1;
struct guest2 {
int x = 9, y = 19;
int skill = 0, skillB = 0, live = 3;
} guest2;
int hhh = 0;
int yyy = 0;
char mapn[21][21];
char aaa = 'f';
char bbb = 's';
int zs1 = 0;
int zs2 = 0;
void cls() {
system("cls");
mapn[guest1.x][guest1.y] = aaa;
mapn[guest2.x][guest2.y] = bbb;
cout << "guest1:";
int a = guest1.live, b = guest2.live;
for (int i = 1; i <= a; i++) {
cout << "O" << " ";
}
cout << " ";
cout << "guest2:";
for (int i = 1; i <= b; i++) {
cout << "O" << " ";
}
cout << endl;
cout << "guest1.A=" << guest1.skill;
cout << " guest1.B=" << guest1.skillB;
cout << endl;
cout << "guest2.A=" << guest2.skill;
cout << " guest2.B=" << guest2.skillB;
cout << endl;
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 20; j++) {
cout << mapn[i][j];
}
cout << endl;
}
}
void min() {
char m = 'f';
char minn[50][50] = {"####################",
"# # #",
"# # ##### #### ### #",
"# # # # # #",
"# ### ##### #### ###",
"# # ## # #",
"#### ## ### #",
"# ## ########## #",
"# ## #P#",
"####################"
};
system("cls");
int x = 1, y = 1;
while (x != 8 || y != 18) {
if(x==8&&y==1){
cout << "恭喜你找到了真正的终点";
Sleep(3000);
return;
}
minn[x][y] = m;
cout << "返回主页请按e" << endl;
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 20; j++) {
cout << minn[i][j];
}
cout << endl;
}
char n;
cin >> n;
if (n == 'a' && minn[x][y - 1] != '#') {
minn[x][y] = ' ';
y--;
} else if (n == 'd' && minn[x][y + 1] != '#') {
minn[x][y] = ' ';
y++;
} else if (n == 'w' && minn[x - 1][y] != '#') {
minn[x][y] = ' ';
x--;
} else if (n == 's' && minn[x + 1][y] != '#') {
minn[x][y] = ' ';
x++;
} else if (n == 'e') {
return;
} else {
cout << "输入不合法";
Sleep(3000);
}
system("cls");
}
cout << "你赢了,三秒后回到主页";
Sleep(3000);
return;
}
void guessnum() {
system("cls");
int x, v, t;
srand((unsigned)time(NULL));
x = rand() % 100 + 1;
cout << "你要猜的数字在1-100之间" << endl << "输入0返回主页";
cin >> v;
while (v != 0) {
if(v == 114514){
cout << "就告诉你答案吧";
cout << x;
Sleep(3000);
}
if (v > x)cout << "大了" << endl;
else if (v < x)cout << "小了" << endl;
else {
cout << "你赢了,3秒后返回主页";
Sleep(3000);
return;
}
cin >> v;
}
return;
}
void add() {
int x, y;
srand((unsigned)time(NULL));
x = rand() % 9 + 1;
y = rand() % 19 + 1;
mapn[x][y] = 'A';
}
void bdd() {
int x, y;
srand((unsigned)time(NULL));
x = rand() % 9 + 1;
y = rand() % 19 + 1;
mapn[x][y] = 'B';
}
void skills1() {
int a = guest1.x, b = guest1.y;
guest1.skill -= 1;
char ma[21][21];
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 20; j++) {
ma[i][j] = mapn[i][j];
}
}
for (int i = b - 1; i >= 1; i--) {
if (ma[a][i] != '#') {
if (ma[a][i] == bbb) {
guest2.live -= 1;
}
ma[a][i] = '-';
} else {
break;
}
}
for (int i = b + 1; i <= 19; i++) {
if (ma[a][i] != '#') {
if (ma[a][i] == bbb) {
guest2.live -= 1;
}
ma[a][i] = '-';
} else {
break;
}
}
for (int i = a - 1; i >= 1; i--) {
if (ma[i][b] != '#') {
if (ma[i][b] == bbb) {
guest2.live -= 1;
}
ma[i][b] = '-';
} else {
break;
}
}
for (int i = a + 1; i <= 10; i++) {
if (ma[i][b] != '#') {
if (ma[i][b] == bbb) {
guest2.live -= 1;
}
ma[i][b] = '-';
} else {
break;
}
}
system("cls");
cout << "guest1:";
int a1 = guest1.live, b1 = guest2.live;
for (int i = 1; i <= a1; i++) {
cout << "O" << " ";
}
cout << " ";
cout << "guest2:";
for (int i = 1; i <= b1; i++) {
cout << "O" << " ";
}
cout << endl;
cout << "guest1.A=" << guest1.skill;
cout << " guest1.B=" << guest1.skillB;
cout << endl;
cout << "guest2.A=" << guest2.skill;
cout << " guest2.B=" << guest2.skillB;
cout << endl;
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 20; j++) {
cout << ma[i][j];
}
cout << endl;
}
Sleep(5000);
cls();
}
void skills2() {
int a = guest2.x, b = guest2.y;
guest2.skill -= 1;
char ma[21][21];
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 20; j++) {
ma[i][j] = mapn[i][j];
}
}
for (int i = b - 1; i >= 1; i--) {
if (ma[a][i] != '#') {
if (ma[a][i] == aaa) {
guest1.live -= 1;
}
ma[a][i] = '-';
} else {
break;
}
}
for (int i = b + 1; i <= 19; i++) {
if (ma[a][i] != '#') {
if (ma[a][i] == aaa) {
guest1.live -= 1;
}
ma[a][i] = '-';
} else {
break;
}
}
for (int i = a - 1; i >= 1; i--) {
if (ma[i][b] != '#') {
if (ma[i][b] == aaa) {
guest1.live -= 1;
}
ma[i][b] = '-';
} else {
break;
}
}
for (int i = a + 1; i <= 10; i++) {
if (ma[i][b] != '#') {
if (ma[i][b] == aaa) {
guest1.live -= 1;
}
ma[i][b] = '-';
} else {
break;
}
}
system("cls");
cout << "guest1:";
int a1 = guest1.live, b1 = guest2.live;
for (int i = 1; i <= a1; i++) {
cout << "O" << " ";
}
cout << " ";
cout << "guest2:";
for (int i = 1; i <= b1; i++) {
cout << "O" << " ";
}
cout << endl;
cout << "guest1.A=" << guest1.skill;
cout << " guest1.B=" << guest1.skillB;
cout << endl;
cout << "guest2.A=" << guest2.skill;
cout << " guest2.B=" << guest2.skillB;
cout << endl;
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 20; j++) {
cout << ma[i][j];
}
cout << endl;
}
Sleep(5000);
cls();
}
void skillB1() {
guest1.skillB -= 1;
cout << "请输入你想传送的坐标";
int x, y;
cin >> x >> y;
if (x < 10 && y < 20) {
mapn[guest1.x][guest1.y] = ' ';
guest1.x = x;
guest1.y = y;
cls();
cout << "传送完毕";
} else {
cout << "输入无效,你白白浪费了一次机会";
Sleep(3000);
cls();
}
}
void skillB2() {
guest2.skillB -= 1;
cout << "请输入你想传送的坐标";
int x, y;
cin >> x >> y;
if (x < 10 && y < 20) {
mapn[guest2.x][guest2.y] = ' ';
guest2.x = x;
guest2.y = y;
cls();
cout << "传送完毕";
} else {
cout << "输入无效,你白白浪费了一次机会,轮到对手走";
Sleep(3000);
cls();
}
}
void pvpgames() {
int t = 1;
while (guest1.live > 0 && guest2.live > 0) {
int a = guest1.x, b = guest1.y, c = guest2.x, d = guest2.y;
char move;
cin >> move;
if (t % 2 == 1) {
if (move == 'a' && mapn[a][b - 1] != '#') {
mapn[a][b] = ' ';
guest1.y -= 1;
if (mapn[a][b - 1] == 'A') {
guest1.skill += 1;
} else if (mapn[a][b - 1] == 'B') {
guest1.skillB += 1;
}
} else if (move == 'd' && mapn[a][b + 1] != '#') {
mapn[a][b] = ' ';
guest1.y += 1;
if (mapn[a][b + 1] == 'A') {
guest1.skill += 1;
} else if (mapn[a][b + 1] == 'B') {
guest1.skillB += 1;
}
} else if (move == 's' && mapn[a + 1][b] != '#') {
mapn[a][b] = ' ';
guest1.x += 1;
if (mapn[a + 1][b] == 'A') {
guest1.skill += 1;
} else if (mapn[a + 1][b] == 'B') {
guest1.skillB += 1;
}
} else if (move == 'w' && mapn[a - 1][b] != '#') {
mapn[a][b] = ' ';
guest1.x -= 1;
if (mapn[a - 1][b] == 'A') {
guest1.skill += 1;
} else if (mapn[a - 1][b] == 'B') {
guest1.skillB += 1;
}
} else if (move == 'N' && zs1 < 2) {
if (zs1 == 0) {
cout << "恭喜解锁彩蛋,奖励你一滴血,不要再输N了哦";
Sleep(3000);
zs1++;
guest1.live += 1;
cls();
} else if (zs1 == 1) {
zs1++;
cout << "贪得无厌!扣你2滴血";
Sleep(3000);
guest1.live -= 2;
cls();
}
} else {
cout << "输入不合法,请重新输入";
continue;
}
t++;
cls();
if (guest1.skill > 0 || guest1.skillB > 0) {
if (hhh == 0) {
cout << "使用技能A请按1,使用技能B请按2,不使用请按0";
int button;
cin >> button;
if (button == 1 && guest1.skill > 0) {
skills1();
} else if (button == 2 && guest1.skillB > 0) {
skillB1();
} else if ((button == 1 && guest1.skill == 0) || (button == 2 && guest1.skillB == 0)) {
cout << "你并没有这个技能,由于你的行为,直接轮到对手走";
Sleep(3000);
continue;
}
if (button == 0) {
cout << endl << "接下来几次你想不使用技能?(输入数字)";
cin >> hhh;
}
} else {
hhh--;
}
}
} else if (t % 2 == 0) {
if (move == 'a' && mapn[c][d - 1] != '#') {
mapn[c][d] = ' ';
guest2.y -= 1;
if (mapn[c][d - 1] == 'A') {
guest2.skill += 1;
} else if (mapn[c][d - 1] == 'B') {
guest2.skillB += 1;
}
} else if (move == 'd' && mapn[c][d + 1] != '#') {
mapn[c][d] = ' ';
guest2.y += 1;
if (mapn[c][d + 1] == 'A') {
guest2.skill += 1;
} else if (mapn[c][d + 1] == 'B') {
guest2.skillB += 1;
}
} else if (move == 's' && mapn[c + 1][d] != '#') {
mapn[c][d] = ' ';
guest2.x += 1;
if (mapn[c + 1][d] == 'A') {
guest2.skill += 1;
} else if (mapn[c + 1][d] == 'B') {
guest2.skillB += 1;
}
} else if (move == 'w' && mapn[c - 1][d] != '#') {
mapn[c][d] = ' ';
guest2.x -= 1;
if (mapn[c - 1][d] == 'A') {
guest2.skill += 1;
} else if (mapn[c - 1][d] == 'B') {
guest2.skillB += 1;
}
} else if (move == 'N' && zs2 < 2) {
if (zs2 == 0) {
cout << "恭喜解锁彩蛋,奖励你一滴血,不要再输N了哦";
Sleep(3000);
zs2++;
guest2.live += 1;
cls();
} else if (zs2 == 1) {
zs2++;
cout << "贪得无厌!扣你2滴血";
Sleep(3000);
guest2.live -= 2;
cls();
}
} else {
cout << "输入不合法,请重新输入";
continue;
}
t++;
cls();
if (guest2.skill > 0 || guest2.skillB > 0) {
if (yyy == 0) {
cout << "使用技能A请按1,使用技能B请按2,不使用请按0";
int button;
cin >> button;
if (button == 1 && guest2.skill > 0) {
skills2();
} else if (button == 2 && guest2.skillB > 0) {
skillB2();
} else if ((button == 1 && guest2.skill == 0) || (button == 2 && guest2.skillB == 0)) {
cout << "你并没有这个技能,由于你的行为,直接轮到对手走";
Sleep(3000);
continue;
}
if (button == 0) {
cout << endl << "接下来几次你想不使用技能?(输入数字)";
cin >> yyy;
}
} else {
yyy--;
}
}
}
if (t % 10 == 0) {
add();
}
if (t % 16 == 0) {
bdd();
}
}
if (guest1.live == 0) {
cout << "guest2 win";
return;
} else {
cout << "guest1 win";
return;
}
}
void games() {
cls();
for (int i = 1; i <= 4; i++) {
int x, y;
cin >> x >> y;
if (x == 1 && y == 1) {
} else if (x == 9 && y == 19) {
} else {
mapn[x][y] = '#';
}
cls();
}
cout << "游戏正式开始";
Sleep(5000);
cls();
pvpgames();
}
void rule() {
system("cls");
cout << "开局每人布置两个障碍物,障碍物可以抵挡攻击,布置完毕后游戏正式开始,按wasd上下左右移动,随着时间的推移,场上出现越来越多的A和B,A是一种可以选择性攻击对手的技能,在本回合移动结束后可选择使用,使用后若对手与你站在同行或者同列,它扣一滴血,当一人三滴血扣完时,另一人胜利。使用B后你可以穿越到任意坐标点上,注意的是若穿越到A或B上,使用者将不会得到相应的技能且这个点上的A或B永久消失。";
cout << endl << "1.开始游戏" << endl << "2.回到主页";
int button;
cin >> button;
if (button == 1) {
games();
} else {
system("cls");
return;
}
}
void dtime() {
system("cls");
time_t now = time(0);
char* dt = ctime(&now);
cout << "当前时间是:" << dt << endl;
Sleep(5000);
return;
}
void coloregg() {
system("cls");
int x;
srand((unsigned)time(NULL));
x = rand() % 5 + 1;
if (x == 1) {
cout << "wasd都可以走那N呢?(5秒后返回)";
Sleep(5000);
system("cls");
}
if (x == 2) {
cout << "P是迷宫的假终点哦(5秒后返回)";
Sleep(5000);
system("cls");
}
if (x == 3) {
cout << "正常人谁会猜114514呢?(5秒后返回)";
Sleep(5000);
system("cls");
}
if (x == 4) {
cout << "下五子棋违规太多次啦!(5秒后返回)";
Sleep(5000);
system("cls");
}
if (x == 5) {
cout << "物理三原色相加的平方!(5秒后返回)";
Sleep(5000);
system("cls");
}
return;
}
void color() {
system("cls");
cout << "输入0 = 黑色",
cout << endl;
cout << "1 = 蓝色",
cout << endl;
cout << "2 = 绿色",
cout << endl;
cout << "3 = 浅绿色",
cout << endl;
cout << "4 = 红色",
cout << endl;
cout << "5 = 紫色",
cout << endl;
cout << "6 = 黄色",
cout << endl;
cout << "7 = 白色";
cout << endl;
cout << "8 = 灰色";
cout << endl;
cout << "9 = 淡蓝色";
cout << endl;
cout << "请输入对应的字符改变颜色";
int button;
cin >> button;
if (button == 0) {
system("color 0");
} else if (button == 1) {
system("color 1");
} else if (button == 2) {
system("color 2");
} else if (button == 3) {
system("color 3");
} else if (button == 4) {
system("color 4");
} else if (button == 5) {
system("color 5");
} else if (button == 6) {
system("color 6");
} else if (button == 7) {
system("color 8");
} else if (button == 8) {
system("color 8");
} else if (button == 9) {
system("color 9");
} else if (button == 49) {
cout << "这都被你发现了?三次方呢?";
Sleep(3000);
} else if (button == 343) {
cout << "666,奖励你";
Sleep(3000);
system("start cmd");
}
system("cls");
return;
}
void chess() {
int c = 0;
system("cls");
int t = 1;
char b[12][12];
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 10; j++) {
b[i][j] = ' ';
}
}
for (int i = 0; i <= 9; i++) {
b[i][0] = i + '0';
b[0][i] = i + '0';
}
cout << "输入10 10返回主页" << endl;
for (int i = 0; i <= 10; i++) {
for (int j = 0; j <= 10; j++) {
cout << b[i][j] << " ";
}
cout << endl;
}
while (1) {
if(c == 20){
cout << "想钻空子钻疯了吧?";
Sleep(3000);
}
int x, y;
cin >> x >> y;
if (x >= 1 && x <= 9 && y >= 1 && y <= 9 && b[x][y] == ' ') {
if (t == 1) {
t = 0;
b[x][y] = '1';
} else {
t = 1;
b[x][y] = '0';
}
} else if (x == 10 && y == 10) {
return;
} else {
cout << "输入不合法";
c++;
continue;
}
system("cls");
for (int i = 0; i <= 9; i++) {
for (int j = 0; j <= 9; j++) {
cout << b[i][j] << " ";
}
cout << endl;
}
}
}
int main() {
for (int i = 0; i <= 20; i++) {
mapn[i][0] = '#';
mapn[0][i] = '#';
mapn[i][20] = '#';
mapn[10][i] = '#';
}
int button = 0;
while (button != 2 && guest1.live != 0 && guest2.live != 0) {
system("cls");
cout << "1.介绍游戏规则" << endl << "2.开始游戏" << endl << "3.彩蛋(你猜猜这是什么)" << endl << "4.修改颜色" << endl << "5.玩迷宫" << endl << "6.猜数字" << endl << "7.查看当前时间" << endl << "8.下下五子棋" << endl << "(输入对应数字)";
cin >> button;
if (button == 1) {
rule();
} else if (button == 2) {
games();
} else if (button == 3) {
coloregg();
} else if (button == 4) {
color();
} else if (button == 5) {
min();
} else if (button == 6) {
guessnum();
} else if (button == 7) {
dtime();
} else if (button == 8) {
chess();
}
}
return 0;
}