1.贪吃蛇
点击查看代码
#include <iostream>
#include <list>
#include <cstdio>
#include <string>
#include <vector>
#include <ctime>
#include <algorithm>
#include <conio.h>
#include <windows.h>
using namespace std;
class Node {
public:
int x, y;
Node(int x1, int y1);
};
class UserData {
public:
string name;
long long score;
int gt;
int gr;
UserData(string s, long long sc,int gametime,int grade);
friend bool operator < (UserData a, UserData b);
};
#define RIGHT 0x4d
#define LEFT 0x4b
#define UP 0x48
#define DOWN 0x50
#define YELLOW FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define CYAN FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define ORANGE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define PURPLE FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define RED FOREGROUND_RED | FOREGROUND_INTENSITY
const int STARTX = 8;
const int STARTY = 4;
const int RANGEX = 60;
const int RANGEY = 20;
int point=10;
const int ENDX = STARTX + RANGEX;
const int ENDY = STARTY + RANGEY;
bool isSnake[RANGEY + 10 ][RANGEX + 10];
int speed;
int sysj;
int gametime;
list<Node> snake;
int curDiraction; //蛇的当前前进方向, 1上, 2下, 3左, 4右
int score; //当前分数
int grade;
int snakeLen; //蛇的长度
int foodx, foody; //食物坐标
int gox, goy; //蛇头坐标
int mj;
void GoTo(short x, short y); //定位光标
void DrawBoard(); //绘制边框
void ShowInformation(); //展示游戏信息
void Init(); //初始化游戏
void RunSnake(int x, int y); //绘制蛇身
void Try(int& x, int& y); //试走
bool IsGoodCoord(int x, int y); //前进坐标是否合法
void AddFood();
void EartFood();
void InitSnake();
bool EndGame();
bool StartGame();
bool GameMenu(); //游戏菜单
void ShowRanking(); //排行榜
void ShowAbout(); //相关信息
void InputData(); //输入玩家名字
int main() {
while (true) {
if (!GameMenu()) return 0;
}
return 0;
}
Node::Node(int x1, int y1) { //构造Node对象
x = x1; y = y1;
}
int SuiJi()
{
srand((unsigned)time(NULL));
return (rand()*rand()+rand()*rand())%14;
}
bool operator < (UserData a, UserData b) { //重载运算符,按分数由大到小排列
if(a.score != b.score)
return a.score > b.score;
if(a.gt !=b.gt)
return a.gt > b.gt;
else
return a.gr > b.gr;
}
UserData::UserData(string s, long long sc,int gametime_,int _grade) { //构造UserData对象
name = s; score = sc; gt=gametime_; gr=_grade;
}
void color(WORD A)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), A);
}
void Color(int a)
{
switch (a%4)
{
case 0:color(RED);break;
case 1:color(CYAN);break;
case 2:color(YELLOW);break;
case 3:color(PURPLE);break;
}
}
void GoTo(short x, short y) { //定位光标
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void ShowInformation() { //输出游戏信息
color(YELLOW);
GoTo(78, 5);
printf("贪吃蛇游戏");
GoTo(78,18);
gametime=(clock()-mj)/1000;
grade=snakeLen-3;
printf("生存时间:%3d 秒",(clock()-mj)/1000);
GoTo(78, 8);
printf("游戏规则:");
GoTo(78, 10);
printf("请按 ↑ ↓ ← → 来控制您的蛇吃东西");
GoTo(78, 12);
printf("吃的越多,蛇就越长,您的等级也将越高");
GoTo(78, 14);
printf("当蛇吃到自己或撞上墙时,游戏结束。");
GoTo(78,16);
printf("自动前进时间:%3dms",speed);
GoTo(78, 20);
printf("当前等级: %8d", snakeLen-3);
GoTo(78, 23);
printf("您的分数: %d", score);
color(CYAN);
printf("+%d=%d",score/3,score*3/2);
color(YELLOW);
GoTo(78,25);
printf("剩余时间:%d秒",20+(snakeLen-3)*5-gametime);
sysj=20+(snakeLen-3)*5-gametime;
}
void DrawBoard() { //绘制墙体
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); //获得输出句柄
CONSOLE_CURSOR_INFO cursor_info = { 1, 0 }; //光标信息
SetConsoleCursorInfo(hOut, &cursor_info); //隐藏光标
COORD size = { 120, 30 };
SetConsoleScreenBufferSize(hOut, size); //重设缓冲区大小
SMALL_RECT rc = { 0 , 0, 120, 30 };
SetConsoleWindowInfo(hOut, true, &rc); //重设窗口大小
SetConsoleTextAttribute(hOut, CYAN);
for (int i = STARTX - 2; i <= ENDX + 2; i += 2) { //横向墙体
GoTo(i, STARTY - 1);
printf("■");
GoTo(i, ENDY + 1);
printf("■");
}
for (int i = STARTY - 1; i <= ENDY + 1; ++i) { //竖向墙体
GoTo(STARTX - 2, i);
printf("■");
GoTo(ENDX + 2, i);
printf("■");
}
}
void draw()
{
char m=snakeLen+62;
Color(score);
cout<<m;
}
void Init() { //初始化游戏
system("cls");
memset(isSnake, 0, sizeof(isSnake));
speed = 200;
curDiraction = 4;
score = 0;
DrawBoard();
InitSnake();
ShowInformation();
AddFood();
mj=clock();
point=20;
sysj=20;
}
void RunSnake(int x, int y) { //绘制蛇身
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
score += snakeLen + 1;
if (x == foodx && y == foody) {
EartFood();
AddFood();
return;
}
DrawBoard();
snake.push_front(Node(x, y));
isSnake[y][x] = true;
GoTo(x, y);
draw();
Node back = snake.back();
snake.pop_back();
isSnake[back.y][back.x] = false;
GoTo(back.x, back.y);
printf(" ");
}
void Try(int& x, int& y) { //试走
int key, cnt = 100;
while (cnt--) { //多次检测键盘状态
if (_kbhit()) {
key = getch();
switch (key) {
case UP:
// if (curDiraction == 1 || curDiraction == 2) break;
--y; curDiraction = 1; return;
case DOWN:
// if (curDiraction == 1 || curDiraction == 2) break;
++y; curDiraction = 2; return;
case LEFT:
// if (curDiraction == 3 || curDiraction == 4) break;
x -= 2; curDiraction = 3; return;
case RIGHT:
// if (curDiraction == 3 || curDiraction == 4) break;
x += 2; curDiraction = 4; return;
}
}
}
if (curDiraction == 1) --y; //用户没有输入时
else if (curDiraction == 2) ++y;
else if (curDiraction == 3) x -= 2;
else x += 2;
}
bool IsGoodCoord(int x, int y) { //判断光标是否合法
if (x <= ENDX && y <= ENDY && x >= STARTX && y >= STARTY)
return true;
else
return false;
}
void AddFood() { //增加食物
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), PURPLE);
srand((unsigned)time(NULL));
while (true) {
foodx = (rand()%ENDX) + 1;
foody = (rand()%ENDY) + 1;
if (foodx&1) foodx++;
if (!isSnake[foody][foodx] && IsGoodCoord(foodx, foody)) break;
}
GoTo(foodx, foody);
int a=rand()%5;
if(a>=4)
printf("@");
else if(a<=1)
printf("#");
else
printf("&");
}
void EartFood() { //吃东西
point+=4;
int sb=gametime=(clock()-mj)/1000;
sysj=point-sb;
score+=score/2;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
snake.push_front(Node(foodx, foody));
isSnake[foody][foodx] = true;
++snakeLen;
if (speed >= 55) speed -= 5;
GoTo(foodx, foody);
draw();
AddFood();
}
void InitSnake() { //初始化蛇身
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
snakeLen = 3, gox = 18, goy = 14;
snake.clear();
snake.push_front(Node(12, 14));
snake.push_front(Node(14, 14));
snake.push_front(Node(16, 14));
for (int i = 12; i <= 16; i += 2) {
GoTo(i, 14);
draw();
isSnake[14][i] = true;
}
}
bool EndGame() { //结束游戏
system("cls");
DrawBoard();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
GoTo(28, 10);
printf("您的本局游戏得分: %d分", score);
GoTo(32, 18);
printf("....你挂了....");
GoTo(27, 20);
printf("是否继续游戏: 是(1), 否(0)");
GoTo(27, 22);
char key = getch();
while (true) {
if (key == '1') return false;
else if (key == '0')
{GoTo(ENDX+1,ENDY+2);
exit(0);return true;
}
else key = getch();
}
}
bool StartGame() { //启动游戏
Init();
while (sysj>0) { //开挂
RunSnake(gox, goy);
ShowInformation();
Try(gox, goy);
Sleep(speed);
}
InputData();
return true;
}
bool GameMenu() { //游戏菜单
system("cls");
DrawBoard();
GoTo(STARTX + 22, STARTY + 4);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
printf("欢迎进入贪吃蛇游戏!");
GoTo(STARTX + 24, STARTY + 10);
printf("1: 新游戏");
GoTo(STARTX + 24, STARTY + 12);
printf("2: 排行榜");
GoTo(STARTX + 24, STARTY + 14);
printf("3: 关于游戏");
GoTo(STARTX + 24, STARTY + 16);
printf("4: 退出游戏");
while (true) {
if (_kbhit()) {
char key = getch();
switch (key) {
case '1':
if (!StartGame()) return false;
else return true;
case '2':
ShowRanking(); return true;
case '3':
ShowAbout(); return true;
case '4':
GoTo(1,ENDY+2);
return false;
default:
return true;
}
}
}
}
void ShowRanking() { //展示排行榜
vector<UserData> vu;
FILE *fp = fopen("Gamedata2.txt", "r");
if (fp == NULL) fp = fopen("Gamedata2.txt", "w+");
char name[20];
int len = 0;
while (fscanf(fp, "%s", name) != EOF) {
++len;
int score,g=grade;
fscanf(fp, "%d%d%d%*c", &score,&gametime,&g);
vu.push_back(UserData(string(name), score,gametime,g));
}
fclose(fp);
sort(vu.begin(), vu.end()); //对得分进行排名
system("cls");
DrawBoard();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), CYAN);
GoTo(STARTX + 8, STARTY + 2);
printf("用户");
GoTo(STARTX + 20, STARTY + 2);
printf("分数");
GoTo(STARTX + 32, STARTY + 2);
printf("生存时间");
GoTo(STARTX + 44, STARTY + 2);
printf("排行");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
for (int i = 0; i < len && i < 10; ++i) { //打印前十名用户数据
char const *p = vu[i].name.c_str();
Color(score);
GoTo(STARTX + 8, STARTY + 4 + i);
printf("%s", p);
GoTo(STARTX + 20, STARTY + 4 + i);
printf("%d分", vu[i].score);
GoTo(STARTX + 32, STARTY + 4 + i);
printf("%d秒", vu[i].gt);
GoTo(STARTX + 44, STARTY + 4 + i);
printf(" %d", i + 1);
}
GoTo(STARTX + 4, ENDY - 2);
printf("----------------- 按'1'返回游戏菜单 ---------------");
while (true) {
if (_kbhit()) {
char key = getch();
if (key == '1') break;
}
}
}
void ShowAbout() { //展示游戏相关
system("cls");
DrawBoard();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
GoTo(STARTX + 4, STARTY + 2);
printf("------------------- 贪吃蛇游戏 -------------------");
GoTo(STARTX + 10,STARTY + 8);
printf("贪吃蛇游戏");
GoTo(STARTX + 10,STARTY + 10);
printf("游戏规则:");
GoTo(STARTX + 10,STARTY + 12);
printf("请按 ↑ ↓ ← → 来控制您的蛇吃东西");
GoTo(STARTX + 10,STARTY + 14);
printf("吃的越多,蛇就越长,您的等级也将越高");
GoTo(STARTX + 10,STARTY + 16);
printf("当蛇吃到自己或撞上墙时,游戏结束。");
GoTo(STARTX + 4, ENDY - 2);
printf("----------------- 按'1'返回游戏菜单 ---------------");
while (true) {
if (_kbhit()) {
char key = getch();
if (key == '1') break;
}
}
}
void InputData() { //用户输入名字
char name[20];
if(score>=1000)
{
GoTo(STARTX + 10, STARTY + 10);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), RED);
printf("请输入你的名字: ");
COORD coord = { STARTX + 10, STARTY + 12 };
SetConsoleCursorPosition(GetStdHandle(STD_INPUT_HANDLE), coord);
while (true) { //忽略非法字符
scanf("%s", name);
if (name[0] != 0 && name[0] != ' ') break;
}FILE *fp = fopen("Gamedata2.txt", "a");
if (fp == NULL) fp = fopen("Gamedata2.txt", "w+");
fprintf(fp, "%s %d %d \n", name, score,gametime);
fclose(fp);
}
else
{
GoTo(STARTX + 20, STARTY + 10);
cout<<"哟!这分数也能上榜??"<<endl;
Sleep(1000);
}
EndGame();
}
2.生化危机
点击查看代码
#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include<conio.h>
using namespace std;
int mzhg;
int zd;
int swhm;
int qxs;
int swx;
int sn;
int mp;
int tongguan;
int sw1;
int zd1;
int sn1;
int mz1;
int mp1;
int zbbj;
int ccg;
int mzzd;
int mz;
int tongguan1;
int sw;
int x;
int s;
int cdd;
int jg;
int qiang;
int gun;
int by;
int gjj[100];
int hjj[100];
int zjj[100];
void Slowsay(string a) {
int l = a.size();
for (int i = 0; i < l; i++) {
cout << a[i];
Sleep(2);
}
printf("\n");
}
int read() {
char ch = _getch();
while (ch > '9' || ch < '0') ch = _getch();
return ch - 48;
}
void qp() {
system("cls");
Slowsay("当前你的状态是\n");
printf("子弹 %d,食物 %d\n", zd, sw);
}
int esl() {
system("cls");
char ch;
Slowsay("你因为食物短缺,饿死了。\n");
ch = _getch();
hjj[1] = 1;
Slowsay("Bad End 1\n");
ch = _getch();
s++;
return 0;
}
int mzd() {
hjj[2] = 1;
system("cls");
char ch;
Slowsay("你遭遇了丧尸,因为子弹不足被咬死了。\n");
ch = _getch();
Slowsay("Bad End 2\n");
ch = _getch();
s++;
return 0;
}
int hd1() {
system("cls");
Slowsay("在某一天,你家门口响起了敲门声,你打开门,外面的发现让你欣喜若狂\n");
Slowsay("政府的救援部队已经消灭了这个城市的丧尸,\n他们在这个城市的各个角落搜索着可能存在的幸存者.\n");
Slowsay("Happy End-----苟到最后\n");
if (hjj[3] == 1 && gjj[1] == 0) {
Sleep(2000);
Slowsay("获得线索-----速度飘忽不定的政府");
}
gjj[1] = 1;
return 0;
}
int hd2() {
system("cls");
int sw;
char ch;
Slowsay("在与妹子相处的这些时间里,你与她相爱了\n");
Slowsay("你们的生活是那样的幸福\n");
Slowsay("直到有一天......\n");
Slowsay("基地首领希望你去执行一个任务,你选择\n");
Slowsay("1.独自一人前往\n");
Slowsay("2.和妹子一起去\n");
while (true) {
int x;
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1) {
Slowsay("当你完成任务回来的时候,发现——\n");
Slowsay("基地被丧尸攻破了\n");
Slowsay("这个基地的所有人都被丧尸杀了,一个人都没跑出来\n");
hjj[4] = 1;
Slowsay("Bad End 4");
s++;
}
if (x == 2) {
Slowsay("当你和妹子完成任务回来时,\n");
Slowsay("基地已经变成一片废墟了\n");
Slowsay("你和妹子没有办法,只能到处流浪\n");
Slowsay("不过,两个人总比一个人要好\n");
gjj[2] = 1;
Slowsay("Happy End------神仙眷侣");
}
break;
}
return 0;
}
int hd3() {
system("cls");
char ch;
Slowsay("你就这样平静的生活在这个基地里\n");
Slowsay("直到某一天,大量的丧尸进攻了这里\n");
if (zd > 9) {
Slowsay("每个人都在尽自己的努力去守卫基地\n");
Slowsay("每个人都做到了自己能做到的\n");
Slowsay("最后,奇迹出现了\n");
Slowsay("大家成功守住了基地\n");
Slowsay("而你,也因为在守卫过程中立下大功成为了这个基地的英雄\n");
Slowsay("顺便说一句,到死了你也没女朋友\n");
gjj[3] = 1;
Slowsay("Happy End-----英雄不朽");
return 0;
}
Slowsay("丧尸的数量实在太多了,\n");
Slowsay("尽管基地的大家都在尽全力防守\n");
Slowsay("可基地还是被攻破了\n");
Slowsay("而你,也死在了这里\n");
s++;
hjj[5] = 1;
Slowsay("Bad End 5");
}
int hd4() {
system("cls");
Slowsay("在于少年相处的这些时间里");
Slowsay("你尽力地保护着他");
Slowsay("而他也常常给你带来惊喜");
Slowsay("慢慢的,你开始认清你自己");
Slowsay("你是个gay");
Slowsay("于是,你就和少年性福快乐的生活在了一起");
Slowsay("Happy End-----认清自己");
gjj[4] = 1;
}
int td() {
system("cls");
char ch;
Slowsay("那箱饼干与你的枪一起发出了强光\n");
Slowsay("紧接着,他们融为了一体\n");
Slowsay("当光芒散去时,整个世界都发生了变化\n");
Slowsay("所有的丧尸都变回了人类\n");
Slowsay("True End-----一如既往");
if (zjj[1] != 1) {
Slowsay("获得线索-----奇特的枪与饼干");
}
zjj[1] = 1;
}
int td2() {
system("cls");
char ch;
Slowsay("你的变异已经开始了");
Slowsay("你开始疯狂的进食,直到把自己的胃撑破");
Slowsay("然后,就眼前一黑失去意识");
Slowsay("再次醒来时,你已经是一个丧尸了");
Slowsay("奇怪的是,你还保留着自己的意识");
Slowsay("你感觉到自己的力气变得更大,速度变得更快");
Slowsay("或许变成丧尸也不错————你这样想着");
Slowsay("True End-----保持本我");
if (zjj[2] != 1) {
Sleep(2000);
Slowsay("获得线索-----延迟变异的少年");
}
zjj[2] = 1;
}
int bd8() {
Slowsay("坐在椅子上的是一个15岁左右的少年");
Slowsay("正在你因为他的年龄而惊讶时");
Slowsay("少年却站了起来,看向了你身后的妹子");
Slowsay("“差不多了吧”,妹子这样说道");
Slowsay("“可以了”,这是少年的回答");
Slowsay("然后,你就感到脖子一阵剧痛");
Slowsay("在你失去意识前,眼中最后的场景是妹子咬着你的脖子");
s++;
Slowsay("Bad End 8");
if (hjj[8] == 0) {
Sleep(2000);
Slowsay("获得线索-----早已变异的妹子");
}
hjj[8] = 1;
}
int td3() {
system("cls");
Slowsay("你和妹子冲出了丧尸的围杀,");
Slowsay("可是当你们来到那个幸存者基地时");
Slowsay("却发现那个基地有一些不对");
Slowsay("所有人都死气沉沉的");
Slowsay("你们直接走向了首领的房间");
if (zjj[2] == 1 && zjj[3] == 1) {
bd8();
return 0;
}
Slowsay("坐在椅子上的是一个30岁左右的男性");
Slowsay("他说,欢迎");
Slowsay("基地的首领表示可以用子弹交换你手中的食物");
Slowsay("请输入你需要的子弹数");
Slowsay("0");
Slowsay("基地首领希望你加入这个基地");
Slowsay("你的选择是");
Slowsay("1.留在这");
Slowsay("2.离开");
Slowsay("2");
Slowsay("你决定");
Slowsay("1.当天离开");
Slowsay("2.再停留一天");
Slowsay("1");
Slowsay("就在你快要离开的时候,妹子抓住了你的手");
Slowsay("“我喜欢你,别走”,她这样说");
Slowsay("于是,你留了下来");
Slowsay("你们的生活是那样的幸福");
Slowsay("直到有一天......");
Slowsay("基地首领希望你去执行一个任务,你选择");
Slowsay("1.独自一人前往");
Slowsay("2.和妹子一起去");
Slowsay("2");
Slowsay("在执行任务的过程中");
Slowsay("妹子曾被丧尸咬到过一口");
Slowsay("她以为你没有发现");
Slowsay("而你却在远处看到了这一幕");
Slowsay("奇怪的是,她却并没有变异");
Slowsay("当你和妹子完成任务回来时,");
Slowsay("基地已经变成一片废墟了");
Slowsay("你和妹子没有办法,只能到处流浪");
Slowsay("不过,两个人总比一个人要好");
Slowsay("Happy End------神仙眷侣");
Slowsay("???????????????????????????????????");
Slowsay("True End------幻觉");
if (zjj[3] == 0) {
Sleep(2000);
Slowsay("获得线索-----不变异的妹子");
}
zjj[3] = 1;
}
int td4() {
system("cls");
Slowsay("当丧尸危机爆发时,你正呆在家里\n");
char ch = _getch();
ch = _getch();
for (int i = 1; i <= 50; i++) {
Slowsay("你的家里是个较为安全的地方,你可以选择搜索你家的物资或是去邻居家看看\n");
Sleep(250 - 5 * i);
system("cls");
Slowsay("********************************************************************\n");
system("cls");
}
Slowsay("检测到不匹配!!!\a\a\a");
Sleep(2000);
ch = _getch();
Slowsay("有什么不对劲");
Slowsay("你这样想着");
Slowsay("过去了好多天,\n你还是一个人都没有遇到,\n除了丧尸就是丧尸");
Slowsay("这一切,就好像被废弃了一样");
Slowsay("\n");
Slowsay("True End------停服");
zjj[4] = 1;
if (zbbj == 0)
Slowsay("进阶线索-----逐步逼近的真相"), zbbj = 1;
}
int td5() {
system("cls");
Slowsay("当少年死去后,整个世界好像变得不同了");
Slowsay("所有的活人在一瞬间消失");
Slowsay("所有的丧尸当场去世");
Slowsay("你的眼前只剩下了黑暗");
Slowsay("不知道过去了多久,你死了");
Slowsay("Bad End......");
system("cls");
Slowsay("当少年死去后,整个世界好像变得不同了\n");
Slowsay("所有的活人在一瞬间消失\n");
Slowsay("所有的丧尸当场去世\n");
Slowsay("你的眼前只剩下了黑暗\n");
Slowsay("不知道过去了多久,你死了\n");
Slowsay("不,还没有结束");
Slowsay("虽然好像和往常死去之后的感觉一样");
Slowsay("但是。。。。。。");
Slowsay("True End-----姗姗来迟的死亡");
s++;
if (zjj[5] == 0)
Slowsay("进阶线索-----死亡之后");
zjj[5] = 1;
}
int tg3() {
Slowsay("当你再次睁开眼时");
Slowsay("你发现自己躺在一个营养仓内");
Slowsay("你无比的确认这就是真实的世界");
Slowsay("你打碎了玻璃,跑出了营养仓");
Slowsay("脑中的一切开始明晰起来");
Slowsay("你认为自己知道了一切的真相");
Slowsay("去杀光人类吧!!!!");
Slowsay("你这样想着");
Slowsay("来到了外面这个被丧尸破坏得满目疮痍的世界");
Slowsay("你熟练的发出嘶吼,呼唤着周围的丧尸");
Slowsay("你指挥着他们,毁掉了一个又一个人类的基地");
Slowsay("虽然,在一个你不知道的地方");
Slowsay("一个个一样的营养仓中,装着一个个一样的你");
Slowsay("---------------游戏进阶剧情通关-------------");
tongguan1 = 1;
}
int tg2() {
Slowsay("当你再次睁开眼时");
Slowsay("你发现自己躺在一个营养仓内");
Slowsay("你无比的确认这就是真实的世界");
Slowsay("你打碎了玻璃,跑出了营养仓");
Slowsay("脑中的一切开始明晰起来");
Slowsay("你认为自己知道了一切的真相");
Slowsay("去拯救世界吧!!!!");
Slowsay("你这样想着");
Slowsay("来到了外面这个被丧尸破坏得满目疮痍的世界");
Slowsay("虽然,在一个你不知道的地方");
Slowsay("一个一样的营养仓中,装着一个一样的你");
Slowsay("---------------游戏进阶剧情通关-------------");
tongguan1 = 1;
}
int td6() {
Slowsay("一天以后,少年回来了");
Slowsay("一起回来的还有妹子");
Slowsay("少年的手中拿着你的铭牌");
Slowsay("此时,你才发现你的铭牌不见了");
Slowsay("“没想到是你”");
Slowsay("“妹子神色复杂的看了你一眼”");
Slowsay("“我们是一类人”");
Slowsay("“现在,让我把你带出去吧”");
if (qxs == 1) {
tg2();
return 0;
} else {
Slowsay("一股强烈的撕扯感出现到了你身上");
Slowsay("此时的你并不能接受如此巨大的伤害");
Slowsay("你死了");
Slowsay("Bad End 14");
if (hjj[14] == 0)
Slowsay("进阶线索-----外面的世界");
hjj[14] = 1;
s++;
}
}
int bd6() {
system("cls");
Slowsay("你感觉到自己正在变异,");
Slowsay("意识开始逐渐模糊起来");
Slowsay("你的肚子正无比渴望着人肉");
Slowsay("接着,你眼前一黑,再也没有醒来");
s++;
hjj[6] = 1;
Slowsay("Bad End 6");
}
int bd3() {
system("cls");
char ch;
Slowsay("长久的等待终于让你失去了理智,你疯了。\n");
if (mp == -1) {
Slowsay("当政府的救援队打开你家的门时,你嘶吼着扑了上去");
if (zd > 0)
Slowsay("他们试图将你击毙,却被你提前一枪击倒");
else {
Slowsay("你被他们击毙了");
Slowsay("Bad End 12");
s++;
hjj[12] = 1;
return 0;
}
Slowsay("你如同一个熟练的猎手,狩猎着救援队");
Slowsay("当他们全部死去后,你开始享用起你的大餐");
Slowsay("Bad End 13");
if (by == 0)
Sleep(2000), Slowsay("进阶线索-----变异是什么时候的事呢"), by = 1;
hjj[13] = 1;
return 0;
}
Slowsay("Bad End 3\n");
s++;
if (hjj[3] == 0 && gjj[1] == 1) {
Sleep(2000);
Slowsay("获得线索-----速度飘忽不定的政府");
}
hjj[3] = 1;
}
int bd7() {
s++;
system("cls");
Slowsay("因为食物不足,你被狗咬死了");
Slowsay("Bad End 7");
hjj[7] = 1;
}
int bd15() {
Slowsay("你发现这笔迹有些不对");
Slowsay("就好像是新写上去的一样");
Slowsay("认字迹的话,好像还十分熟悉");
Slowsay("正当你想的入迷的时候,你的脖子被咬住了");
Slowsay("在死前,你隐约听到了少年的声音,“再来一次吧”");
Slowsay("Bad End 15");
if (hjj[15] == 0) {
Sleep(2000);
Slowsay("进阶线索-----真的,假的!");
}
hjj[15] = 1;
}
int bd16() {
system("cls");
Slowsay("你一枪打死了少年");
Slowsay("基地首领以为你疯了,开枪杀了你");
Slowsay("Bad End 16");
}
int bd17() {
system("cls");
Slowsay("你试图开枪打死少年");
Slowsay("但是被少年发现了");
Slowsay("你被他一口咬死");
Slowsay("Bad End 17");
}
int tgg3() {
system("cls");
Slowsay("你杀掉了少年,并吃掉了他的尸体");
Slowsay("世界开始崩塌");
tg3();
}
int bd9() {
s++;
system("cls");
Slowsay("你进入大厦才发现这里藏着许多丧尸");
Slowsay("你一路且战且退来到了地下室");
Slowsay("诡异的是,当你杀光了跟来的丧尸后,发现地下室里并没有丧尸");
Slowsay("这里有的,只是一个穿着白大褂的尸体");
Slowsay("在尸体的衣服口袋中,你找到了一个笔记本");
Slowsay("****(无法辨认)1号****进展*****永生");
Slowsay("今********,*号诞生了,他比其*****更*");
Slowsay("有些不对,*****的发育有些太快了");
Slowsay("2号的**被***出有强感染性");
Slowsay("************************");
Slowsay("实验***瓶颈,或许我们因该**活体样本");
Slowsay("**,样本失去活性,但**在动");
if (mp == -1) {
bd15();
return 0;
}
Slowsay("正当你看的入迷的时候,你的脖子被咬住了");
Slowsay("在死前,你隐约听到了少年的声音,“再来一次吧”");
Slowsay("Bad End 9");
if (hjj[9] == 0) {
Sleep(2000);
Slowsay("发现线索-----实验体1号与2号");
}
hjj[9] = 1;
}
int tg() {
system("cls");
Slowsay("不知为何,当你走到这里时,感到世界在一瞬间发生了变化");
Slowsay("你不知道这个变化发生在那里,你只知道,现在的世界十分违和");
Slowsay("或许,这个世界不是真实的");
Slowsay("当你的脑中出现了这个的时候,你眼前的世界,蹦塌了");
Slowsay("于此同时,大量记忆冲进了你的脑海");
Slowsay("不,它们只是回来了,这本身就是你的记忆");
Slowsay("他们在一开始被一些虚假的记忆所替换");
Slowsay("从记忆中,你得知你此时正在玩一个vr游戏");
Slowsay("少年与妹子则是游戏的gm");
Slowsay("这款游戏号称有着超强的代入感");
Slowsay("你在发售当天就买来玩了");
Slowsay("“这游戏真是了不起啊”,你这样想着,“再玩一次吧”");
Slowsay("可真的是这样吗");
Slowsay("躺在营养仓中的你自始至终都没有睁开眼");
Slowsay("正如你从一开始就没有怀疑那些记忆的真实性.......");
Slowsay("---------------游戏基础剧情通关-------------");
tongguan = 1;
}
int zhxs() {
system("cls");
Slowsay("你好奇的看着眼前的一切");
Slowsay("“看起来像某个垃圾游戏的界面”,你这样想着");
Sleep(2000);
Slowsay("获得线索-----“结局?”");
}
int cg() {
system("cls");
Slowsay("你感觉到违和感在不断加深");
Slowsay("世界好像不再是真实的");
Slowsay("你现在脑中只有一种想法");
Slowsay("活下去");
}
int cg2() {
system("cls");
system("Color f0");
Slowsay("违和感在此时已经聚集到了顶峰");
Slowsay("你的脑中想清楚了一切");
Slowsay("1.那么,下一步是 杀光他们");
Slowsay("2.那么,下一步是 团结起来");
x = read();
if (x == 1)
Slowsay("本结局需要打通全badend"), swx = 1;
system("Color f0");
}
int bd10() {
system("cls");
Slowsay("你发现了另一个基地");
Slowsay("弹尽粮绝的你选择加入了他们");
Slowsay("之后的每一天都十分单调");
Slowsay("外出寻找物资,然后天黑了回家睡觉");
Slowsay("应该是这样吗?");
Slowsay("也许吧");
Slowsay("Bad End 10");
hjj[10] = 1;
}
int hd5() {
Slowsay("没关系的,一切都会过去的");
Slowsay("你这样说的");
Slowsay("他似乎感觉到了你的善意,一点一点向你靠近");
Slowsay("你紧紧的抱住了他");
Slowsay("我会保护好你的");
Slowsay("Happy End-----跨越物种的gay");
}
int sswj() {
// SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
system("cls");
int w = 0;
mp = 0;
if (tongguan == 1) {
mp = 0;
Slowsay("检测到你以通关,是否领取特殊物品\n");
Slowsay("1.领取");
Slowsay("2.不领取");
while (true) {
x = read();
if (x == 1)
mp = -1;
if (x == 2) {
td4();
return 0;
}
break;
}
}
char ch;
if (cdd == 1) {
Slowsay("是否读取存档\n");
Slowsay("1.读取\n");
Slowsay("2.不读取\n");
x = read();
if (x == 1) {
sw = sw1;
zd = zd1;
sn = sn1;
mz = mz1;
mp = mp1;
goto cddd1;
}
}
system("cls");
Slowsay("当丧尸危机爆发时,你正呆在家里\n");
ch = _getch();
Slowsay("你有10点物资可以分配到子弹和食物上\n");
ch = _getch();
int x, y;
int dd;
qiang = 0;
gun = 0;
zd = 0;
sw = 0;
sn = 0;
mz = 0;
mzzd = 0;
sn = 0;
mzhg = 0;
dd = 1;
Slowsay("请输入你的选择(此次输入需键入回车)\n");
while (true) {
scanf("%d%d", &x, &y);
zd = x;
sw = y;
if (x + y != 10 || x < 0 || y < 0) {
if (x == 1 && y == 2) {
sw = 99999;
zd = 99999;
Slowsay("启用秘籍\n");
break;
}
Slowsay("请重新输入\n");
w++;
if (w > 10) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
Slowsay("行了行了,这只是第一个选择而已\n"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
Slowsay("有必要这么皮吗\n"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
Slowsay("自动分配食物3个子弹7个\n"),
ch = _getch();
ch = _getch();
sw = 3, zd = 7;
break;
}
} else break;
}
Slowsay("你的家里是个较为安全的地方,你可以选择搜索你家的物资或是去邻居家看看\n");
ch = _getch();
Slowsay("1.留在家中\n");
Slowsay("2.前往邻居家\n");
while (true) {
x = read();
if (x != 1 && x != 2)
Slowsay("请重新输入\n");
else if (x == 1) {
Slowsay("在二楼,你发现了一些食物食物+3\n");
ch = _getch();
Slowsay("在家里过了一夜,食物-1\n");
sw = sw + 2;
break;
} else {
Slowsay("在前往邻居家的路上,你遇到了丧尸\n");
ch = _getch();
if (zd < 1) {
Slowsay("你朝他开了一枪,不过枪里没有子弹,你被他咬死了\n");
ch = _getch();
hjj[11] = 1;
Slowsay("Bad End 11\n");
s++;
ch = _getch();
Slowsay("另外在说一句,一个子弹都不带,还到处乱浪,你是真的作");
return 0;
} else {
Slowsay("你用你手中的枪结束了他的生命,子弹-1\n");
zd = zd - 1;
dd = 2;
ch = _getch();
Slowsay("邻居家里不知为何并没有人,你在仔细搜索后发现了一个弹夹,里面有4发子弹\n");
zd += 4;
ch = _getch();
Slowsay("在邻居家过了一夜后,食物-2\n");
sw = sw - 2;
if (sw < 0) {
esl();
return 0;
}
}
break;
}
}
ch = _getch();
qp();
Slowsay("你回想起这附近有一座商场,你决定\n");
ch = _getch();
Slowsay("1.前往商场\n");
Slowsay("2.到处乱走\n");
Slowsay("3.留在屋子里\n");
while (true) {
x = read();
if (x != 1 && x != 2 && x != 3) {
Slowsay("请重新输入\n");
continue;
}
if (x == 3) {
if (sw < 2) {
esl();
return 0;
}
Slowsay("无聊正在逐渐消磨你的意志,但你还是坚持了下来。食物-2\n");
sw = sw - 2;
ch = _getch();
Slowsay("之后的每一天你都是这样,独自一人在家中等待救援\n");
ch = _getch();
Slowsay("在过了好久之后\n");
if (sw < 6) {
esl();
return 0;
}
x = rand() % 2;
if (x == 1 && mp == 0) {
hd1();
return 0;
}
if (x == 0) {
bd3();
return 0;
}
}
if (x == 2) {
if (zd < 2) {
mzd();
return 0;
}
Slowsay("在到处乱走的过程中,你遇到了来自纳克萨玛斯的丧尸,子弹-2\n");
zd = zd - 2;
break;
}
if (x == 1) {
if (zd < 4) {
mzd();
return 0;
}
Slowsay("在前往商场的过程中,你遇到了丧尸,子弹-4\n");
zd = zd - 4;
dd = 4;
ch = _getch();
Slowsay("你在商场发现了食物与子弹,食物+3,子弹+2\n");
sw = sw + 3;
zd = zd + 2;
break;
}
}
Slowsay("你在回家的路上发现了一个女幸存者\n");
ch = _getch();
Slowsay("她试图向你讨要食物,你的选择是\n");
Slowsay("1.不给\n");
Slowsay("2.给她2份食物\n");
Slowsay("3.给她2份子弹\n");
Slowsay("4.给她一枪\n");
while (true) {
x = read();
if (x < 1 || x > 4) {
Slowsay("请重新输入。\n");
continue;
}
if (x == 1) {
Slowsay("妹子生气的走了。\n");
ch = _getch();
}
if (x == 2) {
if (sw < 2) {
Slowsay("食物不足\n");
continue;
}
sw = sw - 2;
mzhg++;
Slowsay("你的食物-2,妹子好感度+1\n");
ch = _getch();
}
if (x == 3) {
if (zd < 2) {
Slowsay("子弹不足\n");
continue;
}
mzzd = 1;
Slowsay("你给了妹子两份子弹,妹子离开了\n"), zd = zd - 2;
ch = _getch();
}
if (x == 4) {
if (zd < 1) {
Slowsay("子弹不足\n");
continue;
}
zd = zd - 1;
Slowsay("你一枪杀死了妹子,并从她的尸体上找到了4份食物\n");
if (swx == 2) {
Slowsay("你吃掉了妹子的尸体,子弹+10086\n");
zd = 10086;
}
sw = sw + 4;
mzhg = -1;
}
break;
}
Slowsay("又过了一夜,你的食物-2\n");
ch = _getch();
qp();
sw = sw - 2;
if (sw < 0) {
esl();
return 0;
}
if (mzhg > 0) {
Slowsay("那个妹子又来找到了你,并邀请你加入他们的幸存者基地\n");
} else Slowsay("你在附近发现了一个幸存者基地\n");
Slowsay("在前往基地的途中,你遇到了丧尸\n");
Slowsay("你且战且退,大量丧尸把你逼进了一家商店\n");
Slowsay("门口的丧尸越来越多,你选择\n");
Slowsay("1.杀出去(消耗较少子弹)\n");
Slowsay("2.守在这(消耗大量子弹,但可以拿到稀有物品)\n");
while (true) {
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1) {
int res = 0;
if (mzhg > 0)
res = 1;
else res = 3;
if (zd < res) {
mzd();
return 0;
}
zd = zd - res;
printf("你消耗了一些子弹冲了出去,子弹-%d\n", res);
if (mzzd == 1 && mp == -1) {
Slowsay("妹子在丧尸的尸体上找到了许多物资,子弹+7,食物+3\n");
zd = zd + 7;
sw = sw + 3;
mz = 1;
break;
}
x = rand() % 5;
if (res == 1 && x != 3)
Slowsay("妹子为了帮你突围,被丧尸咬到,然后自杀了。\n"), mzhg = -1;
if (x == 3 && res == 1) {
td3();
return 0;
}
} else if (x == 2) {
if (zd < 5) {
mzd();
return 0;
}
zd = zd - 5;
Slowsay("你守在这家商店里直到杀死了所有找来的丧尸,子弹-5\n");
if (mzhg == 1) {
Slowsay("妹子在商店中发现了一把无限子弹的枪,子弹+10086\n");
zd = 10086;
ch = _getch();
Slowsay("但是妹子在翻找货架的时候被沾了丧尸血的货架划伤\n");
Slowsay("妹子自杀了\n");
mzhg = -1;
}
}
break;
}
ch = _getch();
qp();
Slowsay("你来到了这个幸存者基地\n");
Slowsay("这个基地的首领表示可以用子弹交换你手中的食物\n");
printf("你还有%d份食物,%d份子弹\n", sw, zd);
ch = _getch();
Slowsay("请输入你需要的子弹数\n");
while (true) {
x = read();
if (x < 0 || x > sw) {
Slowsay("请重新输入\n");
continue;
}
sw = sw - x;
zd = zd + x;
if (x >= 1) {
Slowsay("首领很开心你能提供稀缺的食物,多给了你1份子弹\n");
zd = zd + 2;
}
break;
}
ch = _getch();
qp();
Slowsay("又过了一天,食物-2");
sw = sw - 2;
if (sw < 0) {
esl();
return 0;
}
ch = _getch();
system("cls");
Slowsay("基地首领希望你加入这个基地\n");
Sleep(500);
Slowsay("你的选择是\n");
Sleep(500);
Slowsay("\n");
Sleep(500);
system("Color f0");
Slowsay("1.留在这");
Slowsay("2.离开");
while (true) {
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
system("Color f0");
if (x == 1) {
if (mzhg > -1) hd2();
else hd3();
return 0;
}
if (x == 2) {
ch = _getch();
Slowsay("你决定\n");
Slowsay("1.当天离开\n");
Slowsay("2.再停留一天\n");
while (true) {
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1) break;
if (x == 2) {
ch = _getch();
qp();
Slowsay("这个基地的首领表示可以用子弹交换你手中的食物\n");
printf("你还有%d份食物,%d份子弹\n", sw, zd);
ch = _getch();
Slowsay("请输入你需要的子弹数\n");
while (true) {
x = read();
if (x < 0 || x > sw) {
Slowsay("请重新输入\n");
continue;
}
sw = sw - x;
zd = zd + x;
if (x >= 3) {
Slowsay("首领很开心你能提供稀缺的食物,多给了你3份子弹\n");
zd = zd + 3;
}
break;
}
sw = sw - 2;
if (sw < 0) {
esl();
return 0;
}
Slowsay("又过了一夜,食物-2\n");
}
break;
}
Slowsay("在你离开的时候,一个少年跑了过来。\n");
Slowsay("他说,他想要和你一起走\n");
Slowsay("1.带上他\n");
Slowsay("2.不带他\n");
while (true) {
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
if (x == 2) {
Slowsay("少年生气的离开了,当他走远了,你才发现\n");
Slowsay("在刚刚的接触中,他偷走了你的枪和所有子弹\n");
zd = -1;
}
if (x == 1) {
Slowsay("你选择上少年一起走\n");
Slowsay("少年将他身上带着的一份食物交给了你\n");
sw = sw + 1;
Slowsay("食物消耗+1,少年入队\n");
sn = 1;
}
break;
}
if (sn == 1 && swx == 2) {
Slowsay("1.杀了少年\n");
Slowsay("2.忍一会\n");
x = read();
if (x == 1) {
bd16();
return 0;
}
}
}
break;
}
sw = sw - 2 - sn;
ch = _getch();
qp();
printf("你在路边的一座没人的房子里过了一夜,食物-%d\n", 2 + sn);
if (sn == 1 && swx == 2) {
Slowsay("1.杀了少年\n");
Slowsay("2.忍一会\n");
x = read();
if (x == 1) {
bd17();
return 0;
}
}
ch = _getch();
if (sw < 0) {
esl();
return 0;
}
Slowsay("是否存档?\n");
Slowsay("1.存档(记录当前进度,只能有一个存档)\n");
Slowsay("2.不存\n");
x = read();
if (x == 1) {
cdd = 1;
sw1 = sw;
zd1 = zd;
mp1 = mp;
mz1 = mz;
sn1 = sn;
Slowsay("存档成功");
}
cddd1:
if (sn == 1) {
Slowsay("今天一早你就被少年叫醒了,\n");
ch = _getch();
Slowsay("他在床底下发现了一箱方便面,食物+6\n");
sw = sw + 6;
Slowsay("少年向你讨要武器,你决定\n");
Slowsay("1.把枪给他\n");
Slowsay("2.把从厨房拆下的水管给他\n");
Slowsay("3.什么都不给他\n");
while (true) {
x = read();
if (x < 1 || x > 3) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1)
qiang = 2;
if (x == 2)
gun = 2;
break;
}
} else {
Slowsay("你在冰箱里发现了几包巧克力\n");
ch = _getch();
Slowsay("希望他们还没过期吧,食物+3\n");
sw = sw + 3;
}
ch = _getch();
Slowsay("今天你们来到了一家大商场\n");
Slowsay("你决定\n");
Slowsay("1.独自探索1楼\n");
Slowsay("2.独自探索2楼\n");
if (sn == 1) {
Sleep(500);
Slowsay("3.和少年一起探索2楼");
}
while (true) {
x = read();
if (x < 1 || x > 3) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1) {
Slowsay("你在一楼发现了一些子弹,子弹+3\n");
zd = zd + 3;
Slowsay("奇怪的是,一只丧尸都没有看到\n");
ch = _getch();
if (sn > 0) {
if (qiang == 2) {
Slowsay("当你来到二楼时,发现了一地尸体\n");
Slowsay("少年就倒在这尸体中间,他死前手还紧紧握着枪\n");
Slowsay("你把枪拿了回来,并在少年的尸体下面发现了一箱压缩饼干\n");
Slowsay("食物+10086\n");
ch = _getch();
sw = 10086;
if (sw > 1000 && zd > 1000) {
td();
return 0;
}
sn = 0;
qiang = 1;
} else {
Slowsay("当你来到二楼时,发现了少年的尸体\n");
ch = _getch();
sn = 0;
Slowsay("你紧紧握着手中的枪,猛地一回头\n");
Slowsay("四周大量的僵尸向你涌来\n");
ch = _getch();
zd = zd - 5;
if (zd < 0) {
mzd();
return 0;
}
Slowsay("你杀光了这些丧尸,子弹-5\n");
ch = _getch();
Slowsay("你在二楼找到了食物,食物+2\n");
sw += 2;
}
}
}
if (x == 2) {
Slowsay("你来到了二楼,数之不尽的丧尸忽然从阴影中窜出\n");
Slowsay("尽管你尽力抵抗,可丧尸的数量实在太多。\n");
if (qiang == 2) {
mzd();
return 0;
}
ch = _getch();
zd -= 5;
if (zd < 0) {
mzd();
return 0;
}
Slowsay("你杀光了这些丧尸,子弹-5\n");
ch = _getch();
Slowsay("你在二楼找到了食物,食物+2\n");
sw += 2;
if (sn == 1) {
Slowsay("少年在一楼找到了子弹,子弹+3\n");
zd = zd + 3;
}
}
if (x == 3 && sn == 1) {
system("cls");
Slowsay("你们来到了二楼\n");
ch = _getch();
system("Color f0");
Slowsay("数之不尽的丧尸从阴影中窜出");
Slowsay("尽管你们尽力抵抗,可丧尸的数量实在太多。");
if (gun != 2 && qiang != 2) {
Slowsay("没有武器的少年被当场咬死。");
if (mp == -1 && mz == 0) {
td5();
return 0;
}
sn = 0;
}
Slowsay("其中一只丧尸趁你不注意冲到了你的旁边");
if (gun == 2)
Slowsay("就在你要被咬死的时候,少年扔出了手中的水管\n,救下了你");
else if (qiang != 2) {
zd = zd - 3;
if (zd < 0) {
mzd();
return 0;
}
Slowsay("你赶忙回头几枪补掉了这只丧尸,子弹-3");
}
zd = zd - 3;
if (qiang == 2 || zd < 0) {
system("Color f0");
mzd();
return 0;
}
system("Color f0");
Slowsay("经过了一番苦战,你们终于战胜了所有丧尸,子弹-3");
ch = _getch();
}
break;
}
ch = _getch();
qp();
ch = _getch();
printf("又过了一夜,食物-%d\n", sn + 2);
sw = sw - 2 - sn;
if (sw < 0) {
esl();
return 0;
}
qp();
Slowsay("今天在出门的时候\n");
Slowsay("你遇到了一条流浪狗\n");
Slowsay("1.用枪打它\n");
Slowsay("2.用食物引开它\n");
while (true) {
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1) {
Slowsay("你一枪打死了这条狗,子弹-1\n");
zd = zd - 1;
ch = _getch();
Slowsay("枪声引来了丧尸,子弹-2\n");
zd = zd - 2;
if (zd < 0) {
mzd();
return 0;
}
if (sn == 0) break;
Slowsay("在消灭了丧尸之后,你忽然发现少年的脸色不太好\n");
ch = _getch();
Slowsay("原来,在昨天的商场中,少年早就被咬了一口");
Slowsay("他一直瞒着你,不敢说出来");
Slowsay("此时,他已经濒临变异了");
Slowsay("你决定\n");
Slowsay("1.杀了他(消耗大量子弹)\n");
Slowsay("2.不杀他(消耗大量食物)\n");
if (gjj[4] == 1 && zd < 4) {
Slowsay("3.安抚他\n");
}
while (1) {
x = read();
if (x < 1 || x > 3) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1) {
if (swx == 2) {
if (zd > 1000) tgg3();
else mzd();
return 0;
}
Slowsay("你试着向他开枪,不过却被他躲过了\n");
Slowsay("你十分惊恐,疯狂地倾泻着手中的弹药\n");
Slowsay("子弹-4\n");
ch = _getch();
zd = zd - 4;
if (zd < 0) {
mzd();
return 0;
}
Slowsay("终于,你杀死了他\n");
if (mp == -1 && mz == 0) {
td5();
return 0;
}
sn = 0;
}
if (x == 2) {
Slowsay("你就站在旁边看着少年变异");
Slowsay("奇怪的是,他变异后并没有");
Slowsay("像其他的丧尸一样,向你扑过来");
Slowsay("而是躲在墙角瑟瑟发抖");
Slowsay("你慢慢的走过去");
Slowsay("就在你走近的时候,少年突然暴起");
Slowsay("狠狠地咬住了你的手臂");
Slowsay("你赶忙用枪打死他,可是为时已晚");
sn = 0;
if (sw >= 6) {
td2();
return 0;
} else {
bd6();
return 0;
}
}
break;
}
if (x == 3 && gjj[4] == 1) {
gjj[5] = 1;
hd5();
return 0;
}
}
if (x == 2) {
sw = sw - 2;
if (sw < 0) {
bd7();
return 0;
}
Slowsay("你用两份食物引开了这条狗,食物-2\n");
}
break;
}
ch = _getch();
ch = _getch();
if (sn == 1 && sw >= 4 && gun == 2 && zd > 5) {
hd4();
return 0;
}
if (sn == 1) {
Slowsay("又过了一天,食物-2\n");
sw = sw - 2;
if (sw < 0) {
esl();
return 0;
}
ch = _getch();
Slowsay("今天早上,你发现少年不见了\n");
Slowsay("你决定\n");
Slowsay("1.去寻找他\n");
Slowsay("2.不去找他\n");
while (true) {
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
if (x == 1) {
Slowsay("你通过蛛丝马迹一路追踪,来到了一座大厦前\n");
Slowsay("在路上,你遭遇了丧尸,子弹-2\n");
zd = zd - 2;
if (zd < 0) {
mzd();
return 0;
}
Slowsay("你决定\n");
Slowsay("1.进入大厦\n");
Slowsay("2.离开\n");
while (true) {
x = read();
if (x < 1 || x > 2) {
Slowsay("请重新输入\n");
continue;
}
if (x == 2) {
Slowsay("你在街边的商店中找到了食物,食物+2\n");
sw = sw + 2;
}
if (x == 1) {
if (zd <= 6) {
mzd();
return 0;
} else {
bd9();
return 0;
}
}
break;
}
}
break;
}
}
qp();
ch = _getch();
if (mz == 1 && sn == 1 && swx == 0) {
td6();
return 0;
}
Slowsay("又过了一天,食物-2");
sw = sw - 2;
if (sw < 0) {
esl();
return 0;
}
Sleep(500);
Slowsay("遭遇丧尸,子弹-3");
zd = zd - 3;
if (zd < 0) {
mzd();
return 0;
}
Sleep(500);
Slowsay("又过了一天,食物-2");
sw = sw - 2;
if (sw < 0) {
esl();
return 0;
}
Sleep(500);
Slowsay("遭遇丧尸,子弹-2");
zd = zd - 2;
if (zd < 0) {
mzd();
return 0;
}
Sleep(500);
if (ccg == 1) {
tg();
return 0;
} else {
bd10();
return 0;
}
}
int main() {
CONSOLE_CURSOR_INFO cursor_info = { 1, 0 };
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
srand(time(0));
while (true) {
zd = 10000;
int v = 0;
char ch;
mp = 0;
Sleep(1000);
ch = _getch();
system("cls");
Slowsay("1.进行游戏\n");
Slowsay("2.查看成就\n");
Slowsay("3.查看线索(获得全部线索后通关游戏)\n");
Slowsay("4.获得一条随机的提示\n");
Slowsay("5.'退出游戏'\n");
x = read();
if (x == 1) {
sswj();
if (s > 50 && swhm == 0) {
swhm = 1;
Slowsay("又死了啊");
Slowsay("这已经是第几次了呢");
Slowsay("一个柔和的声音从耳边传来");
Slowsay("或许早该放弃了");
Slowsay("\n");
Slowsay("进阶线索-----死亡?死亡!");
}
}
if (x == 2) {
int v1;
system("cls");
if (tongguan1 == 1) {
Slowsay("已通关进阶剧情");
if (swx == 0)
Slowsay("人类救星\n\n");
else
Slowsay("群尸之首\n\n");
} else if (tongguan == 1) {
Slowsay("已通关基础剧情\n\n");
}
int v = 0;
Slowsay("Happy Bnd 达成\n");
if (gjj[1] == 1)
Slowsay("苟到最后\n"), v++;
else
Slowsay("未达成\n");
if (gjj[2] == 1)
Slowsay("神仙眷侣\n"), v++;
else
Slowsay("未达成\n");
if (gjj[3] == 1)
Slowsay("英雄不朽\n"), v++;
else
Slowsay("未达成\n");
if (gjj[4] == 1)
Slowsay("认清自己\n"), v++;
else
Slowsay("未达成\n");
if (gjj[5] == 1)
Slowsay("跨越物种的gay\n");
else
Slowsay("未达成\n");
Slowsay("\n");
Slowsay("Bad End 达成(共15个)\n");
for (int i = 1; i <= 17; i++)
if (hjj[i] == 1)
printf("%d ", i), v++, v1++;
Slowsay("\n");
printf("当前死亡次数:%d", s);
Slowsay("\n");
Slowsay("True End 达成\n");
if (zjj[1] == 1)
Slowsay("一如既往\n"), v++;
else
Slowsay("未达成\n");
if (zjj[2] == 1)
Slowsay("保持本我\n"), v++;
else
Slowsay("未达成\n");
if (zjj[3] == 1)
Slowsay("幻觉\n"), v++;
else
Slowsay("未达成\n");
if (zjj[4] == 1)
Slowsay("停服\n"), v++;
else
Slowsay("未达成\n");
if (zjj[5] == 1)
Slowsay("珊珊来迟的死亡\n"), v++;
else
Slowsay("未达成\n");
Slowsay("\n");
if (v1 == 17 && swx == 1)
swx = 2, cdd = 0;
if (v > 15 && jg == 0) {
cdd = 0;
zhxs();
jg = 1;
}
char ch = _getch();
}
if (x == 3) {
system("cls");
int v = 0;
Slowsay("基础线索\n");
if (zjj[1] == 1)
Slowsay(" 奇特的枪与饼干\n"), v++;
else
Slowsay(" ?????\n");
if (zjj[2] == 1)
Slowsay(" 延迟变异的少年\n"), v++;
else
Slowsay(" ?????\n");
if (zjj[3] == 1)
Slowsay(" 不变异的妹子\n"), v++;
else
Slowsay(" ?????\n");
if (hjj[3] == 1 && gjj[1] == 1)
Slowsay(" 速度飘忽不定的政府\n"), v++;
else
Slowsay(" ?????\n");
if (hjj[8] == 1)
Slowsay(" 早已变异的妹子\n"), v++;
else
Slowsay(" ?????\n");
if (hjj[9] == 1)
Slowsay(" 实验体1号与2号\n"), v++;
else
Slowsay(" ?????\n");
if (jg == 1)
Slowsay(" “结局?”\n"), v++;
else
Slowsay(" ?????\n\n");
Slowsay("进阶线索\n");
if (swhm == 1)
Slowsay(" 死亡?死亡!\n"), v++;
else
Slowsay(" ?????\n");
if (zbbj == 1)
Slowsay(" 逐步逼近的真相\n"), v++;
else
Slowsay(" ?????\n");
if (by == 1)
Slowsay(" 变异是什么时候的事呢\n");
else
Slowsay(" ?????(本线索可以不发现)\n");
if (zjj[5] == 1)
Slowsay(" 死亡之后\n"), v++;
else
Slowsay(" ?????\n");
if (hjj[14] == 1)
Slowsay(" 外面的世界\n"), v++;
else
Slowsay(" ?????\n");
if (hjj[15] == 1)
Slowsay(" 真的,假的!"), v++;
else
Slowsay(" ?????\n");
if (v > 6 && ccg == 0) {
Sleep(2000);
cdd = 0;
cg();
ccg = 1;
}
if (v >= 12 && qxs == 0) {
Sleep(2000);
qxs = 1;
cg2();
cdd = 0;
}
ch = _getch();
}
if (x == 4) {
system("cls");
x = rand() % 11;
if (x == 0)
Slowsay("加了好感后,妹子是有几率不死的哦");
if (x == 1)
Slowsay("如果想要和少年在一起的话,就一定要十分富有");
if (x == 2)
Slowsay("有一些事不是没有发生,只是你没看到");
if (x == 3)
Slowsay("如果和首领交换子弹的话,他会很开心");
if (x == 4)
Slowsay("妹子的身上带着4份食物呢");
if (x == 5)
Slowsay("因为某不愿透露姓名ww的要求,有一些结局要脸好才能触发");
if (x == 6)
Slowsay("大多数时候,你认为一个地方没有好结局只是因为你食物/子弹不够");
if (x == 7)
Slowsay("有一些结局是有前置条件才能触发的,耐心一点吧");
if (x == 8)
Slowsay("绝大多数的线索来自结局");
if (x == 9)
Slowsay("进阶线索需要你走以前没走过的路");
if (x == 10)
Slowsay("完成所有坏结局会进入尸王线");
ch = _getch();
continue;
}
if (x == 5) {
system("cls");
Slowsay("游戏退出中。。。。。。");
if (tongguan1 != 1) {
Slowsay("你死了");
s++;
} else {
Slowsay("你离开了这个世界");
return 0;
}
}
}
}
3.三国杀
点击查看代码
#include<iostream>
#include<time.h>
#include<stdio.h>
#include <stdlib.h>
using namespace std;
struct pai {
int paifu;
int huase;
int yanse;
int dianshu;
int leixing;
int changdu;
void Kanpai() {
if (paifu == 0 || paifu == 1);
else
printf("牌副参数错误!\n");
switch (huase) {
case 0:
cout << "黑桃";
break;
case 1:
cout << "红桃";
break;
case 2:
cout << "草花";
break;
case 3:
cout << "方片";
break;
case -1:
cout << "无色";
break;
default:
printf("花色错误!\n");
break;
}
switch (dianshu) {
case 0:
cout << "A ";
break;
case 1:
cout << "2 ";
break;
case 2:
cout << "3 ";
break;
case 3:
cout << "4 ";
break;
case 4:
cout << "5 ";
break;
case 5:
cout << "6 ";
break;
case 6:
cout << "7 ";
break;
case 7:
cout << "8 ";
break;
case 8:
cout << "9 ";
break;
case 9:
cout << "10 ";
break;
case 10:
cout << "J ";
break;
case 11:
cout << "Q ";
break;
case 12:
cout << "K ";
break;
case -1:
cout << "无点数";
break;
default:
printf("点数错误!\n");
break;
}
switch (leixing) {
case 101:
cout << "【杀】" << endl;
break;
case 102:
cout << "【闪】" << endl;
break;
case 103:
cout << "【桃】" << endl;
break;
case 201:
cout << "【过河拆桥】" << endl;
break;
case 202:
cout << "【顺手牵羊】" << endl;
break;
case 203:
cout << "【无中生有】" << endl;
break;
case 204:
cout << "【决斗】" << endl;
break;
case 205:
cout << "【借刀杀人】" << endl;
break;
case 206:
cout << "【桃园结义】" << endl;
break;
case 207:
cout << "【五谷丰登】" << endl;
break;
case 208:
cout << "【南蛮入侵】" << endl;
break;
case 209:
cout << "【万箭齐发】" << endl;
break;
case 210:
cout << "【无懈可击】" << endl;
break;
case 251:
cout << "【乐不思蜀】" << endl;
break;
case 252:
cout << "【闪电】" << endl;
break;
case 301:
cout << "【诸葛连弩(1)】" << endl;
break;
case 302:
cout << "【雌雄双股剑(2)】" << endl;
break;
case 303:
cout << "【青釭剑(2)】" << endl;
break;
case 304:
cout << "【青龙偃月刀(3)】" << endl;
break;
case 305:
cout << "【丈八蛇矛(3)】" << endl;
break;
case 306:
cout << "【贯石斧(3)】" << endl;
break;
case 307:
cout << "【方天画戟(4)】" << endl;
break;
case 308:
cout << "【麒麟弓(5)】" << endl;
break;
case 331:
cout << "【八卦阵】" << endl;
break;
case 361:
cout << "【赤兔(-1)】" << endl;
break;
case 362:
cout << "【大宛(-1)】" << endl;
break;
case 363:
cout << "【紫辛(-1)】" << endl;
break;
case 381:
cout << "【爪黄飞电(+1)】" << endl;
break;
case 382:
cout << "【的卢(+1)】" << endl;
break;
case 383:
cout << "【绝影(+1)】" << endl;
break;
default:
printf("类型参数错误!");
break;
}
}
};
void Qishixipai(pai A[2][4][13], pai paidui[104]) {
int i, m, x, y, z, a[104] = {0};
srand((unsigned)time(NULL));
for (i = 1; i <= 104; i++) {
while (a[m = rand() % 104]);
a[m] = i;
}
for (i = 0; i <= 103; i++) {
x = (a[i] - 1) / 52;
y = ((a[i] - 1) - 52 * x) / 13;
z = (a[i] - 1) % 13;
paidui[i] = A[x][y][z];
}
}
void Xipai(pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
int i, m, a[104] = {0};
srand((unsigned)time(NULL));
for (i = 1; i <= (*qipaishu); i++) {
while (a[m = rand() % (*qipaishu)]);
a[m] = i;
}
for (i = 0; i <= ((*qipaishu) - 1); i++) {
paidui[i] = qipaidui[a[i]];
qipaidui[a[i]].leixing = -1;
(*paiduishu)++;
(*qipaishu)--;
}
for (i = (*paiduishu); i <= 103; i++)paidui[i].leixing = -1;
}
pai Mo1pai(pai A[104], int *x, pai B[104], int*y, int *b) {
pai p;
if ((*x) == 0)Xipai(A, x, B, y);
else if ((*x) < 0)printf("摸牌参数错误!");
else;
p = A[104 - (*x)];
(*x)--;
(*b)++;
return (p);
}
struct wujiang {
char name;
int tili;
int tilishangxian;
int shoupaishangxian;
int huihekaishi;
int panding;
int mopai;
int chupai;
int qipai;
int huihejieshu;
int juese;
pai shoupai[20];
int shoupaishu;
pai zhuangbei[4];
int zhuangbeishu;
pai pandingpai[3];
int pandingshu;
int juli[1];
void Kanshoupai() {
printf("玩家当前手牌:\n");
if (shoupaishu) {
int m;
for (m = 0; m <= (shoupaishu - 1); m++) {
printf("%d ", m);
(shoupai[m]).Kanpai();
}
} else printf("空城!\n");
printf("\n");
}
void Kanzhuangbei() {
if (juese)printf("玩家");
else printf("电脑");
printf("当前装备:\n");
printf("0 武器: ");
if ((zhuangbei[0]).leixing == -1)printf("空\n");
else (zhuangbei[0]).Kanpai();
printf("1 防具: ");
if ((zhuangbei[1]).leixing == -1)printf("空\n");
else (zhuangbei[1]).Kanpai();
printf("2 进攻马: ");
if ((zhuangbei[2]).leixing == -1)printf("空\n");
else (zhuangbei[2]).Kanpai();
printf("3 防御马: ");
if ((zhuangbei[3]).leixing == -1)printf("空\n");
else (zhuangbei[3]).Kanpai();
printf("\n");
}
void Kanpandingpai() {
if (juese)printf("玩家");
else printf("电脑");
printf("当前判定区:\n");
if ((pandingpai[0]).leixing == -1)printf("空\n");
else {
printf("0 ");
(pandingpai[0]).Kanpai();
if ((pandingpai[1]).leixing == -1);
else {
printf("1 ");
(pandingpai[1]).Kanpai();
if ((pandingpai[2]).leixing == -1);
else {
printf("2 ");
(pandingpai[2]).Kanpai();
}
}
}
}
};
void Mopai(int*shoupaishu, pai shoupai[20], pai A[104], int *x, pai B[104], int*y, int juese) {
if (juese)printf("玩家从牌堆摸2张牌\n");
else printf("电脑从牌堆摸2张牌\n");
pai p;
p = Mo1pai(A, x, B, y, shoupaishu);
shoupai[*shoupaishu - 1] = p;
pai q;
q = Mo1pai(A, x, B, y, shoupaishu);
shoupai[*shoupaishu - 1] = q;
int m;
if (juese) {
printf("玩家当前手牌:\n");
for (m = 0; m <= (*shoupaishu - 1); m++) {
printf("%d ", m);
(shoupai[m]).Kanpai();
}
}
printf("牌堆还剩%d张牌!\n\n", *x);
}
void Qishishoupai(wujiang *w, pai A[104], int *x, pai B[104], int*y) {
pai a;
a = Mo1pai(A, x, B, y, &((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu - 1] = a;
pai b;
b = Mo1pai(A, x, B, y, &((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu - 1] = b;
pai c;
c = Mo1pai(A, x, B, y, &((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu - 1] = c;
pai d;
d = Mo1pai(A, x, B, y, &((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu - 1] = d;
int m;
if ((*w).juese)printf("玩家从牌堆摸4张牌\n");
else printf("电脑从牌堆摸4张牌\n");
if ((*w).juese) {
printf("玩家当前手牌:\n");
for (m = 0; m <= ((*w).shoupaishu - 1); m++) {
printf("%d ", m);
((*w).shoupai[m]).Kanpai();
}
}
printf("牌堆还剩%d张牌!\n\n", *x);
}
void Panding(pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
paidui[*paiduishu].Kanpai();
qipaidui[*qipaishu] = paidui[*paiduishu];
(*paiduishu)--;
(*qipaishu)++;
}
pai Zhangba(wujiang*w, pai qipaidui[104], int*qipaishu) {
int x, y;
pai p;
for (;;) {
int i, j;
printf("请输入任意两张手牌之前的编号,以空格隔开,以回车结束!\n");
scanf("%d", &x);
scanf("%d", &y);
if ((x >= 0) && (x < (*w).shoupaishu) && (y >= 0) && (y < (*w).shoupaishu - 1)) {
switch ((((*w).shoupai[x].huase) % 2) + (((*w).shoupai[y].huase) % 2)) {
case 0:
p.yanse = 0;
break;
case 2:
p.yanse = 1;
break;
case 1:
p.yanse = 2;
break;
default:
printf("【丈八蛇矛】函数参数错误!\n");
}
qipaidui[*qipaishu] = (*w).shoupai[x];
(*w).shoupai[x].leixing = -1;
((*w).shoupaishu)--;
(*qipaishu)++;
qipaidui[*qipaishu] = (*w).shoupai[y];
(*w).shoupai[y].leixing = -1;
((*w).shoupaishu)--;
(*qipaishu)++;
printf("弃牌数:%d", *qipaishu);
for (i = 0; i <= (((*w).shoupaishu) + 1); i++) {
if ((*w).shoupai[i].leixing == -1) {
for (j = i + 1; j <= (((*w).shoupaishu) + 2); j++)
(*w).shoupai[j - 1] = (*w).shoupai[j];
i--;
}
}
printf("玩家把:\n");
qipaidui[(*qipaishu) - 2].Kanpai();
qipaidui[(*qipaishu) - 1].Kanpai();
printf("当作一张");
switch (p.yanse) {
case 0:
printf("黑色");
break;
case 2:
printf("红色");
break;
case 1:
printf("无色");
break;
default:
printf("绿色");
break;
}
printf("无点数的【杀】");
p.dianshu = -1;
p.leixing = 101;
return p;
break;
}
printf("你将两张空气当作一张空气属性的【杀】使用或打出!\n");
}
}
int Xuanpai(wujiang*w, int t) {
int x;
if ((*w).juese) {
for (;;) {
printf("出牌请输入手牌之前的编号,以回车结束!\n如果你想结束出牌阶段,请输入“-1”,以回车结束!\n");
scanf("%d", &x);
if ((x >= -1 && x < ((*w).shoupaishu)) || ((x == 100) && ((*w).zhuangbei[0].leixing == 305))) {
return x;
break;
}
printf("你打出了一张空气!\n");
}
} else return t;
}
pai Panpai(wujiang*w1, int*sha, int y, pai qipaidui[104], int*qipaishu) {
pai p, q;
p.leixing = 0;
q.leixing = -1;
if (y == -1)return q;
else {
if (y == 100) {
if ((*sha) > 0) {
q = Zhangba(w1, qipaidui, qipaishu);
printf("使用!\n");
return q;
} else {
printf("当前回合使用【杀】的次数已用尽,你也不能使用【丈八蛇矛】效果!\n");
return p;
}
}
switch ((*w1).shoupai[y].leixing) {
case 101:
if (((*sha) > 0) || ((*w1).zhuangbei[0].leixing == 301)) {
if (((*w1).zhuangbei[0].leixing == 301))printf("武器【诸葛连弩】效果被触发!\n");
return (*w1).shoupai[y];
break;
} else {
if ((*w1).juese)printf("当前回合使用【杀】的次数已用尽,你不能使用【杀】!\n");
return p;
break;
}
case 102:
if ((*w1).juese)
printf("当前不需要响应任何操作,你不能主动打出【闪】!\n");
return p;
break;
case 103:
if (((*w1).tili) < ((*w1).tilishangxian)) {
return (*w1).shoupai[y];
break;
} else {
if ((*w1).juese)
printf("你并未受伤,不能对自己使用【桃】!\n");
}
return p;
break;
case 210:
if ((*w1).juese)
printf("当前不需要响应任何锦囊,你不能主动打出【无懈可击】!\n");
return p;
break;
case 201:
case 202:
case 203:
case 204:
case 205:
case 206:
case 207:
case 208:
case 209:
case 251:
case 252:
case 301:
case 302:
case 303:
case 304:
case 305:
case 306:
case 307:
case 308:
case 331:
case 361:
case 362:
case 363:
case 381:
case 382:
case 383:
return (*w1).shoupai[y];
break;
default:
printf("手牌类型参数错误!\n");
return p;
break;
}
}
}
int Mubiao(pai p, wujiang *w1, wujiang *w2, int*sha) {
int x;
switch (p.leixing) {
case 101:
if ((*w1).juese) {
printf("请选择【杀】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
scanf("%d", &x);
if (x == 0) {
if ((*w1).zhuangbei[0].changdu >= (*w1).juli[0]) {
(*sha)--;
return ((*w2).juese);
} else {
printf("武器长度不够!\n");
return -2;
}
} else {
printf("目标错误!\n");
return -2;
}
} else {
if ((*w1).zhuangbei[0].changdu >= (*w1).juli[0]) {
(*sha)--;
return ((*w2).juese);
} else return -2;
}
break;
case 103:
return ((*w1).juese);
break;
case 201:
if ((*w1).juese) {
printf("请选择【过河拆桥】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
scanf("%d", &x);
if (x == 0) {
if ((*w2).shoupaishu || (*w2).zhuangbeishu || (*w2).pandingshu)return ((*w2).juese);
else {
printf("目标没有牌!\n");
return -2;
}
} else {
printf("目标错误!\n");
return -2;
}
} else return ((*w2).juese);
break;
case 202:
if ((*w1).juese) {
printf("请选择【顺手牵羊】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
scanf("%d", &x);
if (x == 0) {
if (((*w2).shoupaishu || (*w2).zhuangbeishu || (*w2).pandingshu) && ((*w1).juli[0] <= 1))return ((*w2).juese);
else {
printf("目标没有牌!\n");
return -2;
}
} else {
printf("目标错误!\n");
return -2;
}
} else {
if ((*w1).juli[0] <= 1)return ((*w2).juese);
else return -2;
}
break;
case 203:
return ((*w1).juese);
break;
case 204:
if ((*w1).juese) {
printf("请选择【决斗】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
scanf("%d", &x);
if (x == 0)return ((*w2).juese);
else {
printf("目标错误!\n");
return -2;
}
} else return ((*w2).juese);
break;
case 205:
int y;
if ((*w1).juese) {
printf("请选择【借刀杀人】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
scanf("%d", &x);
if (x != 0) {
printf("目标错误!\n");
return -2;
} else {
if (((*w2).zhuangbei[0]).leixing <= 300 || ((*w2).zhuangbei[0]).leixing >= 331) {
printf("目标装备区里没有武器!\n");
return -2;
} else {
printf("请选择【杀】的目标!\n提示:【杀】的目标必须在【借刀杀人】的目标的攻击范围之内!\n输入目标前的编号,以回车结束!\n0 玩家\n");
scanf("%d", &y);
if (y != 0) {
printf("目标错误!\n");
return -2;
} else {
if (((*w2).zhuangbei[0].changdu) < (*w2).juli[0]) {
printf("武器距离不够!\n");
return -2;
} else
return ((*w2).juese);
}
}
}
} else {
if (((*w2).zhuangbei[0]).leixing <= 300 || ((*w2).zhuangbei[0]).leixing >= 331)return -2;
else {
if (((*w2).zhuangbei[0].changdu) < (*w2).juli[0])return -2;
else return ((*w2).juese);
}
}
break;
case 206:
case 207:
return 99;
break;
case 208:
case 209:
return 100;
break;
case 251:
if ((*w1).juese) {
printf("请选择【乐不思蜀】的目标!\n输入目标前的编号,以回车结束!\n0 电脑1\n");
scanf("%d", &x);
if (x == 0) {
int i;
for (i = 0; i <= 2; i++) {
if ((*w2).pandingpai[i].leixing == 251)
i = -1;
break;
}
if (i == -1) {
printf("目标判定区里不能同时存在两张相同的延时类锦囊!\n");
return -2;
} else return ((*w2).juese);
} else {
printf("目标错误!\n");
return -2;
}
} else {
int i;
for (i = 0; i <= 2; i++) {
if ((*w2).pandingpai[i].leixing == 251)
i = -1;
break;
}
if (i == -1)return -2;
else return ((*w2).juese);
}
break;
case 252:
int i;
for (i = 0; i <= 2; i++) {
if ((*w1).pandingpai[i].leixing == 252)
i = -1;
break;
}
if (i == -1) {
if ((*w1).juese)printf("目标判定区里不能同时存在两张相同的延时类锦囊!\n");
return -2;
} else return ((*w1).juese);
break;
case 301:
case 302:
case 303:
case 304:
case 305:
case 306:
case 307:
case 308:
case 331:
case 361:
case 362:
case 363:
case 381:
case 382:
case 383:
return ((*w1).juese);
break;
default:
return -2;
break;
}
}
void Da1pai(wujiang *w1, wujiang*w2, pai qipaidui[104], int *qipaishu, int x) {
int i;
if ((x < 0 || x >= ((*w1).shoupaishu)) && x != 100)
printf("你的牌呢?!\n");
else {
switch (((*w1).shoupai)[x].leixing) {
case 101:
case 102:
case 103:
case 201:
case 202:
case 203:
case 204:
case 205:
case 206:
case 207:
case 208:
case 209:
case 210:
qipaidui[*qipaishu] = ((*w1).shoupai)[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
break;
case 251:
for (i = 1; i >= 0; i--)(*w2).pandingpai[i + 1] = (*w2).pandingpai[i];
(*w2).pandingpai[0] = (*w1).shoupai[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
((*w2).pandingshu)++;
break;
case 252:
for (i = 1; i >= 0; i--)(*w1).pandingpai[i + 1] = (*w1).pandingpai[i];
(*w1).pandingpai[0] = (*w1).shoupai[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
((*w1).pandingshu)++;
break;
case 301:
case 302:
case 303:
case 304:
case 305:
case 306:
case 307:
case 308:
if ((*w1).zhuangbei[0].leixing == -1)((*w1).zhuangbeishu)++;
else {
qipaidui[*qipaishu] = ((*w1).zhuangbei)[0];
(*qipaishu)++;
}
(*w1).zhuangbei[0] = (*w1).shoupai[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
break;
case 331:
if ((*w1).zhuangbei[1].leixing == -1)((*w1).zhuangbeishu)++;
else {
qipaidui[*qipaishu] = ((*w1).zhuangbei)[1];
(*qipaishu)++;
}
(*w1).zhuangbei[1] = (*w1).shoupai[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
break;
case 361:
case 362:
case 363:
if ((*w1).zhuangbei[2].leixing == -1)((*w1).zhuangbeishu)++;
else {
qipaidui[*qipaishu] = ((*w1).zhuangbei)[2];
(*qipaishu)++;
}
(*w1).zhuangbei[2] = (*w1).shoupai[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
break;
case 381:
case 382:
case 383:
if ((*w1).zhuangbei[3].leixing == -1)((*w1).zhuangbeishu)++;
else {
qipaidui[*qipaishu] = ((*w1).zhuangbei)[3];
(*qipaishu)++;
}
(*w1).zhuangbei[3] = (*w1).shoupai[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
break;
default:
break;
}
}
}
void Miaoshu(pai p, int juese, int duixiang) {
if (juese == 0)printf("电脑");
else if (juese == 1)printf("玩家");
else printf("角色参数错误!\n");
if (p.leixing <= 300 && p.leixing > 100) {
switch (duixiang) {
case -1:
printf("打出");
break;
case 0:
printf("对电脑使用");
break;
case 1:
printf("对玩家使用");
break;
case 99:
printf("使用");
break;
case 100:
printf("对所有人使用");
break;
default:
printf("对象参数错误\n");
break;
}
} else if (p.leixing >= 301 && p.leixing <= 400)
printf("装备");
else printf("你出的是什么东西?\n");
p.Kanpai();
if (!juese && (p.leixing == 101 || p.leixing == 204 || p.leixing == 205 || p.leixing == 207 || p.leixing == 208 || p.leixing == 209))printf("请响应!\n");
}
int Wuxie(pai *p, wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu, int a) {
int x;
if ((*w1).juese) {
printf("是否使用【无懈可击】响应?\n\n");
for (;;) {
(*w1).Kanshoupai();
printf("如果要使用【无懈可击】请输入手牌之前编号,不需要请输入“-1”,以回车结束!\n");
scanf("%d", &x);
if (x == -1) {
for (x = 0; x < ((*w2).shoupaishu); x++) {
if ((*w2).shoupai[x].leixing == 210) {
printf("电脑使用");
((*w2).shoupai)[x].Kanpai();
printf("对象是");
(*p).Kanpai();
(*p) = ((*w2).shoupai)[x];
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
a++;
break;
}
}
break;
} else if ((*w1).shoupai[x].leixing == 210) {
printf("玩家使用");
((*w1).shoupai)[x].Kanpai();
printf("对象是");
(*p).Kanpai();
(*p) = ((*w1).shoupai)[x];
qipaidui[*qipaishu] = ((*w1).shoupai)[x];
for (int i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
(*w1).Kanshoupai();
a++;
break;
} else printf("你确定你使用的是【无懈可击】?\n");
}
} else {
printf("是否使用【无懈可击】响应?\n");
for (;;) {
(*w2).Kanshoupai();
printf("如果要使用【无懈可击】请输入手牌之前编号,不需要请输入“-1”,以回车结束!\n");
scanf("%d", &x);
if (x == -1)break;
else if ((*w2).shoupai[x].leixing == 210) {
printf("玩家使用");
((*w2).shoupai)[x].Kanpai();
printf("对象是");
(*p).Kanpai();
(*p) = ((*w2).shoupai)[x];
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
(*w2).Kanshoupai();
a++;
break;
} else printf("你确定你使用的是【无懈可击】?\n");
}
}
return a;
}
int Qiutao(wujiang*w, pai qipaidui[104], int*qipaishu) {
int x;
if ((*w).juese) {
for (;;) {
printf("如果要使用【桃】请输入手牌之前的编号,不需要请输入“-1”,以回车结束!\n");
scanf("%d", &x);
if (x == -1) {
return -1;
break;
} else if ((*w).shoupai[x].leixing == 103) {
qipaidui[*qipaishu] = ((*w).shoupai)[x];
for (int i = x + 1; i <= ((*w).shoupaishu); i++)((*w).shoupai)[i - 1] = ((*w).shoupai)[i];
((*w).shoupaishu)--;
(*qipaishu)++;
return 0;
break;
} else printf("你确定你使用的是【桃】?\n");
}
} else {
for (x = 0; x < ((*w).shoupaishu); x++) {
if ((*w).shoupai[x].leixing == 103) {
qipaidui[*qipaishu] = ((*w).shoupai)[x];
for (int i = x + 1; i <= ((*w).shoupaishu); i++)((*w).shoupai)[i - 1] = ((*w).shoupai)[i];
((*w).shoupaishu)--;
(*qipaishu)++;
return 0;
break;
}
}
return -1;
}
}
int Binsi(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
if (((*w2).tili) > 0)return 0;
else {
int i;
if ((*w1).juese) {
for (;;) {
printf("电脑濒死,是否使用【桃】?\n");
i = Qiutao(w1, qipaidui, qipaishu);
if (i == 0)((*w2).tili)++;
if ((i == -1) || ((*w2).tili > 0))break;
}
if ((*w2).tili > 0)return 0;
else {
for (;;) {
i = Qiutao(w2, qipaidui, qipaishu);
if (i == 0)((*w2).tili)++;
if ((i == -1) || ((*w2).tili > 0))break;
}
if ((*w2).tili > 0)return 0;
else return -1;
}
} else {
for (;;) {
printf("玩家濒死,是否使用【桃】?\n");
i = Qiutao(w2, qipaidui, qipaishu);
if (i == 0)((*w2).tili)++;
if ((i == -1) || ((*w2).tili > 0))break;
}
if ((*w2).tili > 0)return 0;
else return -1;
}
}
}
int Shan(wujiang*w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
int x;
if ((*w2).juese) {
if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing != 303)) {
for (;;) {
int m;
printf("是否发动【八卦阵】防具效果?\n0 否\n1 是\n请输入选项之前的编号,以回车结束!\n");
scanf("%d", &m);
if (m == 1) {
Panding(paidui, paiduishu, qipaidui, qipaishu);
if (qipaidui[(*qipaishu) - 1].huase % 2) {
printf("【八卦阵】判定成功!\n");
return 0;
}
} else if (m == 0) {
printf("【八卦阵】判定失败!\n");
break;
} else printf("你确定你输入的是“0”或“1”?\n");
}
} else if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing == 303))printf("【青釭剑】锁定技被触发!\n");
for (;;) {
printf("请输入手牌之前的编号,或者输入“-1”放弃打出【闪】,以回车结束!\n");
scanf("%d", &x);
if (x == -1) {
return -1;
break;
} else if ((*w2).shoupai[x].leixing == 102) {
printf("玩家打出");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
return 0;
break;
} else printf("你确定你打出的是【闪】?\n");
}
} else {
if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing != 303)) {
Panding(paidui, paiduishu, qipaidui, qipaishu);
if (qipaidui[(*qipaishu) - 1].huase % 2) {
printf("【八卦阵】判定成功!\n");
return 0;
} else printf("【八卦阵】判定失败!\n");
} else if (((*w2).zhuangbei[1].leixing == 331) && ((*w1).zhuangbei[0].leixing == 303))printf("【青釭剑】锁定技被触发!\n");
int i;
for (x = 0; x < ((*w2).shoupaishu); x++) {
if ((*w2).shoupai[x].leixing == 102) {
printf("电脑打出");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
return 0;
break;
}
}
return -1;
}
}
int Sha(wujiang *w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
int x;
if ((*w2).juese) {
printf("请打出【闪】响应【杀】!否则你将受到1点伤害!\n");
x = Shan(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
if (x == -1) {
int i;
((*w2).tili)--;
printf("电脑对玩家造成1点伤害!\n");
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 306)) {
int i;
if (((*w1).shoupaishu) >= 2) {
printf("电脑弃掉:\n");
((*w1).shoupai)[0].Kanpai();
qipaidui[*qipaishu] = ((*w1).shoupai)[0];
for (i = 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
((*w1).shoupai)[0].Kanpai();
qipaidui[*qipaishu] = ((*w1).shoupai)[0];
for (i = 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
printf("发动【贯石斧】武器效果使【杀】造成伤害!\n");
((*w2).tili)--;
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
} else return 0;
} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 304)) {
int i;
for (x = 0; x < ((*w1).shoupaishu); x++) {
if ((*w1).shoupai[x].leixing == 101) {
printf("电脑发动【青龙偃月刀】效果对玩家使用");
((*w1).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w1).shoupai)[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
i = Sha(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
return i;
break;
}
}
return 0;
}
} else {
x = Shan(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
if (x == -1) {
if ((*w1).zhuangbei[0].leixing == 308) {
for (;;) {
printf("是否发动【麒麟弓】武器效果?\n0 否\n1 是\n");
scanf("%d", &x);
if (x == 1) {
if (((*w2).zhuangbei[2].leixing == -1) && ((*w2).zhuangbei[3].leixing == -1)) {
printf("电脑根本没有马,射你妹的马啊!\n");
break;
} else {
for (;;) {
printf("0 ");
((*w2).zhuangbei[2]).Kanpai();
printf("1 ");
((*w2).zhuangbei[3]).Kanpai();
printf("请选择要弃掉的马,输入之前的编号,以回车结束!\n");
scanf("%d", &x);
if ((x == 0) && ((*w2).zhuangbei[2].leixing != -1)) {
printf("你弃掉了电脑的");
((*w2).zhuangbei)[2].Kanpai();
qipaidui[*qipaishu] = ((*w2).zhuangbei)[2];
((*w2).zhuangbeishu)--;
(*qipaishu)++;
((*w2).zhuangbei)[2].leixing = -1;
((*w2).juli[0])++;
break;
} else if ((x == 1) && ((*w2).zhuangbei[3].leixing != -1)) {
printf("你弃掉了电脑的");
((*w2).zhuangbei)[3].Kanpai();
qipaidui[*qipaishu] = ((*w2).zhuangbei)[3];
((*w2).zhuangbeishu)--;
(*qipaishu)++;
((*w2).zhuangbei)[3].leixing = -1;
((*w1).juli[0])--;
break;
} else printf("射你妹的马!");
}
break;
}
} else if (x == 0)break;
else printf("键盘上的“0”和“1”被你吃了吗?\n");
}
}
int i;
((*w2).tili)--;
printf("玩家对电脑造成1点伤害!\n");
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 306)) {
for (;;) {
printf("是否发动【贯石斧】武器效果?\n0 否\n1 是\n");
scanf("%d", &x);
if (x == 1) {
int i;
if ((*w1).shoupaishu + (*w1).zhuangbeishu <= 2) {
printf("你除了【贯石斧】以外连2张牌都没有,发动你妹的效果!\n");
break;
} else {
printf("请分别弃掉两张牌!\n");
for (i = 0; i <= 2; i++) {
for (;;) {
printf("请选择区域:\n0 手牌\n1 装备\n");
scanf("%d", &x);
if (x == 0 && ((*w1).shoupaishu == 0))printf("你根本没有手牌,弃你妹啊!\n");
else if (x == 1 && ((*w1).zhuangbeishu == 1))printf("你根本没有别的装备,弃你妹啊!\n");
else if (x >= 0 && x <= 1)break;
else printf("键盘上的“0”和“1”被你吃了吗?\n");
}
if (x == 0) {
for (;;) {
(*w1).Kanshoupai();
printf("弃牌请输入手牌之前的编号,以回车结束!\n");
scanf("%d", &x);
if (x >= 0 && x < ((*w1).shoupaishu))break;
else printf("弃你妹的手牌!\n");
}
printf("你弃掉了");
((*w1).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w1).shoupai)[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
} else {
for (;;) {
(*w1).Kanzhuangbei();
printf("请输入装备之前的编号,以回车键结束!\n");
scanf("%d", &x);
if ((((*w1).zhuangbei[x]).leixing != -1) && (x >= 0) && (x <= 3)) {
printf("你弃掉了");
((*w1).zhuangbei)[x].Kanpai();
qipaidui[*qipaishu] = ((*w1).zhuangbei)[x];
((*w1).zhuangbeishu)--;
(*qipaishu)++;
((*w1).zhuangbei)[x].leixing = -1;
break;
} else printf("弃你妹的装备!\n");
}
}
}
}
printf("玩家发动【贯石斧】武器效果使【杀】造成伤害!\n");
((*w2).tili)--;
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
break;
} else if (x == 0)break;
else printf("键盘上的“0”和“1”被你吃了吗?\n");
}
} else if (x == 0 && ((*w1).zhuangbei[0].leixing == 304)) {
for (;;) {
printf("是否发动【青龙偃月刀】武器效果?\n0 否\n1 是\n");
scanf("%d", &x);
if (x == 1) {
for (;;) {
printf("请对电脑使用一张【杀】!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
(*w1).Kanshoupai();
scanf("%d", &x);
if (x == -1) {
return 0;
break;
} else if ((*w1).shoupai[x].leixing == 101) {
int i;
printf("玩家对电脑使用");
((*w1).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w1).shoupai)[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
i = Sha(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
return i;
break;
} else printf("你确定你打出的是【杀】?\n");
}
} else if (x == 0) {
return 0;
break;
} else printf("你确定你输入的是“0”或“1”?\n");
}
} else return 0;
}
return 0;
}
void Tao(wujiang*w1) {
((*w1).tili)++;
if ((*w1).juese)printf("玩家");
else printf("电脑");
printf("恢复了1点体力!\n");
if (((*w1).tili) > ((*w1).tilishangxian))printf("你被撑死了!\n");
}
void Chai(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
int i, x, y;
if ((*w1).juese) {
for (;;) {
if ((*w2).shoupaishu + (*w2).zhuangbeishu + (*w2).pandingshu == 0) {
printf("对方空城,拆你妹啊!\n");
break;
} else {
printf("请选择想拆的区域,输入选项之前的编号,以回车结束!\n0 手牌\n1 装备区\n2 判定区\n");
scanf("%d", &x);
if (x == 0 && ((*w2).shoupaishu == 0))printf("你拆掉了一张空气!\n");
else if (x == 1 && ((*w2).zhuangbeishu == 0))printf("你拆掉了一张空气!\n");
else if (x == 2 && ((*w2).pandingshu == 0))printf("你拆掉了一张空气!\n");
else if (x >= 0 && x <= 2)break;
else printf("你拆掉了太空区里的一张牌!\n");
}
}
switch (x) {
case 0:
srand((unsigned)time(NULL));
y = rand() % ((*w2).shoupaishu);
printf("你弃掉了电脑的");
((*w2).shoupai)[y].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[y];
for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
break;
case 1:
for (;;) {
(*w2).Kanzhuangbei();
printf("请输入装备之前的编号,以回车键结束!\n");
scanf("%d", &y);
if ((((*w2).zhuangbei[y]).leixing != -1) && (y >= 0) && (y <= 3)) {
printf("你弃掉了电脑的");
((*w2).zhuangbei)[y].Kanpai();
qipaidui[*qipaishu] = ((*w2).zhuangbei)[y];
((*w2).zhuangbeishu)--;
(*qipaishu)++;
((*w2).zhuangbei)[y].leixing = -1;
if (!y)((*w2).zhuangbei)[y].changdu = 1;
else if (y == 2)((*w2).juli[0])++;
else if (y == 3)((*w1).juli[0])--;
break;
} else printf("你弃掉了一张空气!\n");
}
break;
case 2:
for (;;) {
(*w2).Kanpandingpai();
printf("请输入判定牌之前的编号,以回车键结束!\n");
scanf("%d", &y);
if ((*w2).pandingpai[y].leixing != -1) {
printf("你弃掉了电脑的");
((*w2).pandingpai)[y].Kanpai();
qipaidui[*qipaishu] = ((*w2).pandingpai)[y];
((*w2).pandingshu)--;
(*qipaishu)++;
((*w2).pandingpai)[y].leixing = -1;
break;
} else printf("你弃掉了一张空气!\n");
}
break;
default:
break;
}
} else {
if ((*w2).zhuangbeishu) {
if ((*w2).zhuangbei[1].leixing != -1) {
printf("电脑弃掉了玩家的");
((*w2).zhuangbei)[1].Kanpai();
qipaidui[*qipaishu] = ((*w2).zhuangbei)[1];
((*w2).zhuangbeishu)--;
(*qipaishu)++;
((*w2).zhuangbei)[1].leixing = -1;
} else if ((*w2).zhuangbei[3].leixing != -1) {
printf("电脑弃掉了玩家的");
((*w2).zhuangbei)[3].Kanpai();
qipaidui[*qipaishu] = ((*w2).zhuangbei)[3];
((*w2).zhuangbeishu)--;
(*qipaishu)++;
((*w2).zhuangbei)[3].leixing = -1;
((*w1).juli[0])--;
} else if ((*w2).zhuangbei[0].leixing != -1) {
printf("电脑弃掉了玩家的");
((*w2).zhuangbei)[0].Kanpai();
qipaidui[*qipaishu] = ((*w2).zhuangbei)[0];
((*w2).zhuangbeishu)--;
(*qipaishu)++;
((*w2).zhuangbei)[0].leixing = -1;
((*w2).zhuangbei)[0].changdu = 1;
} else {
printf("电脑弃掉了玩家的");
((*w2).zhuangbei)[2].Kanpai();
qipaidui[*qipaishu] = ((*w2).zhuangbei)[2];
((*w2).zhuangbeishu)--;
(*qipaishu)++;
((*w2).zhuangbei)[2].leixing = -1;
((*w2).juli[0])++;
}
} else {
srand((unsigned)time(NULL));
y = rand() % ((*w2).shoupaishu);
printf("电脑弃掉了玩家的手牌");
((*w2).shoupai)[y].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[y];
for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
}
}
}
void Qian(wujiang *w1, wujiang *w2) {
int i, x, y;
if ((*w1).juese) {
for (;;) {
if ((*w2).shoupaishu + (*w2).zhuangbeishu + (*w2).pandingshu == 0) {
printf("对方空城啦!你牵走了一张寂寞!\n");
break;
} else {
printf("请选择想牵的区域,输入选项之前的编号,以回车结束!\n0 手牌\n1 装备区\n2 判定区\n");
scanf("%d", &x);
if (x == 0 && ((*w2).shoupaishu == 0))printf("你牵走了一张空气!\n");
else if (x == 1 && ((*w2).zhuangbeishu == 0))printf("你牵走了一张空气!\n");
else if (x == 2 && ((*w2).pandingshu == 0))printf("你牵走了一张空气!\n");
else if (x >= 0 && x <= 2)break;
else printf("你牵走了太空区里的一张牌!\n");
}
}
switch (x) {
case 0:
srand((unsigned)time(NULL));
y = rand() % ((*w2).shoupaishu);
printf("你牵走了电脑的");
((*w2).shoupai)[y].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).shoupai)[y];
for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
((*w1).shoupaishu)++;
break;
case 1:
for (;;) {
(*w2).Kanzhuangbei();
printf("请输入装备之前的编号,以回车键结束!\n");
scanf("%d", &y);
if ((((*w2).zhuangbei[y]).leixing != -1) && (y >= 0) && (y <= 3)) {
printf("你牵走了电脑的");
((*w2).zhuangbei)[y].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[y];
((*w2).zhuangbeishu)--;
((*w1).shoupaishu)++;
((*w2).zhuangbei)[y].leixing = -1;
if (!y)((*w2).zhuangbei[y]).changdu = 1;
else if (y == 2)((*w2).juli[0])++;
else if (y == 3)((*w1).juli[0])--;
break;
} else printf("你弃掉了一张空气!\n");
}
break;
case 2:
for (;;) {
(*w2).Kanpandingpai();
printf("请输入判定牌之前的编号,以回车键结束!\n");
scanf("%d", &y);
if ((*w2).pandingpai[y].leixing != -1) {
printf("你牵走了电脑的");
((*w2).pandingpai)[y].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).pandingpai)[y];
((*w2).pandingshu)--;
((*w1).shoupaishu)++;
((*w2).pandingpai)[y].leixing = -1;
break;
} else printf("你牵走了一张空气!\n");
}
break;
default:
break;
}
} else {
if ((*w2).zhuangbeishu) {
if ((*w2).zhuangbei[1].leixing != -1) {
printf("电脑牵走了玩家的");
((*w2).zhuangbei)[1].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[1];
((*w2).zhuangbeishu)--;
((*w1).shoupaishu)++;
((*w2).zhuangbei)[1].leixing = -1;
} else if ((*w2).zhuangbei[3].leixing != -1) {
printf("电脑牵走了玩家的");
((*w2).zhuangbei)[3].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[3];
((*w2).zhuangbeishu)--;
((*w1).shoupaishu)++;
((*w2).zhuangbei)[3].leixing = -1;
((*w1).juli[0])--;
} else if ((*w2).zhuangbei[0].leixing != -1) {
printf("电脑牵走了玩家的");
((*w2).zhuangbei)[0].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[0];
((*w2).zhuangbeishu)--;
((*w1).shoupaishu)++;
((*w2).zhuangbei)[0].leixing = -1;
((*w2).zhuangbei)[0].changdu = 1;
} else {
printf("电脑牵走了玩家的");
((*w2).zhuangbei)[2].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[2];
((*w2).zhuangbeishu)--;
((*w1).shoupaishu)++;
((*w2).zhuangbei)[2].leixing = -1;
((*w2).juli[0])--;
}
} else {
srand((unsigned)time(NULL));
y = rand() % ((*w2).shoupaishu);
printf("电脑牵走了玩家的手牌");
((*w2).shoupai)[y].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).shoupai)[y];
for (i = y + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
((*w1).shoupaishu)++;
}
}
}
void Wuzhong(wujiang*w1, pai A[104], int *x, pai B[104], int*y) {
Mopai(&((*w1).shoupaishu), (*w1).shoupai, A, x, B, y, (*w1).juese);
}
int Juedou(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
int i, j, x;
if ((*w1).juese) {
for (;;) {
j = 0;
for (x = 0; x < ((*w2).shoupaishu); x++) {
if ((*w2).shoupai[x].leixing == 101) {
printf("电脑打出");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
j = 1;
break;
}
}
if (!j) {
printf("玩家对电脑造成1点伤害!\n");
((*w2).tili)--;
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
break;
}
j = 0;
for (;;) {
printf("请打出一张【杀】响应【决斗】,否则你将受到1点伤害!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
if (((*w1).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
(*w1).Kanshoupai();
scanf("%d", &x);
if (x == -1) {
int i;
((*w1).tili)--;
printf("电脑对玩家造成1点伤害!\n");
i = Binsi(w2, w1, qipaidui, qipaishu);
return i;
break;
} else if (((*w1).zhuangbei[0].leixing == 305) && x == 100) {
pai p = Zhangba(w1, qipaidui, qipaishu);
p.paifu = -1;
printf("打出!\n");
j = 1;
break;
} else if ((*w1).shoupai[x].leixing == 101) {
printf("玩家打出");
((*w1).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w1).shoupai)[x];
for (i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
j = 1;
break;
} else printf("你确定你打出的是【杀】?\n");
}
}
} else {
for (;;) {
j = 0;
for (;;) {
printf("请打出一张【杀】响应【决斗】,否则你将受到1点伤害!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
if (((*w1).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
(*w2).Kanshoupai();
scanf("%d", &x);
if (x == -1) {
int i;
((*w2).tili)--;
printf("电脑对玩家造成1点伤害!\n");
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
break;
} else if (((*w2).zhuangbei[0].leixing == 305) && x == 100) {
pai p = Zhangba(w2, qipaidui, qipaishu);
p.paifu = -1;
printf("打出!\n");
j = 1;
break;
} else if ((*w2).shoupai[x].leixing == 101) {
printf("玩家打出");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
j = 1;
break;
} else printf("你确定你打出的是【杀】?\n");
}
j = 0;
for (x = 0; x < ((*w1).shoupaishu); x++) {
if ((*w1).shoupai[x].leixing == 101) {
printf("电脑打出");
((*w1).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w1).shoupai)[x];
for (int i = x + 1; i <= ((*w1).shoupaishu); i++)((*w1).shoupai)[i - 1] = ((*w1).shoupai)[i];
((*w1).shoupaishu)--;
(*qipaishu)++;
j = 1;
break;
}
}
if (!j) {
printf("玩家对电脑造成1点伤害!\n");
((*w2).tili)--;
i = Binsi(w2, w1, qipaidui, qipaishu);
return i;
break;
}
}
}
}
int Jiedao(wujiang*w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
int i, j = 0, x;
if ((*w1).juese) {
for (x = 0; x < ((*w2).shoupaishu); x++) {
if ((*w2).shoupai[x].leixing == 101) {
printf("电脑对玩家使用");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
j = 1;
break;
}
}
if (j) {
i = Sha(w2, w1, paidui, paiduishu, qipaidui, qipaishu);
return i;
printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
} else {
printf("电脑放弃使用【杀】,玩家获得电脑的武器");
(*w2).zhuangbei[0].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[0];
((*w2).zhuangbeishu)--;
((*w1).shoupaishu)++;
((*w2).zhuangbei)[0].leixing = -1;
((*w2).zhuangbei)[0].changdu = 1;
(*w1).Kanshoupai();
return 0;
}
} else {
for (;;) {
printf("请对电脑使用一张【杀】,否则电脑将获得你的武器!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
if (((*w2).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
(*w2).Kanshoupai();
scanf("%d", &x);
if (x == -1)break;
else if (((*w2).zhuangbei[0].leixing == 305) && x == 100) {
pai p = Zhangba(w2, qipaidui, qipaishu);
p.paifu = -1;
printf("使用!\n");
j = 1;
break;
} else if ((*w2).shoupai[x].leixing == 101) {
printf("玩家对电脑使用");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
j = 1;
break;
} else printf("你确定你使用的是【杀】?\n");
}
if (j) {
i = Sha(w2, w1, paidui, paiduishu, qipaidui, qipaishu);
return i;
printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
} else {
printf("玩家放弃使用【杀】,电脑获得玩家的武器");
((*w2).zhuangbei)[0].Kanpai();
(*w1).shoupai[(*w1).shoupaishu] = ((*w2).zhuangbei)[0];
((*w2).zhuangbeishu)--;
((*w1).shoupaishu)++;
((*w2).zhuangbei)[0].leixing = -1;
((*w2).zhuangbei)[0].changdu = 1;
return 0;
}
}
}
void Taoyuan(wujiang*w) {
if ((*w).tili < (*w).tilishangxian) {
((*w).tili)++;
if ((*w).juese)printf("玩家");
else printf("电脑");
printf("恢复1点体力!\n");
}
}
void Kaipai(pai paidui[104], int* paiduishu, int renshu, pai wugu[10]) {
int i;
printf("五谷丰登开牌:\n");
for (i = 1; i <= renshu; i++) {
wugu[i - 1] = paidui[104 - (*paiduishu)];
(*paiduishu)--;
printf("%d ", i - 1);
wugu[i - 1].Kanpai();
}
}
void Qupai(pai wugu[10], wujiang*w) {
int i, x;
printf("五谷丰登开牌:\n");
for (i = 0; (wugu[i].leixing) != -1; i++) {
printf("%d ", i);
wugu[i].Kanpai();
}
if ((*w).juese) {
for (;;) {
printf("请选择你想要的卡牌,输入卡牌之前的编号,以回车结束!\n");
scanf("%d", &x);
if (wugu[x].leixing != -1) {
printf("玩家选择");
wugu[x].Kanpai();
(*w).shoupai[(*w).shoupaishu] = wugu[x];
((*w).shoupaishu)++;
for (i = x + 1; i <= 9; i++)wugu[i - 1] = wugu[i];
wugu[9].leixing = -1;
break;
}
printf("你选择了一张空气加入手牌!");
}
} else {
printf("电脑选择");
wugu[0].Kanpai();
(*w).shoupai[(*w).shoupaishu] = wugu[0];
((*w).shoupaishu)++;
for (i = 1; i <= 9; i++)wugu[i - 1] = wugu[i];
wugu[9].leixing = -1;
}
}
void Rengpai(pai wugu[10], pai qipaidui[104], int*qipaishu) {
int i;
for (i = 0; wugu[i].leixing != -1; i++) {
qipaidui[*qipaishu] = wugu[i];
(*qipaishu)++;
wugu[i].leixing = -1;
}
}
int Nanman(wujiang*w1, wujiang*w2, pai qipaidui[104], int*qipaishu) {
int i, x;
if ((*w1).juese) {
for (x = 0; x < ((*w2).shoupaishu); x++) {
if ((*w2).shoupai[x].leixing == 101) {
printf("电脑打出");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (int i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
return 0;
break;
}
}
printf("玩家对电脑造成1点伤害!\n");
((*w2).tili)--;
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
} else {
for (;;) {
printf("请打出一张【杀】响应【南蛮入侵】,否则你将受到1点伤害!\n请输入手牌之前的编号,或者输入“-1”放弃出【杀】,以回车结束!\n");
if (((*w2).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
(*w2).Kanshoupai();
scanf("%d", &x);
if (x == -1) {
int i;
((*w2).tili)--;
printf("电脑对玩家造成1点伤害!\n");
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
break;
} else if (((*w2).zhuangbei[0].leixing == 305) && x == 100) {
pai p = Zhangba(w2, qipaidui, qipaishu);
p.paifu = -1;
printf("使用!\n");
return 0;
break;
} else if ((*w2).shoupai[x].leixing == 101) {
printf("玩家打出");
((*w2).shoupai)[x].Kanpai();
qipaidui[*qipaishu] = ((*w2).shoupai)[x];
for (i = x + 1; i <= ((*w2).shoupaishu); i++)((*w2).shoupai)[i - 1] = ((*w2).shoupai)[i];
((*w2).shoupaishu)--;
(*qipaishu)++;
return 0;
break;
} else printf("你确定你打出的是【杀】?\n");
}
}
}
int Wanjian(wujiang*w1, wujiang*w2, pai paidui[104], int*paiduishu, pai qipaidui[104], int*qipaishu) {
int i;
i = Shan(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
if (i == -1) {
i = Binsi(w1, w2, qipaidui, qipaishu);
return i;
} else return 0;
}
int Chupai(pai paidui[104], pai qipaidui[104], int *paiduishu, int*qipaishu, wujiang*w1, wujiang*w2, pai yuanshipaidui[2][4][13]) {
pai p1;
int sha = 1;
int y = -1, i, t = ((*w1).shoupaishu) - 1;
for (;; t--) {
if ((*w1).juese) {
printf("\n电脑当前手牌数:%d\n", ((*w2).shoupaishu));
(*w2).Kanzhuangbei();
(*w1).Kanshoupai();
(*w1).Kanzhuangbei();
}
int j = 0;
if ((*w1).juese && ((*w1).zhuangbei[0].leixing == 305))printf("如果想发动【丈八蛇矛】效果,请输入“100”,以回车结束!\n");
y = Xuanpai(w1, t);
p1 = Panpai(w1, &sha, y, qipaidui, qipaishu);
if ((p1).leixing == -1)break;
else if ((p1).leixing == 0)continue;
else {
int duixiang;
duixiang = Mubiao(p1, w1, w2, &sha);
if (duixiang == -2)continue;
else {
Da1pai(w1, w2, qipaidui, qipaishu, y);
Miaoshu(p1, ((*w1).juese), duixiang);
if (!((*w1).juese)) {
printf("\n电脑当前手牌数:%d\n", ((*w1).shoupaishu));
(*w1).Kanzhuangbei();
(*w2).Kanshoupai();
(*w2).Kanzhuangbei();
}
switch (p1.leixing) {
case 101:
i = Sha(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
if (i == -1) {
return -1;
break;
}
if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
break;
case 103:
Tao(w1);
break;
case 201:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2))Chai(w1, w2, qipaidui, qipaishu);
else;
if ((*w1).juese)(*w1).Kanshoupai();
break;
case 202:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2))Qian(w1, w2);
else;
if ((*w1).juese)(*w1).Kanshoupai();
break;
case 203:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2))Wuzhong(w1, paidui, paiduishu, qipaidui, qipaishu);
else;
break;
case 204:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2)) {
i = Juedou(w1, w2, qipaidui, qipaishu);
if (i == -1)return -1;
if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
}
break;
case 205:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2)) {
i = Jiedao(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
if (i == -1)return -1;
if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
}
break;
case 206:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2))Taoyuan(w1);
j = 0;
for (;;) {
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2))Taoyuan(w2);
break;
case 207:
pai wugu[10];
for (i = 1; i <= 10; i++)wugu[i - 1].leixing = -1;
Kaipai(paidui, paiduishu, 2, wugu);
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2))Qupai(wugu, w1);
for (;;) {
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2))Qupai(wugu, w2);
Rengpai(wugu, qipaidui, qipaishu);
printf("弃牌数:%d\n", *qipaishu);
break;
case 208:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2)) {
i = Nanman(w1, w2, qipaidui, qipaishu);
if (i == -1)return -1;
if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
}
break;
case 209:
for (;;) {
i = Wuxie(&p1, w1, w2, qipaidui, qipaishu, 0);
if (!i)break;
j++;
i = Wuxie(&p1, w2, w1, qipaidui, qipaishu, 0);
if (!i)break;
j++;
}
if (!(j % 2)) {
i = Wanjian(w1, w2, paidui, paiduishu, qipaidui, qipaishu);
if (i == -1)return -1;
if ((*w1).juese)printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w1).tili, (*w1).tilishangxian, (*w2).tili, (*w2).tilishangxian);
else printf("玩家当前体力值:%d/%d\n电脑当前体力值:%d/%d\n", (*w2).tili, (*w2).tilishangxian, (*w1).tili, (*w1).tilishangxian);
}
break;
case 361:
case 362:
case 363:
((*w1).juli[0])--;
break;
case 381:
case 382:
case 383:
((*w2).juli[0])++;
break;
default:
break;
}
printf("\n");
}
}
}
return 0;
}
void Qipai(pai shoupai[20], int *shoupaishu, pai qipaidui[104], int *qipaishu, int juese, int *shoupaishangxian) {
int x;
if ((*shoupaishu) > (*shoupaishangxian)) {
if (juese != 1 && juese != 0)printf("身份参数错误!");
int q = (*shoupaishu) - (*shoupaishangxian);
int i, j;
for (j = 1; j <= q; j++) {
for (;;) {
if (juese) {
printf("弃牌请输入手牌之前的编号,以回车结束!\n注:一次只能弃一张牌\n");
printf("手牌数:%d\n", *shoupaishu);
scanf("%d", &x);
if (x >= 0 && x < (*shoupaishu))break;
else printf("你弃掉了一张空气!\n");
} else {
srand((unsigned)time(NULL));
x = rand() % (*shoupaishu);
break;
}
}
qipaidui[*qipaishu] = shoupai[x];
for (i = x + 1; i <= (*shoupaishu); i++)shoupai[i - 1] = shoupai[i];
(*shoupaishu)--;
if (juese)printf("弃牌阶段玩家弃置");
else printf("弃牌阶段电脑弃置");
qipaidui[*qipaishu].Kanpai();
(*qipaishu)++;
int m;
if (juese) {
printf("玩家当前手牌:\n");
for (m = 0; m <= (*shoupaishu - 1); m++) {
printf("%d ", m);
(shoupai[m]).Kanpai();
}
}
printf("弃牌堆:%d\n", *qipaishu);
}
}
}
int Huihe(pai A[104], pai B[104], int *x, int *y, pai yuanshipaidui[2][4][13], wujiang *w1, wujiang *w2) {
printf("\n回合开始阶段……\n");
switch ((*w1).huihekaishi) {
case 0:
break;
default:
printf("回合开始阶段参数错误!\n");
break;
}
printf("判定阶段……\n");
int K = 0;
if ((*w1).pandingshu > 0) {
int i, j;
for (; (*w1).pandingshu;) {
switch ((*w1).pandingpai[0].leixing) {
case 251:
printf("【乐不思蜀】开始判定……\n");
break;
case 252:
printf("【闪电】开始判定……\n");
break;
default:
printf("【??】开始判定……\n");
break;
}
j = 0;
pai p = ((*w1).pandingpai[0]);
for (;;) { //在判定之前询问【无懈】
i = Wuxie(&p, w2, w1, B, y, 0);
if (!i)break;
j++;
i = Wuxie(&p, w1, w2, B, y, 0);
if (!i)break;
j++;
}
switch ((*w1).pandingpai[0].leixing) {
case 251:
if (!(j % 2)) {
printf("【乐不思蜀】的判定牌是:");
Panding(A, x, B, y);
if ((B[(*y) - 1].huase) != 1) {
printf("【乐不思蜀】判定成功!\n");
if ((*w1).juese)printf("玩家");
else printf("电脑");
printf("跳过出牌阶段!\n");
K = -1;
} else printf("【乐不思蜀】判定失败!\n");
}
B[*y] = (*w1).pandingpai[0];
((*w1).pandingshu)--;
(*w1).pandingpai[0] = (*w1).pandingpai[1];
(*w1).pandingpai[1] = (*w1).pandingpai[2];
(*w1).pandingpai[2].leixing = -1;
(*y)++;
break;
case 252:
if (!(j % 2)) {
printf("【闪电】的判定牌是:");
Panding(A, x, B, y);
if ((B[(*y) - 1].huase == 0) && (B[(*y) - 1].dianshu >= 1) && (B[(*y) - 1].dianshu <= 8)) {
printf("【闪电】判定成功!\n");
if ((*w1).juese)printf("玩家");
else printf("电脑");
printf("受到3点雷电伤害!");
((*w1).tili) = ((*w1).tili) - 3;
i = Binsi(w2, w1, B, y);
B[*y] = (*w1).pandingpai[0];
((*w1).pandingshu)--;
(*w1).pandingpai[0] = (*w1).pandingpai[1];
(*w1).pandingpai[1] = (*w1).pandingpai[2];
(*w1).pandingpai[2].leixing = -1;
(*y)++;
if (i == -1)return -1;
} else {
printf("【闪电】判定失败!\n");
(*w2).pandingpai[2] = (*w2).pandingpai[1];
(*w2).pandingpai[1] = (*w2).pandingpai[0];
(*w2).pandingpai[0] = (*w1).pandingpai[0];
(*w1).pandingpai[0] = (*w1).pandingpai[1];
(*w1).pandingpai[1] = (*w1).pandingpai[2];
(*w1).pandingpai[2].leixing = -1;
((*w1).pandingshu)--;
((*w2).pandingshu)++;
}
break;
}
default:
printf("判定牌错误!");
}
printf("弃牌数:%d\n", *y);
}
} else if (!((*w1).pandingshu));
else printf("判定阶段参数错误!\n");
printf("摸牌阶段……\n");
switch ((*w1).mopai) {
case 0:
Mopai(&((*w1).shoupaishu), (*w1).shoupai, A, x, B, y, (*w1).juese);
break;
case -1:
break;
default:
printf("摸牌阶段参数错误!\n");
break;
}
if (K == -1)goto M;
printf("出牌阶段……\n");
switch ((*w1).chupai) {
case 0: {
int i;
i = Chupai(A, B, x, y, w1, w2, yuanshipaidui);
if (i == -1) {
return -1;
break;
} else break;
}
case -1:
break;
default:
printf("出牌阶段参数错误!\n");
break;
}
M:
printf("弃牌阶段……\n");
switch ((*w1).qipai) {
case 0:
Qipai((*w1).shoupai, &((*w1).shoupaishu), B, y, (*w1).juese, &((*w1).tili));
break;
default:
printf("弃牌阶段参数错误!\n");
break;
}
printf("回合结束阶段……\n");
switch ((*w1).huihejieshu) {
case 0:
break;
default:
printf("回合结束阶段参数错误!\n");
break;
}
return 0;
}
int main() {
void Kanshoupai(pai p);
pai yuanshipaidui[2][4][13], qipaidui[104], paidui[104];
wujiang wanjia, com;
com.tili = wanjia.tili = 5;
com.tilishangxian = wanjia.tilishangxian = 5;
com.huihekaishi = wanjia.huihekaishi = 0;
com.panding = wanjia.panding = 0;
com.mopai = wanjia.mopai = 0;
com.chupai = wanjia.chupai = 0;
com.qipai = wanjia.qipai = 0;
com.huihejieshu = wanjia.huihejieshu = 0;
com.shoupaishu = wanjia.shoupaishu = 0;
com.pandingshu = wanjia.pandingshu = 0;
com.zhuangbeishu = wanjia.zhuangbeishu = 0;
com.juese = 0;
wanjia.juese = 1;
pai p;
p.leixing = -1;
com.zhuangbei[0] = com.zhuangbei[1] = com.zhuangbei[2] = com.zhuangbei[3] = wanjia.zhuangbei[0] = wanjia.zhuangbei[1] = wanjia.zhuangbei[2] = wanjia.zhuangbei[3] = p;
com.zhuangbei[0].changdu = wanjia.zhuangbei[0].changdu = 1;
com.pandingpai[0] = com.pandingpai[1] = com.pandingpai[2] = wanjia.pandingpai[0] = wanjia.pandingpai[1] = wanjia.pandingpai[2] = p;
com.juli[0] = wanjia.juli[0] = 1;
int a, b, c;
for (a = 0; a <= 1; a++) {
for (b = 0; b <= 3; b++) {
for (c = 0; c <= 12; c++) {
yuanshipaidui[a][b][c].paifu = a;
yuanshipaidui[a][b][c].huase = b;
yuanshipaidui[a][b][c].dianshu = c;
}
}
}
yuanshipaidui[0][0][0].leixing = 204;
yuanshipaidui[0][0][1].leixing = 331;
yuanshipaidui[0][0][2].leixing = 201;
yuanshipaidui[0][0][3].leixing = 201;
yuanshipaidui[0][0][4].leixing = 304;
yuanshipaidui[0][0][4].changdu = 3;
yuanshipaidui[0][0][5].leixing = 251;
yuanshipaidui[0][0][6].leixing = 101;
yuanshipaidui[0][0][7].leixing = 101;
yuanshipaidui[0][0][8].leixing = 101;
yuanshipaidui[0][0][9].leixing = 101;
yuanshipaidui[0][0][10].leixing = 202;
yuanshipaidui[0][0][11].leixing = 201;
yuanshipaidui[0][0][12].leixing = 208;
yuanshipaidui[0][1][0].leixing = 209;
yuanshipaidui[0][1][1].leixing = 102;
yuanshipaidui[0][1][2].leixing = 103;
yuanshipaidui[0][1][3].leixing = 103;
yuanshipaidui[0][1][4].leixing = 308;
yuanshipaidui[0][1][4].changdu = 5;
yuanshipaidui[0][1][5].leixing = 103;
yuanshipaidui[0][1][6].leixing = 103;
yuanshipaidui[0][1][7].leixing = 103;
yuanshipaidui[0][1][8].leixing = 103;
yuanshipaidui[0][1][9].leixing = 101;
yuanshipaidui[0][1][10].leixing = 101;
yuanshipaidui[0][1][11].leixing = 103;
yuanshipaidui[0][1][12].leixing = 102;
yuanshipaidui[0][2][0].leixing = 204;
yuanshipaidui[0][2][1].leixing = 101;
yuanshipaidui[0][2][2].leixing = 101;
yuanshipaidui[0][2][3].leixing = 101;
yuanshipaidui[0][2][4].leixing = 101;
yuanshipaidui[0][2][5].leixing = 101;
yuanshipaidui[0][2][6].leixing = 101;
yuanshipaidui[0][2][7].leixing = 101;
yuanshipaidui[0][2][8].leixing = 101;
yuanshipaidui[0][2][9].leixing = 101;
yuanshipaidui[0][2][10].leixing = 101;
yuanshipaidui[0][2][11].leixing = 205;
yuanshipaidui[0][2][12].leixing = 205;
yuanshipaidui[0][3][0].leixing = 204;
yuanshipaidui[0][3][1].leixing = 102;
yuanshipaidui[0][3][2].leixing = 102;
yuanshipaidui[0][3][3].leixing = 102;
yuanshipaidui[0][3][4].leixing = 102;
yuanshipaidui[0][3][5].leixing = 101;
yuanshipaidui[0][3][6].leixing = 101;
yuanshipaidui[0][3][7].leixing = 101;
yuanshipaidui[0][3][8].leixing = 101;
yuanshipaidui[0][3][9].leixing = 101;
yuanshipaidui[0][3][10].leixing = 102;
yuanshipaidui[0][3][11].leixing = 103;
yuanshipaidui[0][3][12].leixing = 101;
yuanshipaidui[1][0][0].leixing = 252;
yuanshipaidui[1][0][1].leixing = 302;
yuanshipaidui[1][0][1].changdu = 2;
yuanshipaidui[1][0][2].leixing = 202;
yuanshipaidui[1][0][3].leixing = 202;
yuanshipaidui[1][0][4].leixing = 383;
yuanshipaidui[1][0][5].leixing = 303;
yuanshipaidui[1][0][5].changdu = 2;
yuanshipaidui[1][0][6].leixing = 208;
yuanshipaidui[1][0][7].leixing = 101;
yuanshipaidui[1][0][8].leixing = 101;
yuanshipaidui[1][0][9].leixing = 101;
yuanshipaidui[1][0][10].leixing = 210;
yuanshipaidui[1][0][11].leixing = 305;
yuanshipaidui[1][0][11].changdu = 3;
yuanshipaidui[1][0][12].leixing = 362;
yuanshipaidui[1][1][0].leixing = 206;
yuanshipaidui[1][1][1].leixing = 102;
yuanshipaidui[1][1][2].leixing = 207;
yuanshipaidui[1][1][3].leixing = 207;
yuanshipaidui[1][1][4].leixing = 361;
yuanshipaidui[1][1][5].leixing = 251;
yuanshipaidui[1][1][6].leixing = 203;
yuanshipaidui[1][1][7].leixing = 203;
yuanshipaidui[1][1][8].leixing = 203;
yuanshipaidui[1][1][9].leixing = 101;
yuanshipaidui[1][1][10].leixing = 203;
yuanshipaidui[1][1][11].leixing = 201;
yuanshipaidui[1][1][12].leixing = 381;
yuanshipaidui[1][2][0].leixing = 301;
yuanshipaidui[1][2][0].changdu = 1;
yuanshipaidui[1][2][1].leixing = 331;
yuanshipaidui[1][2][2].leixing = 201;
yuanshipaidui[1][2][3].leixing = 201;
yuanshipaidui[1][2][4].leixing = 382;
yuanshipaidui[1][2][5].leixing = 251;
yuanshipaidui[1][2][6].leixing = 208;
yuanshipaidui[1][2][7].leixing = 101;
yuanshipaidui[1][2][8].leixing = 101;
yuanshipaidui[1][2][9].leixing = 101;
yuanshipaidui[1][2][10].leixing = 101;
yuanshipaidui[1][2][11].leixing = 210;
yuanshipaidui[1][2][12].leixing = 210;
yuanshipaidui[1][3][0].leixing = 301;
yuanshipaidui[1][3][0].changdu = 1;
yuanshipaidui[1][3][1].leixing = 102;
yuanshipaidui[1][3][2].leixing = 202;
yuanshipaidui[1][3][3].leixing = 202;
yuanshipaidui[1][3][4].leixing = 306;
yuanshipaidui[1][3][4].changdu = 3;
yuanshipaidui[1][3][5].leixing = 102;
yuanshipaidui[1][3][6].leixing = 102;
yuanshipaidui[1][3][7].leixing = 102;
yuanshipaidui[1][3][8].leixing = 102;
yuanshipaidui[1][3][9].leixing = 102;
yuanshipaidui[1][3][10].leixing = 102;
yuanshipaidui[1][3][11].leixing = 307;
yuanshipaidui[1][3][11].changdu = 4;
yuanshipaidui[1][3][12].leixing = 363;
int paiduishu = 104;
int qipaishu = 0;
printf("游戏开始! by cyh\n");
Qishixipai(yuanshipaidui, paidui);
Qishishoupai(&wanjia, paidui, &(paiduishu), qipaidui, &(qipaishu));
Qishishoupai(&com, paidui, &(paiduishu), qipaidui, &(qipaishu));
int i;
for (;;) {
i = Huihe(paidui, qipaidui, &paiduishu, &qipaishu, yuanshipaidui, &wanjia, &com);
if (i == -1)break;
i = Huihe(paidui, qipaidui, &paiduishu, &qipaishu, yuanshipaidui, &com, &wanjia);
if (i == -1)break;
}
}
4.愤怒的小鸟
点击查看代码
#include <bits/stdc++.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
using namespace std;
const double pi = 3.1415926536;
int toint (float a) {
return ((int) (a * 10 + 5)) / 10;
}
void Color (int a) {
if (a == 0 || a == 14 || a == 20) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else if (a == 1 || a == 12) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else if (a == 2) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_GREEN);
} else if (a == 3) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
} else if (a == 4 || a == 11) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_RED);
} else if (a == 5 || a == 13) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
} else if (a == 7) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_GREEN | FOREGROUND_BLUE);
} else if (a == 15) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
} else if (a == 16) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
} else if (a == 17) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED);
} else if (a == 8) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else if (a == 6) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_BLUE);
} else if (a == 9) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN);
}
}
void SetPos (float x, float y) {
int xx = toint (x), yy = toint (y);
COORD pos;
pos.X = yy * 2;
pos.Y = xx;
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), pos);
}
struct node {
int W, W2, S, mS;
float X, Y;
float vx, vy;
float ax, ay;
bool go, boom;
} blt[100001], pig[100001], boo[100001];
int T, yX, yY, Xy, put, K, K2, Sle, What;
int Bot, Pit, Blt, Pig, Sco, pigk, scok;
int m[41][41];
void Cout (int a, int x, int y) {
if (a == 1) {
SetPos (x, y);
Color (5);
cout << put << ' ';
}
if (y == 202) {
SetPos (pig[a].X, pig[a].Y);
cout << " ";
if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) {
SetPos (pig[a].X - 2, pig[a].Y);
cout << " ";
SetPos (pig[a].X - 1, pig[a].Y);
cout << " ";
} else if (pig[a].W == 4) {
SetPos (pig[a].X, pig[a].Y - 1);
cout << " ";
} else if (pig[a].W == 5) {
SetPos (pig[a].X - 1, pig[a].Y);
cout << " ";
SetPos (pig[a].X - 1, pig[a].Y - 1);
cout << " ";
}
}
if (a == 2) {
for (int i = 0; i <= 40; i++) {
for (int j = 0; j <= 40; j++) {
if (i <= 18 && m[i][j] == 1) {
SetPos (i, j);
Color (7);
cout << "■";
}
if (m[i][j] >= 2 && m[i][j] <= 19) {
SetPos (i, j);
Color (5);
cout << "█";
m[i][j]++;
}
if (m[i][j] > 19 && m[i][j] <= 29) {
SetPos (i, j);
Color (0);
cout << "█";
m[i][j]++;
if (m[i][j] == 30) {
SetPos (i, j);
Color (0);
cout << " ";
m[i][j] = 0;
}
if (m[i][j] >= 31 && m[i][j] <= 49) {
SetPos (i, j);
Color (0);
cout << "■";
m[i][j]++;
}
if (m[i][j] == 50) {
SetPos (i, j);
Color (7);
cout << "■";
m[i][j] = 1;
}
}
}
}
}
if (y == 666) {
SetPos (blt[a].X, blt[a].Y);
Color (10 + blt[a].W);
cout << "●";
}
Color (0);
}
void Go (int a) {
SetPos (blt[a].X, blt[a].Y);
cout << " ";
blt[a].X += blt[a].vx / 2;
blt[a].Y += blt[a].vy / 2;
blt[a].vx += blt[a].ax / 2;
blt[a].vy += blt[a].ay / 2;
if (blt[a].X >= 20) {
blt[a].X = 19;
}
if (blt[a].X > 20 || blt[a].Y > 38 || blt[a].X < 0 || blt[a].Y <= 0) {
blt[a].go = 1;
}
if (blt[a].W2 == 1 && blt[a].Y >= Xy) {
blt[a].go = 1;
Sle = 0;//地跑鸟
}
if (blt[a].W2 == 0) {
for (int i = 0; i <= blt[a].vx / 2 + 1; i++) {
if (blt[a].vx > 0 && m[toint (blt[a].X) + i][toint (blt[a].Y)] == 1) {
if (blt[a].W != 5) {
blt[a].boom = 1;
}
blt[a].X = toint (blt[a].X) + i - 1;
blt[a].Y += blt[a].vy / 2;
blt[a].vx = -blt[a].vx * 0.4;
blt[a].vy = blt[a].vy * 0.8;
if (blt[a].W == 3) {
blt[a].ax = 0.5;
}
if (blt[a].W == 7) {
blt[a].vx *= 2;
}
if (blt[a].W == 10) {
blt[a].go = 1;
Bot++;
boo[Bot].X = blt[a].X;
boo[Bot].Y = blt[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
}
}
if (blt[a].vx < 0 && m[toint (blt[a].X) - i][toint(blt[a].Y)] == 1) {
if (blt[a].W != 5) {
blt[a].boom = 1;
}
blt[a].X = toint (blt[a].X) + i + 1;
blt[a].Y += blt[a].vy / 2;
blt[a].vx = -blt[a].vx;
blt[a].vy = blt[a].vy * 0.8;
if (blt[a].W == 3) {
blt[a].ax = 0.5;
}
if (blt[a].W == 7) {
blt[a].vx *= 2;
}
if (blt[a].W == 10) {
blt[a].go = 1;
Bot++;
boo[Bot].X = blt[a].X;
boo[Bot].Y = blt[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
}
}
}
if (abs (blt[a].vx) <= 0.1 && abs (blt[a].vy) <= 0.1 && abs (blt[a].ay) <= 0.1) {
blt[a].go = 1;
if (blt[a].W == 5) {
Bot++;
boo[Bot].X = blt[a].X;
boo[Bot].Y = blt[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
blt[a].go = 1;
}
}
}
if (blt[a].go == 0) {
Cout (a, 0, 666);
}
}
void Kill (int a) {
if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {
Cout (a, 202, 202);
pig[a].Y = 16;
}
if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) {
pig[a].W = 1;
}
int R = rand () % 50;
Cout (a, 202, 202);
//清除猪猪
pig[a].X += pig[a].vx / 2;
pig[a].Y += pig[a].vy / 2;
pig[a].vx += pig[a].ax / 2;
pig[a].vy += pig[a].ay / 2;
for (int i = -2; i <= pig[a].vx / 2 + 1; i++) {
if (m[toint (pig[a].X) + i][toint (pig[a].Y)] == 1) {
pig[a].X = toint (pig[a].X) + i - 1;
pig[a].Y += pig[a].vy / 2;
pig[a].vx = -pig[a].vx * 0.5;
pig[a].vy = pig[a].vy * 0.8;
}
}
for (int i = Blt - 10; i <= Blt; i++) {
if (pig[a].W == 5 && blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1
&& abs (pig[a].Y - blt[i].Y) <= 1) {
m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2;
pig[a].W2++;
Sco += 2;
break;
}
if (pig[a].W == 5 && m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 &&
m[toint (pig[a].X)][toint (pig[a].Y)] < 30) {
m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2;
pig[a].W2++;
Sco += 2;
break;
}
if (blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) {
if (pig[a].W == 6) {
Bot++;
boo[Bot].X = pig[a].X;
boo[Bot].Y = pig[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
blt[i].go = 1;
}
m[toint (pig[a].X)][toint (pig[a].Y)] = 2;
pig[a].go = 1;
Pig--;
Sco += 10;
break;
}
if (m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 &&
m[toint (pig[a].X)][toint (pig[a].Y)] < 30) {
if (pig[a].W == 6) {
Bot++;
boo[Bot].X = pig[a].X;
boo[Bot].Y = pig[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
}
pig[a].go = 1;
Pig--;
Sco += 10;
break;
}
if ((pig[a].W == 2 || pig[a].W == 3) && blt[i].go == 0 &&
abs (pig[a].X - 2 - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) {
m[toint (pig[a].X)][toint (pig[a].Y)] = 2;
pig[a].go = 1;
Pig--;
Sco += 10;
break;
}
if ((pig[a].W == 2 || pig[a].W == 3) &&
m[toint (pig[a].X - 2)][toint (pig[a].Y)] >= 2
&& m[toint (pig[a].X - 2)][toint (pig[a].Y)] < 30) {
pig[a].go = 1;
Pig--;
Sco += 10;
break;
}
}
//弄死猪猪
if (pig[a].go == 0) {
if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {
Cout (a, 202, 202);
pig[a].Y = 16;
}
if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) {
pig[a].W = 1;
}
int Xx = toint (pig[a].X), Xy = toint (pig[a].Y);
if (pig[a].W == 6) {
SetPos (pig[a].X, pig[a].Y);
Color (9);
cout << "TN";
Color (0);
} else {
SetPos (pig[a].X, pig[a].Y);
Color (2);
cout << "●";
if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) {
SetPos (pig[a].X - 2, pig[a].Y);
Color (0);
cout << "○";
SetPos (pig[a].X - 1, pig[a].Y);
cout << "|";
} else if (pig[a].W == 4) {
SetPos (pig[a].X, pig[a].Y - 1);
Color (2);
cout << "﹃";
} else if (pig[a].W == 5) {
SetPos (pig[a].X - 1, pig[a].Y);
Color (8);
SetPos (pig[a].X - 1, pig[a].Y - 1);
cout << "▁";
if (pig[a].W2 == 0) {
cout << "▅";
} else if (pig[a].W2 == 1) {
cout << "▃";
} else if (pig[a].W2 == 2) {
cout << "▂";
} else if (pig[a].W2 == 3) {
pig[a].W = 1;
pig[a].W2 = 0;
SetPos (pig[a].X - 1, pig[a].Y - 1);
cout << " ";
}
}
}
//输出猪猪
if (pig[a].W == 2 && pig[a].X > pig[a].S) {
pig[a].W = 3;
pig[a].ax = -0.4;
pig[a].vx = 1.5;
} else if (pig[a].W == 3 && pig[a].X <= pig[a].S) {
pig[a].W = 2;
pig[a].ax = 0.4;
pig[a].vx = -1.5;
}
if ((pig[a].W == 2 || pig[a].W == 3) && (pig[a].Y <= 10 || pig[a].Y >= 38)) {
pig[a].vy *= -1;
}
if (pig[a].W == 4 && R == 0 && pig[a].X == 20) {
pig[a].vx = -((rand () % 40) / 10);
}
if (pig[a].W == 4) {
int r = rand () % 20;
for (int i = Blt - 10; i <= Blt; i++) {
if (r <= 5 && blt[i].go == 0 && pig[a].Y - blt[i].Y <= 5 &&
abs (blt[i].X - pig[a].X) <= 1.5 && r < 5) {
r = 0;
break;
}
}
if (r == 0) {
m[toint (pig[a].X)][toint (pig[a].Y) - 2] = 10;
m[toint (pig[a].X)][toint (pig[a].Y) - 3] = 2;
for (int j = toint (pig[a].Y) - 1; j >= toint (pig[a].Y) - 5; j--) {
for (int i = Blt - 10; i <= Blt; i++) {
if (blt[i].go == 0 && !(blt[i].W == 3 && blt[i].boom == 1)
&& blt[i].W2 == 0 && toint (blt[i].Y) == j
&& abs (blt[i].X - pig[a].X) <= 2) {
blt[i].vy = -2;
}
}
for (int i = Pit - 50; i <= Pit; i++) {
if (pig[i].go == 0 && toint (pig[i].Y) == j && abs (pig[i].X - pig[a].X) <= 2) {
pig[i].vy = -1;
}
}
}
}
}
//移动猪猪
if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {
Cout (a, 202, 202);
pig[a].Y = 16;
}
if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) {
pig[a].W = 1;
}
if (pig[a].X > 20 || pig[a].Y > 38 || pig[a].X < 0 || pig[a].Y <= 0) {
pig[a].go = 1;
Pig--;
Cout (a, 202, 202);
}
//清除猪猪
}
}
void Creat (int a, int p) {
if (a == -1 && p == -1) {
Blt++;
blt[Blt].W = What;
blt[Blt].W2 = 1;
blt[Blt].vy = 1;
blt[Blt].X = 19;
blt[Blt].Y = 0;
blt[Blt].boom = 1;
} else if (a == 0 && p == -1) {
int u = rand () % 7 + 1, U = rand() % 30;
if (u >= 5) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 1;
} else if (u == 1) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].vy = 0.5;
pig[Pit].ax = 0.5;
pig[Pit].S = rand () % 5 + 7;
pig[Pit].W = 2;
} else if (u == 2) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 4;
} else if (u == 3) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 5;
} else if (u == 4) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 6;
}
if (U == 1) {
Bot++;
boo[Bot].Y = rand () % 13 + 15;
boo[Bot].X = (rand () % 4) * 3 + 8;
boo[Bot].S = 0;
boo[Bot].mS = rand () % 2 + 2;
boo[Bot].W2 = 1;
}
} else {
Blt++;
blt[Blt].W = What;
if (a == 1) {
blt[Blt].X = yX;
blt[Blt].Y = yY;
blt[Blt].ax = 0.5; //抛物线
}
blt[Blt].vx = -3.5 * sin (p * pi / 180);
blt[Blt].vy = 3 * cos (p * pi / 180);
if (p <= 45) {
blt[Blt].vy *= 1 + (0.33 - 0.01 * (45 - p));
}
if (p >= 45) {
blt[Blt].vy *= 1 + (0.33 - 0.01 * (p - 45));
}
if (blt[Blt].W == 6) {
blt[Blt].vy *= 1.2;
blt[Blt].ax = 0.4;
}
}
}
void Boom (int a) {
if (boo[a].W2 == 0) {
int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y;
if (s == ms) {
return ;
}
for (int i = x - s; i <= x + s; i++) {
for (int j = y - s; j <= y + s; j++) {
float k = (i - x) * (i - x) + (j - y) * (j - y) - s * s;
if (k <= s && k >= -s && i <= 20 && j <= 38 && i >= 0 && j > 0 && m[i][j] != 1) {
m[i][j] = 2;
}
}
}
boo[a].S++;
}
if (boo[a].W2 == 1) {
int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y;
if (s == ms) {
return ;
}
if (y - s > 10) {
m[x][y - s] = 31 - 31 * (boo[a].W2 - 1);
}
if (y + s < 40) {
m[x][y + s] = 31 - 31 * (boo[a].W2 - 1);
}
boo[a].S++;
}
}
void Move (int a) {
Color (5);
if (a == -2) {
SetPos (17, Xy);
cout << " ";
SetPos (18, Xy);
cout << " ";
SetPos (19, Xy);
cout << " ";
SetPos (20, Xy);
cout << " ";
}
if (a == -1) {
SetPos (17, Xy);
cout << " ";
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 0) {
SetPos (18, Xy);
cout << " ┃";
Color (What + 10);
cout << "●";
Color (5);
cout << "┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 1) {
SetPos (18, Xy);
cout << " ";
Color (What + 10);
cout << "●";
Color (5);
cout << " ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 2) {
SetPos (18, Xy);
Color (What + 10);
cout << "●";
Color (5);
cout << "┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 3) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
Color (What + 10);
cout << "●";
Color (5);
cout << "╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 4) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
Color (What + 10);
cout << "●";
Color (5);
cout << " ▏";
}
if (a == 5) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ";
Color (What + 10);
cout << "●";
Color (5);
cout << " ▏";
}
if (a == 6) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ";
Color (What + 10);
cout << "●";
Color (5);
cout << " ";
}
Color (0);
}
void Start () {
char g;
Color (5);
system ("cls");
SetPos (1, 1);
cout << "------- 愤 怒 的 小 鸟 -------";
Color (0);
SetPos (3, 1);
cout << "空格瞄准,按X触发小鸟技能,←→移动弹弓";
SetPos (5, 1);
cout << "猪猪技能自动触发,空中会有墙出现。";
SetPos (7, 1);
cout << "危险值由命中率,猪的存活时间计算!";
SetPos (9, 1);
cout << "危险值点满后失败!1500分通关!";
SetPos (1, 20);
cout << "-------- 小 鸟 技 能 --------";
SetPos (3, 20);
Color (11);
cout << "●";
Color (0);
cout << ":无技能";
SetPos (5, 20);
Color (12);
cout << "●";
Color (0);
cout << ":分身!不同分身初速度大小相同,";
SetPos(6, 20);
cout << " 方向不同。";
SetPos (7, 20);
Color (13);
cout << "●";
Color (0);
cout << ":加速!以当前速度做匀速直线运动,";
SetPos (8, 20);
cout << " 且免疫狙击猪的冲击。";
SetPos (9, 20);
Color (14);
cout << "●";
Color (0);
cout << ":投蛋!并获得向上速度做匀速直线";
SetPos (10, 20);
cout << " 运动,快达可以穿墙。";
SetPos (11, 20);
Color (15);
cout << "●";
Color (0);
cout << ":爆炸!";
SetPos (13, 20);
Color (16);
cout << "●";
Color (0);
cout << ":回旋!开始做向左加速运动!发射";
SetPos (14, 20);
cout << " 时获得双倍水平速度。";
SetPos (15, 20);
Color (17);
cout << "●";
Color (0);
cout << ":[被动] 弹跳力为普通鸟三倍。发射";
SetPos (16, 20);
cout << " 时获得1.5倍水平、竖直速度。";
SetPos (11, 1);
cout << "-------- 猪 猪 技 能 --------";
SetPos (13, 2);
Color (2);
cout << "●";
Color (0);
cout << ":无技能";
SetPos (14, 1);
Color (8);
cout << "▁▅";
SetPos (15, 2);
Color (2);
cout << "●";
Color (0);
cout << ":防御力为普通猪三倍";
SetPos (16, 2);
cout << "○";
SetPos (17, 2);
cout << "│:做空中简谐运动,受死范围";
SetPos (18, 2);
Color (2);
cout << "●";
Color (0);
cout << " 为普通猪两倍。";
SetPos (19, 2);
cout << " 有几率跳起或发射冲击波,冲";
SetPos (20, 1);
Color (2);
cout << "﹃●";
Color (0);
cout << ":开小鸟与同类,可以引爆TNT!";
SetPos (18, 20);
Color (5);
cout << "按 y 开始游戏!";
A:
if (kbhit ()) {
g = _getch ();
}
if (g != 'y') {
goto A;
}
}
int main () {
system ("mode con cols=79 lines=22");
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cursor_info);
srand ((unsigned)time(NULL));
St:
Start ();
system ("cls");
memset (blt, 0, sizeof (blt));
memset (pig, 0, sizeof (pig));
memset (boo, 0, sizeof (boo));
memset (m, 0, sizeof (m));
T = put = K = K2 = Sle = What = Pig = Sco = 0;
pigk = scok = -1;
Xy = 4;
yX = 18;
yY = 6;
Blt = 20;
Bot = 20;
Pit = 60;
Color (7);
SetPos (19, 14);
cout << "■";
SetPos (20, 13);
cout << " █▍";
m[19][14] = m[20][13] = m[20][14] = 1;
SetPos (21, 0);
for (int i = 0; i < 39; i++) {
cout << "■";
m[21][i] = 1;
}
Color (0);
What = rand () % 5 + 1;
while (1) {
if (Sco >= 1500) {
break;
}
T++;
K = 0;
Color (0);
if (Sco != scok) {
SetPos (1, 1);
cout << "分数:" << Sco << ' ';
}
if (Pig != pigk) {
SetPos (3, 1);
cout << "危险值:";
int aa = min (Sco / 100, 10);
Pig += aa;
SetPos (3, 5);
if (Pig <= 2) {
Color (2);
} else if (Pig <= 4) {
Color (16);
} else if (Pig <= 6) {
Color (7);
} else if (Pig <= 9) {
Color (6);
} else if (Pig <= 12) {
Color (3);
} else if (Pig <= 15) {
Color (17);
} else {
Color (11);
}
for (int i = 1; i <= Pig; i++) {
cout << "■";
}
Color (0);
cout << ' ' << Pig;
for (int i = 1; i <= 5; i++) {
cout << " ";
}
if (Pig > 18) {
break;
}
Pig -= aa;
}
scok = Sco;
pigk = Pig;
if (GetAsyncKeyState (VK_LEFT) & 0x8000 && Xy > 0) {
Move (-2);
Xy--;
K = 1;
}
if (GetAsyncKeyState (VK_RIGHT) & 0x8000 && Xy < 10) {
Move (-2);
Xy++;
K = 1;
}
if (K == 1) {
if (put == 0 && Sle == 0) {
Move (0);
} else {
Move (-1);
}
}
if (kbhit ()) {
char g = _getch ();
if (g == 'x' || g == 'X') {
for (int i = Blt - 10; i <= Blt; i++) {
if (blt[i].go == 0 && blt[i].boom == 0 && blt[i].W != 1 && blt[i].W != 7) {
blt[i].boom = 1;
if (blt[i].W == 2) {
Blt++;
blt[Blt].W = 2;
blt[Blt].vy = blt[i].vy * 1.2;
blt[Blt].vx = blt[i].vx + 1;
blt[Blt].ax = blt[i].ax;
blt[Blt].X = blt[i].X;
blt[Blt].Y = blt[i].Y;
blt[Blt].boom = 1;
Blt++;
blt[Blt].W = 2;
blt[Blt].vy = blt[i].vy * 0.7;
blt[Blt].vx = blt[i].vx - 1;
blt[Blt].ax = blt[i].ax;
blt[Blt].X = blt[i].X;
blt[Blt].Y = blt[i].Y;
blt[Blt].boom = 1;
}
if (blt[i].W == 3) {
blt[i].vy = fmax (blt[i].vy * 1.5, 2.5);
blt[Blt].vx++;
blt[i].ax = 0;
}
if (blt[i].W == 4) {
blt[i].vx = -3;
blt[i].ax = 0.1;
Blt++;
blt[Blt].boom = 1;
blt[Blt].W = 10;
blt[Blt].X = blt[i].X;
blt[Blt].Y = blt[i].Y;
blt[Blt].ax = blt[i].ax;
blt[Blt].vx = 1;
}
if (blt[i].W == 5) {
Bot++;
boo[Bot].X = blt[i].X;
boo[Bot].Y = blt[i].Y;
boo[Bot].S = 1;
boo[Bot].mS = 5;
blt[i].go = 1;
}
if (blt[i].W == 6) {
blt[i].ay = -1;
blt[i].ax = 0.3;
blt[i].vx = min (blt[i].vx / 2, (float)0);
}
break;
}
}
}
}
if (GetAsyncKeyState (' ') & 0x8000 && K == 0 && Sle == 0) {
if (put <= 5) {
Move (1);
yX = 18;
yY = Xy + 1;
} else if (put <= 20) {
Move (2);
yX = 18;
yY = Xy;
} else if (put <= 40) {
Move (3);
yX = 19;
yY = Xy;
} else if (put <= 60) {
Move (4);
yX = 20;
yY = Xy;
} else if (put <= 80) {
Move (5);
yX = 20;
yY = Xy + 1;
} else {
Move (6);
yX = 20;
yY = Xy + 2;
}
if (put == 0) {
K2 = 1;
}
if (put == 90) {
K2 = -1;
}
if (K2 == 1) {
put += min (rand () % 7 + 1, 90 - put);
}
if (K2 == -1) {
put -= min(rand() % 7 + 1, put);
}
Cout (1, 17, Xy + 2);
}
if ((!(GetAsyncKeyState (' ') & 0x8000) && (put != 0)) || (put != 0 && K == 1)) {
Move (-1);
Creat (1, put);
put = 0;
yX = 18;
yY = 5;
Sle = 1;
What = rand () % 7 + 1;
Creat (-1, -1);
Sco = max (Sco - 5, 0);
}
for (int i = Blt - 10; i <= Blt; i++) {
if (blt[i].go == 0) {
Go (i);
}
}
for (int i = Bot - 10; i <= Bot; i++) {
if (boo[i].go == 0) {
Boom (i);
Cout (2, 0, 0);
}
}
for (int i = Pit - 50; i <= Pit; i++) {
if (pig[i].go == 0) {
Kill (i);
}
}
if (Sle != 0) {
Move (-1);
} else if (put == 0) {
Move (0);
}
if (T % 300 == 0) {
system ("cls");
pigk = scok = -1;
}
if (T % 100 == 0) {
Color (7);
for (int i = 0; i <= 18; i++) {
for (int j = 0; j <= 40; j++) {
if (m[i][j] == 1 && T % 100 == 0) {
SetPos (i, j);
cout << "■";
}
}
}
SetPos (19, 14);
cout << "■";
SetPos (20, 13);
cout << " █▍";
SetPos (21, 0);
for (int i = 0; i < 39; i++) {
cout << "■";
Color (0);
}
}
if (T % min (50, (2000 - Sco) / 30) == 0) {
Pig++;
Creat (0, -1);
}
Sleep (30);
}
if (Sco < 1500) {
if (MessageBox (NULL, "很遗憾,您输了,您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) {
goto St;
} else {
return 0;
}
} else {
if (MessageBox (NULL, "恭喜您赢了!您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) {
goto St;
} else {
return 0;
}
}
return 0;
}
5.跑酷
点击查看代码
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define Nor if(B[b].x<5) B[b].x=5;
#define Out1 Bx1-Bvx1<=6||Bx1-Bvx1>=28||By1-Bvy1<=7||By1-Bvy1>=27
#define Out2 Bx2-Bvx2<=6||Bx2-Bvx2>=28||By2-Bvy2<=7||By2-Bvy2>=27
#define Chang1 {Bwhat1=0;Bvx1=Bvy1=0;memset(Bgo1,0,sizeof(Bgo1));}
#define Chang2 {Bwhat2=0;Bvx2=Bvy2=0;memset(Bgo2,0,sizeof(Bgo2));}
#define Chang3 {Bwhat3=0;Bvx3=Bvy3=0;memset(Bgo3,0,sizeof(Bgo3));}
using namespace std;
int ti(float a) {
return ((int)(a * 10 + 5)) / 10;
}
void Setpos(float x, float y) {
COORD pos;
pos.X = ti(y * 4) / 2;
pos.Y = ti(x);
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void Color(int a) {
if (a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
if (a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
if (a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
if (a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
if (a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
if (a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
if (a == 6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
if (a == 7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
if (a == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
if (a == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE);
if (a == 10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_BLUE);
if (a == 11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE);
if (a == 12) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);
if (a == 13) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
if (a == 14) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE);
}
int Blomax, Ren, Exp, Expmax, Lv, Lvl, Ice, Drug, ar1, ar2, Tar1, Tar2, bl, br, Win, T, Tb, Sy, Up, Upt, Down, u1, u2, Kill, Killb, L, Ll[4], Li, D, Gd[10], Biao, Fire, Fir, Water, Thun, Wind, Magne, I[20][2], ib, Dis, Disb, Dis1, Disb1, Boss, Bblo, Bblomax, Bwhat1, Bwhat2, Bwhat3, Bgo1[10], Bgo2[10], Bgo3[10], Bbr, Bbl, Bl[4];
float X, Y, Vx, Vy, Ding, Blo, Hui, Bx1, By1, Bx2, By2, Bx3, By3, Bvx1, Bvy1, Bvx2, Bvy2, Bvx3, Bvy3, Bway[1001][2];
struct bullet {
float x, y, vx, vy;
int what;
int a, t, How;
int life;
bool kill;
} B[100001];
void Map(int a, int b);
void Pan(int a, float x, float y, int b) {
float Nox[4], Noy[4];
Nox[0] = X, Noy[0] = Y;
if (Down == 1 && X == 22) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
else if (Down == 2) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
else if (Down == 1 || X < 18) Nox[1] = X - 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
else Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
for (int i = 0; i < 3; i++) {
if (a == -1) {
if (abs(x - Nox[i]) + abs(y - Noy[i]) < 1.5) {
if (B[b].what == -10)Exp += 2;
if (B[b].what == -11)Exp += 1;
B[b].life = 0;
if (B[b].life == 0 && b == bl) bl++;
Map(3, b);
break;
}
}
if (a == -2) {
if (abs(x - Nox[i]) + abs(y - Noy[i]) < 2.5) {
if (B[b].what == -2)Exp += 5, Biao += 5;
if (B[b].what == -3)Fire = 300, Ice = 0, Fir = 3;
if (B[b].what == -4)Water = 200;
if (B[b].what == -5) {
Wind = 70;
Ding = 28.25;
Ice = 0;
if (Y < Ding - 1)Vy = 5;
else Vy = 0;
if (Up >= 1) Vx = -5;
if (Down == 2) Vx = 5;
}
if (B[b].what == -6) {
Thun = 200;
system("color 1F");
Sleep(20);
system("color 6F");
Sleep(10);
system("color 0F");
}
if (B[b].what == -7)Magne = 300;
if (B[b].what == -8)Ice = 0, Drug = 0, Blo = fmin((float)Blomax, Blo + 20);
if (B[b].what == -9)Exp = fmin((float)Expmax, Exp + 20);
B[b].life = 0;
if (B[b].life == 0 && b == bl) bl++;
Map(3, b);
break;
}
}
}
if (Wind == 0 && Thun == 0 && (B[b].kill != 0 || Killb >= 15 || Ren == 1 && Killb > 0)) return;
for (int i = 0; i < 3; i++) {
if ((Wind >= 1 || Thun >= 1) && abs(x - Nox[i]) + abs(y - Noy[i]) < 2.5) {
if (B[b].what < 98)Exp += 2;
B[b].life = 0;
Map(3, b);
break;
}
if (a == 1) {
if (abs(x - Nox[i]) < 0.5 && abs(y - Noy[i]) < 1) {
if (B[b].what >= 99)Blo -= 10;
if (B[b].what == 14)Blo -= 15, Ice = 100, B[b].life = 0;
else if (B[b].what == 15)Blo -= 20, Ice = 0, B[b].life = 0;
else if (B[b].what == 17)Blo -= 5, Drug = 100, B[b].life = 0;
else if (B[b].what >= 13 && B[b].what <= 17)Blo -= 10, B[b].life = 0;
else Blo -= 15;
B[b].kill = 1, Killb = 20;
Kill = 1;
Map(3, b);
break;
}
}
if (a == 2 || a == 6 || a == 8 || a == 9 || a == 10 || a == 11 || a == 12) {
if (abs(x - Nox[i]) + abs(y - Noy[i]) < 1.5) {
if (a == 2)Blo -= 20;
else if (a == 8)Blo -= 10;
else Blo -= 15;
B[b].kill = 1, Killb = 20;
Kill = 1;
if (a != 2) {
B[b].life = 0;
if (B[b].life == 0 && b == bl) bl++;
Map(3, b);
break;
}
}
}
if (a == 4) {
if ((Wind >= 1 || Thun >= 1) && abs(x - Nox[i]) < 1.5 && Noy[i] - y <= 0 && Noy[i] - y >= -8) {
if (B[b].what < 98)Exp += 2;
B[b].life = 0;
Map(3, b);
break;
}
if (abs(x - Nox[i]) < 1 && Noy[i] - y <= 0 && Noy[i] - y >= -8) {
Blo -= 25, B[b].kill = 1, Killb = 20;
Kill = 1;
Vy = -1;
Y -= 0.5;
break;
}
}
}
}
void Map(int a, int b) {
Color(0);
if (a == -1) {
if (Boss == 1 || Boss == 6) {
if (Bwhat1 == 5) {
if (ti(Bx1) == 20)Setpos(Bx1, By1), cout << "==";
else Setpos(Bx1, By1), cout << " ";
} else {
Setpos(Bx1 - 1, By1 - 0.5), cout << " ";
Setpos(Bx1, By1 - 1), cout << " ";
Setpos(Bx1 + 1, By1 - 0.5), cout << " ";
if (abs(ti(Bx1) - 20) <= 1)Setpos(20, By1 - 1), cout << "======";
}
}
if (Boss == 2 || Boss == 6) {
Setpos(Bx2 - 1, By2 - 1);
cout << " ";
Setpos(Bx2, By2 - 1);
cout << " ";
Setpos(Bx2 + 1, By2 - 1), cout << " ";
Color(0);
if (abs(ti(Bx2) - 20) <= 1)Setpos(20, By2 - 1), cout << "======";
}
if (Boss == 3 || Boss == 6) {
Setpos(Bx3 - 1, By3 - 0.5);
cout << " ";
Setpos(Bx3, By3);
cout << " ";
Setpos(Bx3 + 1, By3 - 1), cout << " ";
Color(0);
if (abs(ti(Bx3) - 20) <= 1)Setpos(20, By3 - 1), cout << "=======";
}
if (X < 0)return;
if (X >= 17 && X <= 19) {
Setpos(X - 1, Y);
cout << " ";
Setpos(X, Y - 1);
cout << " ";
Setpos(X + 1, Y - 1), cout << " ";
} else if (X <= 23 && X >= 21) {
Setpos(X + 1, Y);
cout << " ";
Setpos(X, Y - 1);
cout << " ";
Setpos(X - 1, Y - 1), cout << " ";
} else if (X > 23) {
Setpos(X, Y - 1);
cout << " ";
Setpos(X - 1, Y - 0.5), cout << " ";
} else if (X < 17 && Upt != 0) {
Setpos(X, Y - 1);
cout << " ";
Setpos(X + 1, Y - 1.5), cout << " ";
} else if (X < 17) {
Setpos(X, Y - 1);
cout << " ";
Setpos(X + 1, Y - 0.5), cout << " ";
}
if (Thun > 0) {
Setpos(X - 2, Y - 1), cout << " ";
Setpos(X + 2, Y - 1), cout << " ";
Setpos(X, Y + 2), cout << " ";
Setpos(X, Y - 2.5), cout << " ";
Setpos(X - 1, Y + 1), cout << " ";
Setpos(X + 1, Y + 1), cout << " ";
Setpos(X - 1, Y - 2), cout << " ";
Setpos(X + 1, Y - 2), cout << " ";
Setpos(20, Y - 2.5), cout << "============";
}
if (Wind != 0) {
Setpos(X + 1, Y - 5);
cout << " ";
Setpos(X, Y - 5);
cout << " ";
Setpos(X - 1, Y - 5);
cout << " ";
Setpos(20, Y - 5), cout << "========";
}
if (Water != 0) {
Setpos(X, Y - 4);
cout << " ";
Setpos(X + 2, Y - 3.5);
cout << " ";
Setpos(X - 2, Y - 3.5);
cout << " ";
Setpos(X + 1, Y - 3.5);
cout << " ";
Setpos(X - 1, Y - 3.5);
cout << " ";
Setpos(20, Y - 5), cout << "========";
}
if (Fire != 0) {
Setpos(X, Y + 1), cout << " ";
Setpos(X + 1, Y), cout << " ";
Setpos(X - 1, Y - 1), cout << " ";
Setpos(20, Y - 1);
cout << "======";
}
}
if (a == 0) {
if (Boss == 1 || Boss == 6) {
if (Bwhat1 == 5)Color(5), Setpos(Bx1, By1), cout << "█", Color(0);
else if (Bwhat1 == 4 && Bgo1[1] > 6 && Bgo1[1] < 11)Color(4), Setpos(Bgo1[5] - 1, Bgo1[6]), cout << "︻", Setpos(Bgo1[5], Bgo1[6] - 1), cout << "【", Setpos(Bgo1[5], Bgo1[6] + 1), cout << "】", Setpos(Bgo1[5] + 1, Bgo1[6]), cout << "︼", Color(0);
else {
Setpos(Bx1 - 1, By1 - 0.5), Color(0), cout << "●●";
Setpos(Bx1, By1 - 1);
if (Bwhat1 == 2 && Bgo1[1] <= 5)Color(1);
else if (Bwhat1 == 3 && Bgo1[1] <= 5)Color(5);
else if (Bwhat1 == 6 && Bgo1[1] <= 5)Color(8);
else Color(4);
if (Bwhat1 == 4) Setpos(Bx1, By1 - 0.5), cout << "██(";
else cout << ")██(";
Setpos(Bx1 + 1, By1 - 0.5), cout << "……";
Color(0);
}
}
if (Boss == 2 || Boss == 6) {
Setpos(Bx2 - 1, By2 - 1);
Color(0), cout << "\\ ";
Color(0);
cout << "●";
Setpos(Bx2, By2 - 1);
Color(3);
cout << "◥";
Color(5), cout << "JJJ";
Color(0), cout << ">";
Color(3);
Setpos(Bx2 + 1, By2 - 1), cout << "◢█◣";
Color(0);
}
if (Boss == 3 || Boss == 6) {
Setpos(Bx3 - 1, By3 - 0.5);
if (Bwhat3 == 3 || Bwhat3 == 9) Color(1);
else if (Bwhat3 == 4 || Bwhat3 == 10) Color(4);
else if (Bwhat3 == 5 || Bwhat3 == 11) Color(5);
if (Bwhat3 == 11)cout << ' ';
else if (Bwhat3 == 6) Color(3);
else Color(2);
cout << "●-";
Setpos(Bx3, By3);
if (Bwhat3 == 11)cout << "/";
else cout << "┃";
Color(0);
Setpos(Bx3 + 1, By3 - 1), cout << "●●●";
}
if (X < 0)return;
if (Ren == 2) Color(12);
if (Ren == 3) Color(1);
if (Ren == 4) Color(3);
if (Ren == 5) Color(4);
if (Ren == 6) Color(2);
if (Drug != 0 && T % 5 != 0) Color(11);
if (Drug != 0 && T % 5 == 0) Color(11);
if (Ice != 0) Color(6);
if (b == 1) Color(8);
if (Li != 0) Color(5);
if (Ren == 1 && Killb > 0 && T % 4 < 2) Color(13);
if (Wind > 0 && T % 4 <= 1) Color(1);
if (Wind > 0 && T % 4 >= 2) Color(0);
if (Thun > 0 && T % 4 <= 1) Color(1);
if (Thun > 0 && T % 4 >= 2) Color(6);
if (X >= 17 && X <= 19) {
Setpos(X - 1, Y);
cout << "●";
Setpos(X, Y - 1);
cout << "━/";
if (T % 10 < 3) Setpos(X + 1, Y - 1), cout << "┛╲";
else if (T % 10 < 6) Setpos(X + 1, Y - 1), cout << "┦ ";
else Setpos(X + 1, Y - 1), cout << "╯>";
if (Wind > 0 && T % 3 == 0) Setpos(X + 1, Y - 1), cout << "┛╲";
else if (Wind > 0 && T % 3 == 1) Setpos(X + 1, Y - 1), cout << "┦ ";
else if (Wind > 0 && T % 3 == 2)Setpos(X + 1, Y - 1), cout << "╯>";
} else if (X <= 23 && X >= 21) {
Setpos(X + 1, Y);
cout << "●";
Setpos(X, Y - 1);
cout << "━\\";
if (T % 10 < 3) Setpos(X - 1, Y - 1), cout << "┓╱";
else if (T % 10 < 6) Setpos(X - 1, Y - 1), cout << "┪ ";
else Setpos(X - 1, Y - 1), cout << "╮>";
if (Wind > 0 && T % 3 == 0) Setpos(X - 1, Y - 1), cout << "┓╱";
else if (Wind > 0 && T % 3 == 1) Setpos(X - 1, Y - 1), cout << "┪ ";
else if (Wind > 0 && T % 3 == 2)Setpos(X - 1, Y - 1), cout << "╮>";
} else if (X > 23) {
Setpos(X, Y - 1);
cout << "━ ●";
Setpos(X - 1, Y - 0.5), cout << "│>";
} else if (X < 17 && Upt != 0) {
Setpos(X, Y - 1);
cout << "━ ●";
Setpos(X + 1, Y - 1.5), cout << "╱ >";
} else if (X < 17) {
Setpos(X, Y - 1);
cout << "━ ●";
Setpos(X + 1, Y - 0.5), cout << "│>";
}
if (Thun > 0) {
Setpos(X - 2, Y - 1), cout << "▄▄";
Setpos(X + 2, Y - 1), cout << "▄▄";
Setpos(X, Y + 2), cout << "▌";
Setpos(X, Y - 2.5), cout << "▌";
Setpos(X - 1, Y + 1), cout << "█";
Setpos(X + 1, Y + 1), cout << "█";
Setpos(X - 1, Y - 2), cout << "█";
Setpos(X + 1, Y - 2), cout << "█";
}
if (Magne > 0 && T % 7 < 2)Setpos(X, Y), Color(5), cout << "★";
if (Wind > 1) {
if (T % 6 < 2)Color(1);
else Color(0);
if (T % 8 <= 1) {
Setpos(X + 1, Y - 5);
cout << "---- --";
Setpos(X, Y - 5);
cout << "- --- -";
Setpos(X - 1, Y - 5);
cout << "--- - --";
} else if (T % 8 <= 3) {
Setpos(X + 1, Y - 5);
cout << "------ ";
Setpos(X, Y - 5);
cout << " -- ---";
Setpos(X - 1, Y - 5);
cout << "----- - ";
} else if (T % 8 <= 5) {
Setpos(X + 1, Y - 5);
cout << " ------";
Setpos(X, Y - 5);
cout << "-- -- -";
Setpos(X - 1, Y - 5);
cout << "- ----- ";
} else if (T % 8 <= 7) {
Setpos(X + 1, Y - 5);
cout << "-- ----";
Setpos(X, Y - 5);
cout << " --- -- ";
Setpos(X - 1, Y - 5);
cout << "- - ----";
}
}
if (Water != 0) {
Color(1);
if (T % 20 < 5) {
Setpos(X + 2, Y - 3);
cout << "■";
Setpos(X + 1, Y - 3.5);
cout << "■";
Setpos(X - 1, Y - 2.5);
cout << "■";
Setpos(X - 2, Y - 3);
cout << "■";
} else if (T % 20 < 10 || T % 20 >= 15) {
Setpos(X + 2, Y - 3);
cout << "■";
Setpos(X, Y - 4);
cout << "■■";
Setpos(X - 2, Y - 3);
cout << "■";
} else if (T % 20 < 15) {
Setpos(X + 2, Y - 3.5);
cout << "■";
Setpos(X + 1, Y - 3);
cout << "■";
Setpos(X - 1, Y - 3.5);
cout << "■";
Setpos(X - 2, Y - 3);
cout << "■";
}
}
if (Fire != 0) {
if (T % 6 < 3)Color(4);
else Color(5);
if (Fir >= 1)Setpos(X, Y + 1), cout << "●";
if (Fir >= 2)Setpos(X + 1, Y), cout << "●";
if (Fir >= 3)Setpos(X - 1, Y - 1), cout << "●";
}
}
if (a == 1 || a == 3) {
if (B[b].what == 1) {
Nor;
Setpos(B[b].x, B[b].y - 1);
if (ti(B[b].x) == 20)cout << "======";
else cout << " ";
if (B[b].life != 0) {
B[b].y -= B[b].vy;
Setpos(B[b].x, B[b].y);
if (B[b].How <= 1) Color(13);
else Color(4);
cout << "●";
if (a == 1) Pan(1, B[b].x, B[b].y, b);
}
}
if (B[b].what == 2) {
Nor;
Setpos(B[b].x - 1, B[b].y - 1);
if (ti(B[b].x - 1) == 20)cout << "======";
else cout << " ";
Setpos(B[b].x, B[b].y - 1);
if (ti(B[b].x) == 20)cout << "======";
else cout << " ";
Setpos(B[b].x + 1, B[b].y - 1);
if (ti(B[b].x + 1) == 20)cout << "======";
else cout << " ";
if (B[b].life != 0) {
B[b].y -= B[b].vy;
Setpos(B[b].x, B[b].y);
Color(5);
if (B[b].How == 0) {
Setpos(B[b].x - 1, B[b].y), cout << "↑";
Setpos(B[b].x, B[b].y - 1), cout << "←┼ →";
Setpos(B[b].x + 1, B[b].y), cout << "↓";
} else if (B[b].How == 1) {
Setpos(B[b].x - 1, B[b].y - 1), cout << "↖ ↗";
Setpos(B[b].x, B[b].y), cout << "╳";
Setpos(B[b].x + 1, B[b].y - 1), cout << "↙ ↘";
}
if (a == 1) Pan(2, B[b].x, B[b].y, b);
}
}
if (B[b].what == 3 || B[b].what == 5) {
Nor;
Setpos(B[b].x, B[b].y);
if (ti(B[b].x) == 20)cout << "==";
else cout << " ";
if (B[b].life != 0) {
B[b].y -= B[b].vy;
B[b].x -= B[b].vx;
Setpos(B[b].x, B[b].y);
if (B[b].How == 1) Color(5);
else Color(4);
cout << "◎";
}
}
if (B[b].what == 4) {
Nor;
Setpos(B[b].x, fmax((float)0, B[b].y - 8));
if (ti(B[b].x) == 20) {
for (int i = max(0, (int)B[b].y - 8); i <= B[b].y; i++)cout << "==";
} else {
for (int i = max(0, (int)B[b].y - 8); i <= B[b].y; i++)cout << " ";
}
if (B[b].life != 0) {
B[b].y -= B[b].vy;
Setpos(B[b].x, fmax((float)0, B[b].y - 8));
Color(6);
for (int i = max(0, (int)B[b].y - 8); i <= B[b].y; i++)cout << "═";
if (a == 1) Pan(4, B[b].x, B[b].y, b);
}
}
if (B[b].what == 6 || B[b].what == 8 || B[b].what == 9) {
Nor;
Setpos(B[b].x - 1, B[b].y);
if (ti(B[b].x) - 1 == 20)cout << "==";
else cout << " ";
Setpos(B[b].x + 1, B[b].y);
if (ti(B[b].x) + 1 == 20)cout << "==";
else cout << " ";
Setpos(B[b].x, B[b].y - 1);
if (ti(B[b].x) == 20)cout << "======";
else cout << " ";
if (B[b].life != 0) {
B[b].y -= B[b].vy;
B[b].x -= B[b].vx;
Setpos(B[b].x, B[b].y - 1);
if (B[b].what == 6) {
if (B[b].How <= 1) Color(1);
else Color(6);
}
if (B[b].what == 9) {
if (B[b].How <= 1) Color(4);
else Color(8);
}
if (B[b].what == 8)Color(5);
Setpos(B[b].x - 1, B[b].y);
cout << "︹";
Setpos(B[b].x + 1, B[b].y);
cout << "︺";
Setpos(B[b].x, B[b].y - 1);
if (B[b].How % 2 == 1) cout << "〔●〕";
else cout << "﹝○﹞";
if (a == 1) Pan(6, B[b].x, B[b].y, b);
}
}
if (B[b].what == 7) {
Nor;
Setpos(B[b].x, B[b].y);
if (B[b].How < 0) for (int i = 19; i >= 20 + B[b].How; i--) {
Setpos(i, B[b].y);
cout << " ";
}
if (B[b].How > 0) for (int i = 21; i <= 20 + B[b].How; i++) {
Setpos(i, B[b].y);
cout << " ";
}
if (B[b].life != 0) {
B[b].y -= B[b].vy;
if (B[b].How < 0) for (int i = 19; i >= 20 + B[b].How; i--) {
Setpos(i, B[b].y);
cout << "║";
if (a == 1) Pan(7, i, B[b].y, b);
}
if (B[b].How > 0) for (int i = 21; i <= 20 + B[b].How; i++) {
Setpos(i, B[b].y);
cout << "║";
if (a == 1) Pan(7, i, B[b].y, b);
}
}
}
if (B[b].what == 10 || B[b].what == 11 || B[b].what == 12) {
Nor;
Setpos(B[b].x, B[b].y);
if (ti(B[b].x) == 20)cout << "==";
else cout << " ";
if (B[b].life != 0) {
B[b].x -= B[b].vx;
B[b].y -= B[b].vy;
if (B[b].How == 1) {
B[b].vy -= 0.2;
} else B[b].vx -= 0.35;
if (B[b].x >= 25) B[b].x = 25, B[b].vx *= -0.8;
if (B[b].what == 11 && B[b].y <= 1) B[b].y = 1, B[b].vy *= -1;
if (B[b].what == 12 && B[b].y <= 1) B[b].y = 1, B[b].vx = 0, B[b].vy = -0.5, B[b].How = 1;
Setpos(B[b].x, B[b].y);
if (B[b].what == 11)Color(1);
else if (B[b].what == 12)Color(5);
else Color(0);
if (B[b].t % 4 < 2)cout << "▃";
else cout << "▍";
if (a == 1) Pan(B[b].what, B[b].x, B[b].y, b);
}
}
if (B[b].what >= 13 && B[b].what <= 17) {
Nor;
Setpos(B[b].x, B[b].y);
if (ti(B[b].x) == 20)cout << "====";
else cout << " ";
if (B[b].life != 0) {
B[b].x -= B[b].vx;
B[b].y -= B[b].vy;
Setpos(B[b].x, B[b].y);
if (B[b].what == 14) Color(1);
else if (B[b].what == 15) Color(4);
else if (B[b].what == 16) Color(5);
else if (B[b].what == 17) Color(3);
else Color(2);
cout << "●";
if (B[b].what == 14)cout << "*";
if (B[b].what == 15)cout << "";
if (B[b].what == 16)cout << "<";
if (B[b].what == 17)cout << "X";
}
if (a == 1) Pan(1, B[b].x, B[b].y, b);
}
if (B[b].what == 98 && B[b].life != 0) {
B[b].y -= B[b].vy;
Setpos(B[b].x, B[b].y);
if (ti(B[b].x == 20))cout << "==";
else cout << " ";
if (B[b].y <= 3)B[b].life = 0;
}
if (B[b].what >= 99) {
if (B[b].y <= 3)B[b].life = 0;
if (B[b].life != 0) {
B[b].y -= B[b].vy;
Setpos(B[b].x, B[b].y);
Color(5);
if (B[b].what == 99)cout << "█";
if (B[b].what >= 100 && B[b].what < 200) {
if (B[b].what % 5 == 0)cout << "我";
if (B[b].what % 5 == 1)cout << "是";
if (B[b].what % 5 == 2)cout << "最";
if (B[b].what % 5 == 3)cout << "强";
if (B[b].what % 5 == 4)cout << "的";
}
if (B[b].what >= 200 && B[b].what < 300) {
if (B[b].what % 6 == 0)cout << "神";
if (B[b].what % 6 == 1)cout << "级";
if (B[b].what % 6 == 2)cout << "怪";
if (B[b].what % 6 == 3)cout << "物";
if (B[b].what % 6 == 4)cout << "之";
if (B[b].what % 6 == 5)cout << "光";
}
if (B[b].what >= 300 && B[b].what < 400) {
if (B[b].what % 8 == 0)cout << "颤";
if (B[b].what % 8 == 1)cout << "抖";
if (B[b].what % 8 == 2)cout << "吧";
if (B[b].what % 8 == 3)cout << "无";
if (B[b].what % 8 == 4)cout << "能";
if (B[b].what % 8 == 5)cout << "的";
if (B[b].what % 8 == 6)cout << "人";
if (B[b].what % 8 == 7)cout << "类";
}
if (B[b].what >= 400 && B[b].what < 500) {
if (B[b].what % 8 == 0)cout << "还";
if (B[b].what % 8 == 1)cout << "不";
if (B[b].what % 8 == 2)cout << "快";
if (B[b].what % 8 == 3)cout << "跪";
if (B[b].what % 8 == 4)cout << "倒";
if (B[b].what % 8 == 5)cout << "在";
if (B[b].what % 8 == 6)cout << "朕";
if (B[b].what % 8 == 7)cout << "前";
}
if (B[b].what >= 500 && B[b].what < 600) {
if (B[b].what % 8 == 0)cout << "看";
if (B[b].what % 8 == 1)cout << "懂";
if (B[b].what % 8 == 2)cout << "这";
if (B[b].what % 8 == 3)cout << "句";
if (B[b].what % 8 == 4)cout << "话";
if (B[b].what % 8 == 5)cout << "的";
if (B[b].what % 8 == 6)cout << "是";
if (B[b].what % 8 == 7)cout << "猪";
}
if (a == 1) Pan(1, B[b].x, B[b].y, b);
}
}
if (B[b].what == -1) {
Nor;
Setpos(B[b].x, B[b].y);
if (ti(B[b].x) == 20)cout << "==";
else cout << " ";
if (Boss == 0) B[b].life = 0;
else if (((Boss == 1 && abs(B[b].x - Bx1) + abs(B[b].y - By1) < 1.5) || (Boss == 2 && abs(B[b].x - Bx2) + abs(B[b].y - By2) < 1.5) || (Boss == 3 && abs(B[b].x - Bx3) + abs(B[b].y - By3) < 1.5) || (B[b].t == 10)) && B[b].life == 1) Bblo -= 8 + Lv * 2, B[b].life = 0;
if (B[b].life != 0) {
if (Boss == 1)B[b].x = B[b].x + (Bx1 - B[b].x) / (10 - B[b].t) * 1.0, B[b].y = B[b].y + (By1 - B[b].y) / (10 - B[b].t) * 1.0;
if (Boss == 2)B[b].x = B[b].x + (Bx2 - B[b].x) / (10 - B[b].t) * 1.0, B[b].y = B[b].y + (By2 - B[b].y) / (10 - B[b].t) * 1.0;
if (Boss == 3)B[b].x = B[b].x + (Bx3 - B[b].x) / (10 - B[b].t) * 1.0, B[b].y = B[b].y + (By3 - B[b].y) / (10 - B[b].t) * 1.0;
Setpos(B[b].x, B[b].y);
Color(7);
if (B[b].t % 2 == 0) cout << "+";
else cout << "×";
}
}
if (B[b].what <= -2 && B[b].what >= -9) {
Nor;
Setpos(B[b].x - 1, B[b].y);
if (ti(B[b].x) - 1 == 20)cout << "==";
else cout << " ";
Setpos(B[b].x + 1, B[b].y);
if (ti(B[b].x) + 1 == 20)cout << "==";
else cout << " ";
Setpos(B[b].x, B[b].y - 1);
if (ti(B[b].x) == 20)cout << "======";
else cout << " ";
if (B[b].life != 0) {
B[b].y -= B[b].vy;
B[b].x -= B[b].vx;
if (B[b].what <= -3 && B[b].what >= -7) {
if (B[b].x <= 7)B[b].x = 7;
if (B[b].x >= 28)B[b].x = 28;
else if (B[b].x >= B[b].a + 1 && B[b].How == 1)B[b].How = 0;
else if (B[b].x <= B[b].a - 1 && B[b].How == 0)B[b].How = 1;
if (B[b].How == 1 && B[b].vx >= -1)B[b].vx -= 0.2;
if (B[b].How == 0 && B[b].vx <= 1)B[b].vx += 0.2;
}
if (B[b].what == -2) Color(3);
if (B[b].what == -3) Color(4);
if (B[b].what == -4) Color(1);
if (B[b].what == -5) Color(0);
if (B[b].what == -6) Color(6);
if (B[b].what == -7) Color(5);
if (B[b].what == -8) Color(2);
if (B[b].what == -9) Color(14);
if (T % 7 <= 1 && B[b].what == -5)Color(1);
else if (T % 7 <= 1)Color(0);
Setpos(B[b].x - 1, B[b].y);
cout << "︹";
Setpos(B[b].x + 1, B[b].y);
cout << "︺";
Setpos(B[b].x, B[b].y - 1);
if (B[b].what == -2) cout << "﹝镖﹞";
if (B[b].what == -3) cout << "﹝火﹞";
if (B[b].what == -4) cout << "﹝水﹞";
if (B[b].what == -5) cout << "﹝风﹞";
if (B[b].what == -6) cout << "﹝雷﹞";
if (B[b].what == -7) cout << "﹝磁﹞";
if (B[b].what == -8) cout << "﹝血﹞";
if (B[b].what == -9) cout << "﹝忍﹞";
if (a == 1) Pan(-2, B[b].x, B[b].y, b);
}
}
if (B[b].what == -11 || B[b].what == -12) {
Nor;
Setpos(B[b].x, B[b].y);
if (ti(B[b].x) == 20)cout << "==";
else cout << " ";
if (B[b].life != 0) {
if (Magne > 0)B[b].How++, B[b].x = B[b].x + (X - B[b].x) / (10 - B[b].How) * 1.0, B[b].y = B[b].y + (Y - B[b].y) / (10 - B[b].How) * 1.0;
B[b].y -= B[b].vy;
Setpos(B[b].x, B[b].y);
if (B[b].what == -10) Color(5);
if (B[b].what == -11) Color(7);
if (T % 7 <= 1)Color(0);
cout << "◆";
if (a == 1) Pan(-1, B[b].x, B[b].y, b);
}
}
if (B[b].what == -13) {
Nor;
Setpos(B[b].x, B[b].y - 0.5);
if (ti(B[b].x) == 20)cout << "===";
else cout << " ";
if (B[b].life != 0) {
if (B[b].a == 13880086) {
if (Boss == 0) B[b].life = 0;
else if (((Boss == 1 && abs(B[b].x - Bx1) + abs(B[b].y - By1) < 1.5) || (Boss == 2 && abs(B[b].x - Bx2) + abs(B[b].y - By2) < 1.5) || (Boss == 3 && abs(B[b].x - Bx3) + abs(B[b].y - By3) < 1.5) || (B[b].t == 5)) && B[b].life == 1) Bblo -= 8 + Lv * 2, B[b].life = 0;
if (B[b].life != 0) {
if (Boss == 1)B[b].x = B[b].x + (Bx1 - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (By1 - B[b].y) / (5 - B[b].t) * 1.0;
if (Boss == 2)B[b].x = B[b].x + (Bx2 - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (By2 - B[b].y) / (5 - B[b].t) * 1.0;
if (Boss == 3)B[b].x = B[b].x + (Bx3 - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (By3 - B[b].y) / (5 - B[b].t) * 1.0;
}
} else {
if (B[B[b].a].life == 0) B[b].life = 0;
else if ((abs(B[b].x - B[B[b].a].x) + abs(B[b].y - B[B[b].a].y) < 1.5 || (B[b].t == 5)) && B[b].life == 1) Exp += 2, B[B[b].a].life = B[b].life = 0;
if (B[b].life != 0) {
B[b].x = B[b].x + (B[B[b].a].x - B[b].x) / (5 - B[b].t) * 1.0, B[b].y = B[b].y + (B[B[b].a].y - B[b].y) / (5 - B[b].t) * 1.0;
}
}
Setpos(B[b].x, B[b].y - 0.5);
if (T % 6 < 3)Color(5);
else Color(4);
cout << "●";
}
}
}
if (br < bl) {
br = -1, bl = 0;
memset(B, 0, sizeof(B));
}
Color(0);
}
void Move() {
if (X < 3) X = 3;
if (Y < 1) Y = 1, Vy = 0;
if (Y > 29) Y = 29, Vy = 0;
if (Ice != 0) {
X -= Vx / 2.0;
Y += Vy / 2.0;
Vy = fmax(Vy - 0.025, (float)0);
if (T % 6 == 0 && Up == 0 && Y < Ding) Y += 0.25;
if (T % 6 == 3 && Up == 0 && Y >= Ding) Y -= 0.25;
if (Up == 0 && Y <= Ding - 1.25) Vy = 0.25;
if (Up == 0 && Y >= Ding + 1.25 && Wind == 0) Vy = -0.25;
if (Up == 0 && Down == 0 && Vx > 0 && X <= 18) Up = 0, Down = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
else if (Down == 2 && X <= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
else if (Up == 0 && Down == 1 && Vx < 0 && X >= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
else if (Up > 0 && Down == 0 && X > 18) Up = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
else if (Down == 2) Vx += 0.175;
else if (Up > 0 && Upt == 0) Vx -= 0.175;
else if (Up > 0 && Upt > 0) {
Vx = fmax(Vx - 0.125, (float)0);
if (Upt == 1 && T % 2 == 0)Map(-1, 0);
if (T % 2 == 0)Upt--;
}
} else {
X -= Vx;
Y += Vy;
Vy = fmax(Vy - 0.05, (float)0);
if (Wind == 0) {
if (T % 6 == 0 && Up == 0 && Y < Ding) Y += 0.5;
if (T % 6 == 3 && Up == 0 && Y >= Ding) Y -= 0.5;
} else {
if (T % 2 == 0 && Up == 0 && Y < Ding) Y += 0.5;
if (T % 2 == 1 && Up == 0 && Y >= Ding) Y -= 0.5;
}
if (Up == 0 && Y <= Ding - 1.25) Vy = 0.5;
if (Up == 0 && Y >= Ding + 1.25 && Wind == 0) Vy = -0.5;
if (Up == 0 && Down == 0 && Vx > 0 && X <= 18) Up = 0, Down = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
else if (Down == 2 && X <= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
else if (Up == 0 && Down == 1 && Vx < 0 && X >= 22) Up = 0, Down = 1, Vx = 0, Vy = 0, X = 22, Setpos(20, Y - 2.5), cout << "==========";
else if (Up > 0 && Down == 0 && X > 18) Up = 0, Vx = 0, Vy = 0, X = 18, Setpos(20, Y - 2.5), cout << "==========";
else if (Down == 2) Vx += 0.35;
else if (Up > 0 && Upt == 0) Vx -= 0.35;
else if (Up > 0 && Upt > 0) {
Vx = fmax(Vx - 0.25, (float)0);
if (Upt == 1)Map(-1, 0);
Upt--;
}
}
for (int i = bl; i <= br; i++) {
if (B[i].what < 98)if (B[i].x - B[i].vx <= 5 || B[i].x - B[i].vx >= 30 || B[i].y - B[i].vy <= 0 || B[i].y - B[i].vy >= 30) {
B[i].life = 0;
Map(1, i);
}
for (int j = 0; j < 20; j++)if (B[i].what > 0 && B[i].life != 0 && abs(B[i].x - I[j][0]) < 2 && B[i].y - I[j][1] <= 2) {
Setpos(I[j][0], I[j][1]);
if (I[j][0] == 20) cout << "===";
else cout << " ";
I[j][0] = I[j][1] = -1;
B[i].life = 0;
Exp += 2;
}
if (B[i].t >= 100)B[i].life = 0;
if (B[i].life == 0 && i == bl) bl++;
Map(1, i);
if (B[i].life == 0) continue;
else {
B[i].t++;
if (B[i].what == 1) {
if (B[i].y <= 25 && B[i].How == 0) B[i].vy = 0, B[i].How = 1;
if (B[i].t == 30) B[i].y += 1.5, B[i].How = 2;
if (B[i].t == 35) B[i].vy = 1.5, B[i].How = 3;
}
if (B[i].what == 2) {
if (B[i].t % 3 == 0) B[i].How = !B[i].How;
}
if (B[i].what == 3 || B[i].what == 5) {
if (B[i].what == 3 && B[i].y <= 20) B[i].vy = 0;
if (B[i].what == 5 && B[i].y <= 21) B[i].vy = 0;
if (B[i].t > 30 && B[i].t % 2 == 0) B[i].How = !B[i].How;
if (B[i].what == 5 && B[i].t <= 30 && B[i].x < X) B[i].vx = -0.2;
else if (B[i].what == 5 && B[i].t <= 70 && B[i].x > X) B[i].vx = 0.2;
else B[i].vx = 0;
if (B[i].t == 45) {
B[i].life = 0;
br++;
B[br].what = 4;
B[br].x = B[i].x;
B[br].y = 32;
B[br].vy = 3;
B[br].life = 1;
}
}
if (B[i].what == 6 || B[i].what == 8 || B[i].what == 9) {
if (B[i].vx < 0.25 && B[i].vy < 0.25 && B[i].t >= 50) {
B[i].life = 0;
if (B[i].life == 0 && i == bl) bl++;
Map(1, i);
break;
}
if (B[i].t % 5 == 0) B[i].How = rand() % 4;
if (B[i].what == 9) {
if (B[i].t == 7) {
X9:
float xx = (rand() % 41) / 40.0, yy = (rand() % 41) / 40.0;
if (xx <= 0.5 && yy <= 0.5) goto X9;
for (int j = 1; j <= 4; j++) {
br++, B[br].what = 9;
B[br].t = 11;
B[br].x = B[i].x, B[br].y = B[i].y, B[br].vx = xx, B[br].vy = yy;
if (j % 2 == 0)swap(B[br].vx, B[br].vy), B[br].vy *= -1;
if (j <= 2)B[br].vx *= -1, B[br].vy *= -1;
B[br].life = 1;
}
B[i].life = 0;
}
}
if (B[i].what == 8) {
if (B[i].x > X && B[i].vx < 1.2) B[i].vx += fmax((float)0, 0.2 - B[i].t / 25);
if (B[i].x < X && B[i].vx > -1.2) B[i].vx -= fmax((float)0, 0.2 - B[i].t / 25);
if (B[i].y > Y && B[i].vy < 1.2) B[i].vy += fmax((float)0, 0.2 - B[i].t / 25);
if (B[i].y < Y && B[i].vy > -1.2) B[i].vy -= fmax((float)0, 0.2 - B[i].t / 25);
}
}
if (B[i].what >= 13 && B[i].what <= 15 && B[i].How != 0) {
if (B[i].x == B[i].How)B[i].vx = 0, B[i].How = 0;
}
if (B[i].what == 16) {
if (B[i].x < X && B[i].vx >= -1) B[i].vx -= 0.2;
else if (B[i].x > X && B[i].vx <= 1) B[i].vx += 0.2;
}
}
if (B[i].life == 1 && B[i].a == 0 && B[i].what > 0) {
if (B[i].y > Y && abs(B[i].x - X) <= 3 && ((B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y)) < Dis) Dis = (B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y), Disb = i;
else if (((B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y)) < Dis1) Dis1 = (B[i].x - X) * (B[i].x - X) + (B[i].y - Y) * (B[i].y - Y), Disb1 = i;
}
}
}
void Guai(int R, int r) {
if (R == -1) {
br++;
B[br].what = -1;
B[br].x = X + rand() % 3 - 1;
B[br].y = Y + rand() % 3 - 1;
B[br].life = 1;
}
if (R <= -2 && R >= -11) {
br++;
B[br].what = R;
B[br].x = B[br].a = r;
B[br].y = 29;
if (R <= -3 && R >= -7)B[br].vx = -1;
B[br].vy = 1;
B[br].life = 1;
}
if (R == 0) {
br++;
B[br].what = 1;
B[br].x = r;
B[br].y = 29;
B[br].vy = 1;
B[br].life = 1;
}
if (R == 1) {
br++;
B[br].what = 2;
B[br].x = r;
B[br].y = 29;
B[br].vy = 1;
B[br].life = 1;
}
if (R == 2 || R == 3) {
br++;
B[br].what = 2 * R - 1;
B[br].x = r;
B[br].y = 29;
B[br].vy = 1;
B[br].life = 1;
}
if (R == 4) {
br++;
B[br].what = 6;
if (r < 5)r = 5;
if (r > 30)r = 30;
B[br].x = r;
if (r == 11 || r == 25) B[br].y = 29 - (rand() % 20);
else B[br].y = 29;
X4:
B[br].vx = (rand() % 21 - 10) / 30.0;
B[br].vy = (rand() % 25) / 30.0;
if (B[br].vx <= 0.8 && B[br].vy <= 0.8)goto X4;
int rx = rand() % 50;
if (rx == 0) B[br].vx = 0;
B[br].life = 1;
}
if (R == 5) {
br++;
B[br].How = r;
B[br].what = 7;
if (B[br].How < 0) B[br].x = 19;
if (B[br].How > 0) B[br].x = 21;
B[br].y = 29;
B[br].vy = 1;
B[br].life = 1;
}
}
void CpGuai(int R, float x, float y, float xx, float yy) {
if (R == 4) {
br++;
B[br].what = 6;
B[br].x = x;
B[br].y = y;
B[br].vx = xx;
B[br].vy = yy;
B[br].life = 1;
}
if (R == 6 || R == 7 || R == 8) {
br++;
B[br].what = 4 + R;
B[br].x = x;
B[br].y = y;
B[br].vx = xx;
B[br].vy = yy;
B[br].life = 1;
}
}
void MesGuai(int a, int rr) {
int R = rand() % rr, r = -10086;
if (R == 0) {
if (a == 1) r = (5 + rand() % 8) * 2;
if (a <= 3 && a != 1) r = 10 + rand() % 16;
if (a == 4) r = rand() % 75 - 20;
if (a == 5) r = 2 + rand() % 4;
if (r != -10086) Guai(a, r);
}
}
void NorGuai(int a, int b) {
if (a == 1) {
if (b == 1 || b == 41) Guai(0, 15), Guai(0, 17), Guai(0, 19);
if (b == 21 || b == 61) Guai(0, 21), Guai(0, 23), Guai(0, 25);
if (b == 81) Guai(0, 11), Guai(0, 13), Guai(0, 15), Guai(0, 17), Guai(0, 19);
if (b == 101 || b == 141) Guai(0, 17), Guai(0, 19), Guai(0, 21), Guai(0, 23), Guai(0, 25);
if (b == 121) Guai(0, 15), Guai(0, 17), Guai(0, 19), Guai(0, 21), Guai(0, 23);
if (b >= 160 && b <= 260 && b % 10 == 0) Guai(0, b / 10 - 1);
if (b >= 270 && b <= 370 && b % 10 == 0) Guai(0, 52 - b / 10);
if (b >= 460 && b <= 560 && b % 10 == 0) Guai(0, b / 10 - 37), Guai(0, b / 10 - 36), Guai(0, b / 10 - 35);
if (b >= 570 && b <= 670 && b % 10 == 0) Guai(0, 78 - b / 10), Guai(0, 77 - b / 10), Guai(0, 76 - b / 10);
if (b >= 760 && b <= 960 && b % 10 == 0) Guai(0, b / 10 - 66), Guai(0, b / 10 - 65), Guai(0, 103 - b / 10), Guai(0, 104 - b / 10);
if (b >= 1000 && b <= 1300) MesGuai(0, 30 - b / 50);
}
if (a == 2) {
if (b <= 200 && b % 30 == 1) {
int r = rand() % 4;
if (r == 1) r = 0;
for (int i = 0; i < 4; i++) if (i != r) Guai(1, i * 4 + 9);
}
if (b > 200 && b <= 220 && b % 5 == 1) Guai(1, 18);
if (b > 220 && b <= 300 && b % 7 == 1) Guai(1, b / 5 - 26);
if (b > 350 && b <= 370 && b % 5 == 1) Guai(1, 22);
if (b > 370 && b <= 450 && b % 7 == 1) Guai(1, 96 - b / 5);
if (b == 461 || b == 501 || b == 541) Guai(1, 13), Guai(1, 17), Guai(1, 21);
if (b == 481 || b == 521 || b == 561) Guai(1, 17), Guai(1, 21), Guai(1, 25);
if (b >= 561 && b <= 861 && b % 20 == 1) Guai(1, b / 40 + 5);
if (b >= 561 && b <= 861 && b % 20 == 11) Guai(1, 35 - b / 40);
if (b >= 801 && b <= 961 && b % 15 == 1) Guai(1, 20);
if (b >= 1000 && b <= 1300) MesGuai(1, 30 - b / 50);
}
if (a == 3) {
if (b == 1 || b == 61) Guai(3, 15), Guai(2, 17), Guai(2, 19);
if (b == 31 || b == 91) Guai(2, 21), Guai(2, 23), Guai(3, 25);
if (b >= 120 && b <= 220 && b % 10 == 0) Guai(2, b / 10 + 3);
if (b >= 240 && b <= 340 && b % 10 == 0) Guai(2, 49 - b / 10);
if (b >= 360 && b <= 460 && b % 20 == 0) Guai(2, b / 10 - 21), Guai(2, 61 - b / 10);
if (b >= 480 && b <= 580 && b % 20 == 0) Guai(3, b / 10 - 33), Guai(3, 73 - b / 10);
if (b >= 600 && b < 750 && b % 30 == 0) {
for (int i = 0; i < 5; i++) Guai(3, i * 3 + 10);
}
if (b >= 750 && b < 830 && b % 10 == 0) if (b <= 200 && b % 40 == 1) Guai(2, X);
if (b >= 830 && b < 910 && b % 20 == 0) Guai(2, X);
if (b >= 910 && b < 980 && b % 10 == 0) Guai(2, X);
if (b >= 1000 && b <= 1300) MesGuai(rand() % 2 + 2, 40 - b / 50);
}
if (a == 4) {
if (b == 1) CpGuai(4, 10, 29, -0.4, 0.7), CpGuai(4, 14, 29, -0.2, 0.7), CpGuai(4, 21, 29, 0, 0.65);
if (b == 41) CpGuai(4, 10, 29, -0.2, 0.7), CpGuai(4, 14, 29, -0.1, 0.7), CpGuai(4, 18, 29, 0, 0.65);
if (b == 81) CpGuai(4, 5, 20, -0.4, 0.35), CpGuai(4, 10, 29, -0.4, 0.7), CpGuai(4, 14, 29, -0.2, 0.7), CpGuai(4, 30, 20, 0.25, 0.4), CpGuai(4, 21, 29, 0, 0.65);
if (b == 121) CpGuai(4, 5, 20, -0.2, 0.35), CpGuai(4, 10, 29, -0.2, 0.7), CpGuai(4, 14, 29, -0.1, 0.7), CpGuai(4, 30, 20, 0.4, 0.4), CpGuai(4, 18, 29, 0, 0.65);
if (b == 161) CpGuai(4, 10, 29, -0.4, 0.7), CpGuai(4, 14, 29, -0.2, 0.7), CpGuai(4, 21, 29, 0, 0.6), CpGuai(4, 10, 29, -0.2, 0.7), CpGuai(4, 14, 29, -0.1, 0.7), CpGuai(4, 18, 29, 0, 0.65);
if (b >= 200 && b <= 500 && b % 40 == 1) {
float r = 0, rr;
for (int i = 1; i <= 5; i++) {
X5:
rr = 0.7 + (rand() % 5) / 10.0;
if (rr == r)goto X5;
r = rr;
CpGuai(4, i * 3 + 7, 29, 0, 0.5 + (rand() % 50) / 80.0);
}
}
if (b > 540 && b <= 565 && b % 5 == 1) CpGuai(4, 5, 8, -2, 0.2);
if (b > 590 && b <= 615 && b % 5 == 1) CpGuai(4, 30, 8, 1.5, 0.2);
if (b > 640 && b <= 665 && b % 5 == 1) CpGuai(4, 5, 8, -1.5, 0.3);
if (b > 690 && b <= 715 && b % 5 == 1) CpGuai(4, 30, 8, 2, 0.3);
if (b >= 750 && b <= 950 && b % 20 == 1) {
float r = 0, rr;
for (int i = 1; i <= 3; i++) {
X6:
rr = 0.7 + (rand() % 5) / 10.0;
if (rr == r)goto X6;
r = rr;
CpGuai(4, i * 5 + 7 + (rand() % 3), 29, 0, 0.5 + (rand() % 50) / 200.0);
}
}
if (b >= 1000 && b <= 1300) MesGuai(4, 5);
}
}
void RandGood() {
if (Biao > 0) {
Biao--;
Guai(-1, 0);
}
if (Gd[1] == 0) {
Gd[1] = rand() % 1000 + 1;
if (Win == 7)Gd[1] = 10086;
Gd[3] = rand() % 16 + 8;
} else if (Gd[1] <= 5) {
Guai(-2 - Gd[1], Gd[3]);
memset(Gd, 0, sizeof(Gd));
} else if (Gd[1] >= 20 && Gd[1] < 27) {
Guai(-8, Gd[3]);
memset(Gd, 0, sizeof(Gd));
} else if (Gd[1] >= 30 && Gd[1] < 37) {
Guai(-9, Gd[3]);
memset(Gd, 0, sizeof(Gd));
} else if (Gd[1] >= 40 && Gd[1] < 70) {
Gd[2]++;
if (Gd[2] % 2 == 1)Guai(-10, Gd[3]);
if (Gd[2] >= 9)memset(Gd, 0, sizeof(Gd));
} else if (Gd[1] >= 70 && Gd[1] < 100) {
Gd[2]++;
if (Gd[2] % 2 == 1)Guai(-11, Gd[3]);
if (Gd[2] >= 9)memset(Gd, 0, sizeof(Gd));
} else if (Boss != 0 && Gd[1] >= 450 && Gd[1] <= 500) {
Guai(-2, Gd[3]);
memset(Gd, 0, sizeof(Gd));
} else Gd[1] = 0;
for (int i = 0; i < 20; i++) {
if (I[i][0] == -1) continue;
Setpos(I[i][0], I[i][1]);
Color(0);
if (I[i][0] == 20) cout << "===";
else cout << " ";
I[i][1]++;
if (I[i][0] >= 28 || I[i][0] <= 0 || I[i][1] >= 29) I[i][0] = I[i][1] = -1;
else Color(1), Setpos(I[i][0], I[i][1]), cout << "■";
Color(0);
}
}
void Panboss(int bx, int by) {
float Nox[4], Noy[4];
Nox[0] = X, Noy[0] = Y;
if (Down == 1 && X == 22) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
else if (Down == 2) Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
else if (Down == 1 || X < 18) Nox[1] = X - 1, Noy[1] = Y - 0.5, Nox[2] = -10, Noy[2] = -10;
else Nox[1] = X + 1, Noy[1] = Y - 0.5, Nox[2] = X - 1, Noy[2] = Y - 0.5;
for (int i = 0; i < 3; i++) {
if ((Boss == 1 || Boss == 6) && Wind == 0 && Thun == 0 && abs(Nox[i] - bx) < 1 && abs(Noy[i] - by) < 1 && Bgo1[4] == 0) Blo -= 20, Bgo1[4] = 1, Killb = 20, Kill = 1;
if ((Boss == 2 || Boss == 6) && Wind == 0 && Thun == 0 && abs(Nox[i] - bx) < 1 && abs(Noy[i] - by) < 1 && Bgo2[8] == 0) Blo -= 20, Bgo2[8] = 1, Killb = 20, Kill = 1;
}
}
void Boss1() {
for (int j = 0; j < 20; j++)if (abs(Bx1 - I[j][0]) < 2 && By1 - I[j][1] <= 2) {
Setpos(I[j][0], I[j][1]);
if (I[j][0] == 20) cout << "===";
else cout << " ";
I[j][0] = I[j][1] = -1;
Bblo -= 8 + Lv * 2;
Exp += 2;
}
if (Bbr == Bbl && Bbr != 0) Bbr = Bbl = 0;
for (int i = 1; i <= 3 + (Bbl - Bbr) / 5; i++)if (Bbr < Bbl) {
Setpos(Bway[Bbr][0], Bway[Bbr][1]);
if (Bway[Bbr][0] == 20) cout << "==";
else cout << " ";
Bbr++;
}
if (Bwhat1 == 5) {
int bx, by;
Color(5);
for (int i = 0; i < 10; i++) {
bx = Bx1 - i*Bvx1 / 10.0;
by = By1 - i*Bvy1 / 10.0;
Setpos(bx, by), cout << "█";
Bbl++;
Bway[Bbl][0] = bx;
Bway[Bbl][1] = by;
}
Color(0);
}
Bx1 -= Bvx1;
By1 -= Bvy1;
if (Bwhat1 == 0) {
X2:
Bwhat1 = rand() % 7;
if (Bwhat1 == 2 || Bwhat1 == 3) {
if (By1 <= 10 || By1 > 25) goto X2;
}
if (Bwhat1 == 4) {
if (By1 <= 15 || Bx1 < 20) goto X2;
Bgo1[2] = Bx1;
Bgo1[3] = By1 - 1;
}
if (Bwhat1 == 5) {
X0:
Bgo1[3] = rand() % 4 + 1;
Bvx1 = (rand() % 101) / 20.0;
Bvy1 = (rand() % 101) / 20.0;
if (Bgo1[3] <= 2) Bvx1 *= -1;
if (Bgo1[3] % 2 == 1) Bvy1 *= -1;
if (abs(Bvx1) + abs(Bvy1) <= 3 || Out1)goto X0;
}
if (Bwhat1 == 6) {
if (By1 <= 17 || By1 > 25) goto X2;
}
}
if (Bwhat1 == 1) {
Bgo1[1]++, Bgo1[2]++;
int R = rand() % (5 - Bgo1[1]), r = rand() % (10 - Bgo1[2]);
if (Out1) R = 0;
if (R == 0) {
int vx = Bvx1, vy = Bvy1;
Bgo1[1] = 0;
Bvx1 = (rand() % 101 - 20) / 50.0;
Bvy1 = (rand() % 101 - 20) / 50.0;
if (Bgo1[3] <= 2) Bvx1 *= -1;
if (Bgo1[3] % 2 == 1) Bvy1 *= -1;
if (Out1) r = 0;
}
if (r == 0) Chang1
}
if (Bwhat1 == 2) {
Bgo1[1]++;
if (Bgo1[1] > 6) {
Bvy1 = -0.3;
br++;
B[br].x = Bx1, B[br].y = By1 - 1;
B[br].what = 6;
X3:
B[br].vx = (rand() % 21 - 10) / 40.0;
B[br].vy = (rand() % 25) / 30.0;
if (B[br].vx <= 0.8 && B[br].vy <= 0.8)goto X3;
int rx = rand() % 50;
if (rx == 0) B[br].vx = 0;
B[br].life = 1;
}
if (Bgo1[1] > 8) Chang1
}
if (Bwhat1 == 3) {
Bgo1[1]++;
if (Bgo1[1] > 6 && Bgo1[1] % 3 == 0) {
Bvy1 = -0.3;
br++;
B[br].x = Bx1, B[br].y = By1 - 1;
B[br].what = 8;
B[br].life = 1;
}
if (Bgo1[1] > 15) Chang1
}
if (Bwhat1 == 4) {
Bgo1[1]++;
if (Bgo1[1] <= 8) {
Setpos(Bgo1[2], Bgo1[3]);
if (Bgo1[1] == 1)cout << " ";
else if (Bgo1[1] > 1 && Bgo1[2] == 20) cout << "==";
else cout << " ";
Bgo1[2]--;
Setpos(Bgo1[2], Bgo1[3]);
int r = rand() % 4;
if (r % 2 == 0) Color(6);
else Color(9);
if (r < 2) cout << ") ";
else cout << "】";
Color(0);
}
if (Bgo1[1] == 6) Bgo1[5] = X, Bgo1[6] = Y;
if (Bgo1[1] == 11) {
Map(0, (bool)Kill);
Setpos(Bgo1[5], Bgo1[6] + 1), cout << " ";
Setpos(Bgo1[5], Bgo1[6] - 1), cout << " ";
Setpos(Bgo1[5] + 1, Bgo1[6]), cout << " ";
Setpos(Bgo1[5] - 1, Bgo1[6]), cout << " ";
int bx, by, bvx = Bgo1[2] - Bgo1[5], bvy = Bgo1[3] - Bgo1[6];
Color(6);
int i = 0;
while (1) {
bx = Bgo1[2] - i*bvx / 30.0;
by = Bgo1[3] - i*bvy / 30.0;
if (bx <= 5 || bx >= 30 || by < 0 || by >= 29) break;
Panboss(bx, by);
Setpos(bx, by), cout << "█";
Bbl++;
Bway[Bbl][0] = bx;
Bway[Bbl][1] = by;
i++;
}
Color(0);
Map(-1, 0);
Chang1
}
}
if (Bwhat1 == 5) {
Bgo1[1]++, Bgo1[2]++;
int R = rand() % (5 - Bgo1[1]), r = rand() % (10 - Bgo1[2]);
if (Out1) R = 0;
if (R == 0) {
int vx = Bvx1, vy = Bvy1;
Bgo1[1] = 0;
X1:
Bvx1 = (rand() % 101 - 20) / 20.0;
Bvy1 = (rand() % 101 - 20) / 20.0;
if (Bgo1[3] <= 2) Bvx1 *= -1;
if (Bgo1[3] % 2 == 1) Bvy1 *= -1;
if (abs(Bvx1) + abs(Bvy1) <= 3 || abs(Bvx1 - vx) <= 1 || abs(Bvy1 - vy) <= 1)goto X1;
if (Out1) r = 0;
}
if (r == 0) Chang1
}
if (Bwhat1 == 6) {
Bgo1[1]++;
if (Bgo1[1] > 6 && Bgo1[1] % 10 == 0) {
By1 -= 1;
br++;
B[br].x = Bx1, B[br].y = By1 - 1;
B[br].what = 9;
X30:
B[br].vy = 1;
B[br].life = 1;
}
if (Bgo1[1] > 31) Chang1
}
}
void Boss2() {
for (int j = 0; j < 20; j++)if (abs(Bx2 - I[j][0]) < 2 && By2 - I[j][1] <= 2) {
Setpos(I[j][0], I[j][1]);
if (I[j][0] == 20) cout << "===";
else cout << " ";
I[j][0] = I[j][1] = -1;
Bblo -= 8 + Lv * 2;
Exp += 2;
}
if (Bbr == Bbl && Bbr != 0) Bbr = Bbl = 0;
for (int i = 1; i <= 3 + (Bbl - Bbr) / 5; i++)if (Bbr < Bbl) {
Setpos(Bway[Bbr][0], Bway[Bbr][1]);
if (Bway[Bbr][0] == 20) cout << "==";
else cout << " ";
Bbr++;
}
Bx2 -= Bvx2;
By2 -= Bvy2;
if (Bwhat2 == 0) {
X21:
Bwhat2 = rand() % 7;
if (Bwhat2 == 2) {
X31:
for (int i = 1; i <= 3; i++) {
Bgo2[i * 2 + 1] = rand() % 28 + 1, Bgo2[i * 2] = rand() % 25 + 5;
if ((abs(Bgo2[i * 2] - Bx2) <= 2 && abs(Bgo2[i * 2 + 1] - By2) <= 2) || (abs(Bgo2[i * 2] - X) <= 2 && abs(Bgo2[i * 2 + 1] - Y) <= 2))goto X31;
}
if (Bgo2[2] == Bgo2[4] || Bgo2[2] == Bgo2[6] || Bgo2[6] == Bgo2[4] || Bgo2[5] == Bgo2[3] || Bgo2[3] == Bgo2[7] || Bgo2[5] == Bgo2[7]) goto X31;
}
if (Bwhat2 == 3) {
Bgo2[2] = rand() % 2;
}
if (Bwhat2 == 4 || Bwhat2 == 5 || Bwhat2 == 6) {
Bvy2 = -1.5;
Bvx2 = -0.5;
}
}
if (Bwhat2 == 1) {
Bgo2[1]++, Bgo2[2]++;
int R = rand() % (5 - Bgo2[1]), r = rand() % (30 - Bgo2[2]);
if (Out2) R = 0;
if (R == 0) {
int vx = Bvx2, vy = Bvy2;
Bgo2[1] = 0;
Bvx2 = (rand() % 101 - 20) / 50.0;
Bvy2 = (rand() % 101 - 20) / 50.0;
if (Bgo2[3] <= 2) Bvx2 *= -1;
if (Bgo2[3] % 2 == 1) Bvy2 *= -1;
if (Out2) r = 0;
}
if (r == 0) Chang2
}
if (Bwhat2 == 2) {
Bgo2[1]++;
float bx, by, bvx, bvy;
if (Bgo2[1] < 21) {
for (int i = 1; i <= 3; i++) {
bvx = Bgo2[i * 2] - Bx2, bvy = Bgo2[i * 2 + 1] - By2;
if (Bgo2[1] <= 10) {
Setpos(Bx2 + (Bgo2[1] - 1)*bvx / 10.0, By2 + (Bgo2[1] - 1)*bvy / 10.0);
if (abs(Bx2 + (Bgo2[1] - 1) * bvx / 10.0 - 20) < 0.5)cout << "==";
else cout << " ";
bx = Bx2 + Bgo2[1] * bvx / 10.0;
by = By2 + Bgo2[1] * bvy / 10.0;
Setpos(bx, by);
} else Setpos(Bgo2[i * 2], Bgo2[i * 2 + 1]);
int r = rand() % 4;
if (r % 2 == 0) Color(3);
else Color(10);
if (r <= 1) cout << "×";
else cout << "+";
Color(0);
}
}
if (Bgo2[1] == 21) {
Map(0, (bool)Kill);
Color(3);
int j = 0;
for (int j = 0; j <= 30; j++)for (int i = 1; i <= 3; i++)for (int k = 1; k <= 4; k++) {
if (k == 1) bvx = j, bvy = 0;
if (k == 2) bvx = -j, bvy = 0;
if (k == 3) bvx = 0, bvy = j;
if (k == 4) bvx = 0, bvy = -j;
bx = Bgo2[i * 2] + bvx, by = Bgo2[i * 2 + 1] + bvy;
if (bx <= 5 || bx >= 30 || by < 0 || by >= 30) {
continue;
}
Panboss(bx, by);
Setpos(bx, by), cout << "█";
Bbl++;
Bway[Bbl][0] = bx;
Bway[Bbl][1] = by;
}
Color(0);
Map(-1, 0);
Chang2
}
}
if (Bwhat2 == 3) {
Bgo2[1]++;
if (Bgo2[1] <= 18) {
if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << " ", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << " ", Color(0), Setpos(20, Bgo2[5]), cout << "==";
if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3.5), cout << " ", Setpos(Bgo2[4], Bgo2[5] + 2.5), cout << " ", Color(0), Setpos(20, Bgo2[5] + 2.5), cout << "====", Setpos(20, Bgo2[5] - 3.5), cout << "====";
if (Bgo2[1] % 4 == 0)Bgo2[3] = !Bgo2[3];
if (Bgo2[1] % 6 < 3)Color(3);
else Color(5);
if (Bgo2[3] == 0) Setpos(X - 3, Y), cout << "▼", Setpos(X + 3, Y), cout << "▲", Bgo2[4] = (int)(X + 0.5), Bgo2[5] = (int)(Y + 0.5);
if (Bgo2[3] == 1) Setpos(X, Y - 3), cout << " ", Setpos(X, Y + 3), cout << " ", Bgo2[4] = (int)(X + 0.5), Bgo2[5] = (int)(Y + 0.5);
Color(0);
}
if (Bgo2[1] == 18) {
if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << " ", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << " ", Color(0), Setpos(20, Bgo2[5]), cout << "==";
if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3.5), cout << " ", Setpos(Bgo2[4], Bgo2[5] + 2.5), cout << " ", Color(0), Setpos(20, Bgo2[5] + 2.5), cout << "====", Setpos(20, Bgo2[5] - 3.5), cout << "====";
}
if (Bgo2[1] > 18 && Bgo2[1] <= 25) {
Bgo2[3] = Bgo2[2];
if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << " ", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << " ", Color(0), Setpos(20, Bgo2[5]), cout << "==";
if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3.5), cout << " ", Setpos(Bgo2[4], Bgo2[5] + 2.5), cout << " ", Color(0), Setpos(20, Bgo2[5] + 2.5), cout << "====", Setpos(20, Bgo2[5] - 3.5), cout << "====";
if (Bgo2[1] % 4 < 2)Color(3);
else Color(5);
if (Bgo2[3] == 0) Setpos(Bgo2[4] - 3, Bgo2[5]), cout << "▼", Setpos(Bgo2[4] + 3, Bgo2[5]), cout << "▲";
if (Bgo2[3] == 1) Setpos(Bgo2[4], Bgo2[5] - 3), cout << " ", Setpos(Bgo2[4], Bgo2[5] + 3), cout << " ";
Color(0);
}
if (Bgo2[1] == 25) {
if (Bgo2[2] == 0) {
Color(3);
for (int i = 4; i <= 29; i++) {
Setpos(i, Bgo2[5]), cout << "█";
Bbl++;
Panboss(i, Bgo2[5]);
Bway[Bbl][0] = i;
Bway[Bbl][1] = Bgo2[5];
}
}
if (Bgo2[2] == 1) {
Color(3);
for (int i = 0; i <= 28; i++) {
Setpos(Bgo2[4], i), cout << "█";
Bbl++;
Panboss(Bgo2[4], i);
Bway[Bbl][0] = Bgo2[4];
Bway[Bbl][1] = i;
}
}
Chang2
}
}
if (Bwhat2 == 4 || Bwhat2 == 5 || Bwhat2 == 6) {
Bgo2[1]++;
if (By2 > 27)Bvy2 = 0;
if (Bx2 > 23)Bvx2 = 0;
if (Bgo2[1] > 13 && Bgo2[1] % 3 == 0) {
float t = By2 - Y, g = 0.35;
if (Boss == 6) t /= 2.0;
CpGuai(Bwhat2 + 2, Bx2, By2, (Bx2 - X) / t * 1.0 + (t - 1)*g / 2.0, 1);
}
if (Bgo2[1] > 20) Chang2
}
}
void Boss3() {
#define Bean br++;B[br].what=13;B[br].x=Bx3-1,B[br].y=By3-1;B[br].vy=1;B[br].life=1;
for (int j = 0; j < 20; j++)if (abs(Bx3 - I[j][0]) < 2 && By3 - I[j][1] <= 2) {
Setpos(I[j][0], I[j][1]);
if (I[j][0] == 20) cout << "===";
else cout << " ";
I[j][0] = I[j][1] = -1;
Bblo -= 8 + Lv * 2;
Exp += 2;
}
Bx3 -= Bvx3;
By3 -= Bvy3;
if (Bwhat3 <= 8) {
if (Bx3 > X && Bvx3 < 1.5) Bvx3 += 0.3;
if (Bx3 < X && Bvx3 > -1.5) Bvx3 -= 0.3;
}
if (Bwhat3 == 0) {
X22:
Bwhat3 = rand() % 12;
if (Bwhat3 == 11 && abs(Bx3 - 20) <= 1)goto X22;
if (Bwhat3 == 11)Bgo3[2] = rand() % 5;
}
if (Bwhat3 == 1) {
Bgo3[1]++;
if (Bgo3[1] == 6) {
br++;
B[br].what = 13;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].vx = 1;
B[br].How = (int)Bx3 - 4;
B[br].life = 1;
br++;
B[br].what = 13;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].vx = -1;
B[br].How = (int)Bx3 + 2;
B[br].life = 1;
br++;
B[br].what = 13;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].life = 1;
Chang3
}
}
if (Bwhat3 >= 2 && Bwhat3 <= 6) {
Bgo3[1]++;
if (Bgo3[1] == 6) {
br++;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].what = 11 + Bwhat3;
B[br].vy = 0.5 + (rand() % 100) / 80.0;
if (Bwhat3 == 5)B[br].vy = B[br].vy * 3 / 4.0;
B[br].life = 1;
Chang3
}
}
if (Bwhat3 == 7) {
Bgo3[1]++;
if (Bgo3[1] == 6) {
br++;
B[br].what = 14;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].vx = 1;
B[br].How = (int)Bx3 - 4;
B[br].life = 1;
br++;
B[br].what = 14;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].vx = -1;
B[br].How = (int)Bx3 + 2;
B[br].life = 1;
br++;
B[br].what = 14;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].life = 1;
Chang3
}
}
if (Bwhat3 == 8) {
Bgo3[1]++;
if (Bgo3[1] == 6) {
br++;
B[br].what = 15;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].vx = 1;
B[br].How = (int)Bx3 - 4;
B[br].life = 1;
br++;
B[br].what = 15;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].vx = -1;
B[br].How = (int)Bx3 + 2;
B[br].life = 1;
br++;
B[br].what = 15;
B[br].x = (int)Bx3 - 1, B[br].y = By3 - 1;
B[br].vy = 1;
B[br].life = 1;
Chang3
}
}
if (Bwhat3 == 9) {
Bvx3 = 0;
Bgo3[1]++;
if (Bgo3[1] == 6 || Bgo3[1] == 8) {
Bean
}
if (Bgo3[1] >= 8)Chang3
}
if (Bwhat3 == 10) {
Bvx3 = 0;
Bgo3[1]++;
if (Bgo3[1] == 6 || Bgo3[1] == 8 || Bgo3[1] == 10 || Bgo3[1] == 12) {
Bean
}
if (Bgo3[1] >= 12)Chang3
}
if (Bwhat3 == 11) {
Bvx3 = 0;
Bgo3[1]++;
if (Bgo3[1] >= 8)for (int i = 1; i <= 4; i++) {
br++;
B[br].what = 80 + 100 * Bgo3[2] + Bgo3[1] * 4 + i;
B[br].x = Bx3 - 1, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
br++;
B[br].what = 99;
B[br].x = Bx3, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
br++;
B[br].what = 99;
B[br].x = Bx3 - 2, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
}
if (Bgo3[1] >= 20) {
for (int i = 1; i <= 4; i++) {
br++;
B[br].what = 98;
B[br].x = Bx3 - 1, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
br++;
B[br].what = 98;
B[br].x = Bx3, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
br++;
B[br].what = 98;
B[br].x = Bx3 - 2, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
}
Chang3
}
}
}
void Ball(int ball) {
if (ball == 1) {
if (Fir < 3 && T % 8 == 0) Fir++;
if (Fir > 0) {
br++;
B[br].what = -13;
B[br].x = X;
B[br].y = Y + rand() % 3 - 1;
B[br].life = 1;
if (Dis <= 30) B[br].a = Disb, B[Disb].a = 1, Fir--;
else if (Boss != 0) B[br].a = 13880086, Fir--;
else if (Dis != 13880087) B[br].a = Disb, B[Disb].a = 1, Fir--;
else if (Dis1 != 13880087) B[br].a = Disb1, B[Disb1].a = 1, Fir--;
else B[br].life = 0;
Dis = Dis1 = 13880087;
}
}
if (ball == 2) {
if (T % 4 == 0)ib = (ib + 1) % 20, I[ib][1] = Y - 2;
if (T % 16 == 0)I[ib][0] = X;
if (T % 16 == 4)I[ib][0] = X - 1;
if (T % 16 == 8)I[ib][0] = X + 1;
if (T % 16 == 12)I[ib][0] = X - 2;
if (T % 12 == 9)I[ib][0] = X + 2;
if (Water == 1) {
for (int i = X - 6; i <= X + 6; i++)ib = (ib + 1) % 20, I[ib][0] = i, I[ib][1] = Y - 2 - 0.5 * abs(i - X);
}
}
if (ball == 3) {
if (Wind > 5) {
if (Y < Ding - 1)Vy = 5;
else Vy = 0;
if (Up >= 1) Vx = -5;
if (Down == 2) Vx = 5;
}
if (Wind < 5) {
if (Y > Ding - 1)Vy = -5;
else Vy = 0;
if (Up >= 1) Vx = -5;
if (Down == 2) Vx = 5;
}
if (Wind == 5) {
if (Boss == 2) Ding = 12.25;
else Ding = 6.25;
if (Boss != 0) Bblo -= 16 + Lv * 4;
if (Boss == 1) Chang1 if (Boss == 2) Chang2 if (Boss == 3) Chang3 system("color 3F");
Sleep(20);
system("color 6F");
Sleep(10);
system("color 0F");
system("cls");
for (int i = bl; i <= br; i++)if (B[i].what > 0)B[i].life = 0;
Setpos(20, 0);
for (int i = 1; i <= 60; i++) printf("=");
}
}
if (ball == 4) {
if (Thun == 1) {
if (Boss != 0) Bblo -= 16 + Lv * 4;
if (Boss == 1) Chang1 if (Boss == 2) Chang2 if (Boss == 3) Chang3 system("color 9F");
Sleep(20);
system("color 6F");
Sleep(10);
system("color 0F");
system("cls");
for (int i = bl; i <= br; i++)if (B[i].what > 0)B[i].life = 0;
Setpos(20, 0);
for (int i = 1; i <= 60; i++) printf("=");
}
}
if (ball == 5) {
system("cls");
Color(5);
Setpos(10, 10);
cout << "新天赋!";
Y:
int rr = rand() % 4 + 2;
Setpos(12, 10);
if (rr == Ren) goto Y;
if (rr == 2)cout << "瞬跳";
if (rr == 3)cout << "空之舞";
if (rr == 4)cout << "三段跳";
if (rr == 5)cout << "反重力跳跃";
Setpos(14, 10);
cout << "当前天赋:";
if (Ren == 1)cout << "小无敌";
if (Ren == 2)cout << "瞬跳";
if (Ren == 3)cout << "空之舞";
if (Ren == 4)cout << "三段跳";
if (Ren == 5)cout << "反重力跳跃";
Setpos(16, 10);
cout << "换否?(y/n)";
G:
char g = _getch();
if (g == 'y')Ren = rr;
else if (g != 'n')goto G;
system("cls");
Setpos(20, 0);
Color(0);
for (int i = 1; i <= 60; i++) printf("=");
}
if (ball == 6) {
Color(4);
for (float i = 1; i <= Bblo; i += Bblomax / 20.0)cout << "▄";
Color(0);
cout << ' ' << Bblo << " ";
Color(0);
}
if (ball == 7) {
Color(1);
if (Win == 7 && T % 6 < 3)Color(3);
for (float i = 1; i <= Blo; i += Blomax / 20.0)cout << "▄";
Color(0);
if (Win == 7 && T % 6 < 3)Color(3);
printf(" %0.1f ", Blo);
}
}
int main() {
system("mode con cols=60 lines=37");
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
srand((unsigned)time(NULL));
Win = 0;
Ren = 1;
Lv = 1;
Blo = Blomax = 100;
Expmax = 300;
Hui = 15;
X = 18, Y = 6;
ReStart:
system("cls");
memset(B, 0, sizeof(B));
memset(I, -1, sizeof(I));
T = 0;
bl = 0;
br = -1;
Upt = 0;
Start:
Blo = Blomax * 100;
Ding = 6.25;
memset(Bgo1, 0, sizeof(Bgo1));
memset(Bgo2, 0, sizeof(Bgo2));
memset(Bgo3, 0, sizeof(Bgo3));
if (Win % 2 == 0) T = 0;
if (Win % 2 == 0 && D == 0) {
if (Win > 0)Ball(5);
Boss = 0;
lL:
L = rand() % 4 + 1;
for (int i = 0; i <= Win / 2 - 1; i++)if (L == Ll[i]) goto lL;
Ll[Win / 2] = L;
}
if (Win % 2 == 1 && D == 0) {
if (Win == 7)Boss = 6, T = 0, Blomax += 100;
else {
bl:
Boss = rand() % 3 + 1;
for (int i = 0; i <= 3; i++)if (Boss == Bl[i]) goto bl;
}
Bl[Win / 2] = Boss;
Bwhat1 = Bwhat2 = Bwhat3 = 0, Bx1 = 10, By1 = 20, Bx2 = 15, By2 = 20, Bx3 = 21, By3 = 20;
system("color 4C");
Sleep(20);
system("color 0F");
Map(0, 1);
Sleep(1000);
}
if (Win % 2 == 1) {
Bblomax = 500 + (Win / 2) * 500;
Bblo = Bblomax;
if (Boss == 2) Ding = 12.25;
}
while (1) {
T++;
if (Wind == 0) {
if (GetAsyncKeyState(VK_LEFT) & 0x8000) Vy = -(10 - abs(Ding - Y) * 1.5) / 20.0;
if (GetAsyncKeyState(VK_RIGHT) & 0x8000) Vy = (10 - abs(Ding - Y) * 1.5) / 20.0;
}
if (GetAsyncKeyState(VK_UP) & 0x8000 && u1 == 0) {
u1++;
if (Down == 1) {
Down = 0;
Up = 0;
if (Ren == 2)Map(-1, 0), Vx = 0, X = 18, Li = 5;
else Vx = 7, Vy = 0.3;
} else if (Up == 0 && Wind == 0) {
Down = 0;
Up = 1;
if (Ren == 2)Map(-1, 0), Vx = 1, X = 10, Map(0, 3), Li = 5;
else Vx = 2, Vy = 0.1;
} else if (Up == 1 && Wind == 0) {
Down = 0;
Up = 2;
if (Ren == 2)Map(-1, 0), Vx = 1, X -= 6, Map(0, 3), Li = 5;
else Vx = 1.5, Vy = 0.1;
} else if (Ren == 3 && Up == 2 && Wind == 0) {
Down = 0;
Up = 3;
Vx = 1;
Vy = 0.5;
Upt = 30;
} else if (Ren == 4 && Up == 2 && Wind == 0) {
Down = 0;
Up = 3;
Vx = 1.8;
Vy = 0.1;
}
}
if (GetAsyncKeyState(VK_DOWN) & 0x8000 && u2 == 0) {
u2++;
if (Down == 1 && Ren == 5) {
Down = 2;
Up = 0;
Vx = -1.7;
} else {
Down = 1;
Up = 0;
if (Ren == 2)Map(-1, 0), Vx = 0, X = 22, Map(0, 3), Li = 5;
else {
if (Upt != 0) Map(-1, 0), Upt = 0;
Vx = -7;
}
}
}
if ((GetAsyncKeyState(VK_UP) & 0x8000) ? 0 : 1) u1 = 0;
if ((GetAsyncKeyState(VK_DOWN) & 0x8000) ? 0 : 1) u2 = 0;
if (kbhit()) {
char g = _getch();
if (g == ' ') Sleep(100), Setpos(4, 1), Sy++, system("pause");
}
if (Sy == 1) Setpos(4, 1), printf(" "), Sy--;
if (Drug == 0) Blo = fmin((float)Blomax, Blo + Hui / 100.0);
else if (T % 10 == 0)Blo--;
if (T % 20 == 0) {
if (Kill != 0) Kill = 0;
if (Lvl != 0) Lvl = 0;
}
if (Killb > 0) Killb--;
if (Li > 0) Li--;
if (Ice > 0) Ice--;
if (Drug > 0) Drug--;
if (Magne > 0) Magne--;
if (Fire > 0) Ball(1), Fire--;
if (Water > 0) Ball(2), Water--;
if (Wind > 0) Ball(3), Wind--;
if (Thun > 0) Ball(4), Thun--;
if (Boss == 0) NorGuai(L, T % 1500);
RandGood();
if (T % 20 == 1)Exp++;
if (T % 50 == 1) {
Exp++;
system("cls");
Setpos(20, 0);
Color(0);
for (int i = 1; i <= 60; i++) printf("=");
if (Win == 0 && T < 300) {
Setpos(4, 6);
cout << "↑/↓ 跳跃/下翻,←→ 些微移动(松手即返回)";
Setpos(8, 6);
cout << "球可以开启特殊效果,经验积满(300)可提升级别。";
Setpos(8, 6);
cout << "打败 7 波即胜利,打败 BOSS 有新天赋。";
Setpos(10, 15);
cout << "空格可以暂停。";
}
}
Map(-1, 0);
if (Boss == 1) Boss1();
if (Boss == 2) Boss2();
if (Boss == 3) Boss3();
if (Boss == 6) Boss1(), Boss2(), Boss3();
Move();
Map(0, (bool)Kill);
Color(0);
Setpos(1, 1);
Blo = fmin(Blo, (float)Blomax);
if (Boss == 0)cout << "血量: " << (int)Blo << " ";
Color(0);
Setpos(1, 9), cout << "死亡次数: " << D << " ";
Setpos(2, 1);
Exp = min(Exp, Expmax);
if (Exp >= Expmax)Exp = 0, Lv++, Lvl++, Hui++, Blomax += 5;
if (Lvl > 0)Color(5);
cout << "级别: " << Lv;
Color(0);
Setpos(2, 9);
cout << "经验: " << Exp << " ";
if (Boss > 0) Setpos(3, 1), cout << "血量 : ", Ball(7);
if (Boss > 0 && Boss != 6) Setpos(4, 1), cout << "怪物血量: ", Ball(6);
if (Boss == 6) Setpos(1, 9), printf("时间: %0.1f s ", T / 15.0);
if (Win == 0) Sleep(55);
if (Win == 1) Sleep(50);
if (Win == 2) Sleep(35);
if (Win == 3) Sleep(40);
if (Win == 4) Sleep(25);
if (Win == 5) Sleep(30);
if (Win == 6) Sleep(20);
if (Win >= 7) Sleep(17);
if (Boss == 3 && Bblo <= 0) {
for (int i = 1; i <= 4; i++) {
br++;
B[br].what = 98;
B[br].x = Bx3 - 1, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
br++;
B[br].what = 98;
B[br].x = Bx3, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
br++;
B[br].what = 98;
B[br].x = Bx3 - 2, B[br].y = By3 - 1 + i;
B[br].vy = 4;
B[br].life = 1;
}
}
if ((Win % 2 == 0 && T >= 1400) || (Win % 2 == 1 && Bblo <= 0) || (Win == 7 && T >= 450) || Blo <= 0) {
Map(-1, 0);
break;
}
}
if (Blo <= 0) {
Sleep(1000);
D++;
system("color 7F");
Setpos(15, 11);
Color(4);
cout << "GAME OVER...";
Sleep(2000);
goto ReStart;
} else if (Win == 6) {
system("color 7F");
Setpos(15, 11);
Color(4);
cout << "坚持30秒 !";
Sleep(2000);
Setpos(30, 0);
Win++;
D = 0;
} else if (Win == 7) {
Sleep(1000);
system("color 6E");
Setpos(15, 11);
Color(5);
cout << "YOU WIN !";
Sleep(2000);
Setpos(30, 0);
return 0;
} else Sleep(1000), Win++, D = 0;
goto Start;
}
6.飞机大战
点击查看代码
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<string>
using namespace std;
/*=============== all the structures ===============*/
typedef struct Frame
{
COORD position[2];
int flag;
}Frame;
/*=============== all the functions ===============*/
void SetPos(COORD a)// set cursor
{
HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(out, a);
}
void SetPos(int i, int j)// set cursor
{
COORD pos={i, j};
SetPos(pos);
}
void HideCursor()
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
//把第y行,[x1, x2) 之间的坐标填充为 ch
void drawRow(int y, int x1, int x2, char ch)
{
SetPos(x1,y);
for(int i = 0; i <= (x2-x1); i++)
cout<<ch;
}
//在a, b 纵坐标相同的前提下,把坐标 [a, b] 之间填充为 ch
void drawRow(COORD a, COORD b, char ch)
{
if(a.Y == b.Y)
drawRow(a.Y, a.X, b.X, ch);
else
{
SetPos(0, 25);
cout<<"error code 01:无法填充行,因为两个坐标的纵坐标(x)不相等";
system("pause");
}
}
//把第x列,[y1, y2] 之间的坐标填充为 ch
void drawCol(int x, int y1, int y2, char ch)
{
int y=y1;
while(y!=y2+1)
{
SetPos(x, y);
cout<<ch;
y++;
}
}
//在a, b 横坐标相同的前提下,把坐标 [a, b] 之间填充为 ch
void drawCol(COORD a, COORD b, char ch)
{
if(a.X == b.X)
drawCol(a.X, a.Y, b.Y, ch);
else
{
SetPos(0, 25);
cout<<"error code 02:无法填充列,因为两个坐标的横坐标(y)不相等";
system("pause");
}
}
//左上角坐标、右下角坐标、用row填充行、用col填充列
void drawFrame(COORD a, COORD b, char row, char col)
{
drawRow(a.Y, a.X+1, b.X-1, row);
drawRow(b.Y, a.X+1, b.X-1, row);
drawCol(a.X, a.Y+1, b.Y-1, col);
drawCol(b.X, a.Y+1, b.Y-1, col);
}
void drawFrame(int x1, int y1, int x2, int y2, char row, char col)
{
COORD a={x1, y1};
COORD b={x2, y2};
drawFrame(a, b, row, col);
}
void drawFrame(Frame frame, char row, char col)
{
COORD a = frame.position[0];
COORD b = frame.position[1];
drawFrame(a, b, row, col);
}
void drawPlaying()
{
drawFrame(0, 0, 48, 24, '=', '|');// draw map frame;
drawFrame(49, 0, 79, 4, '-', '|');// draw output frame
drawFrame(49, 4, 79, 9, '-', '|');// draw score frame
drawFrame(49, 9, 79, 20, '-', '|');// draw operate frame
drawFrame(49, 20, 79, 24, '-', '|');// draw other message frame
SetPos(52, 6);
cout<<"得分:";
SetPos(52, 7);
cout<<"称号:";
SetPos(52,10);
cout<<"操作方式:";
SetPos(52,12);
cout<<" a,s,d,w 控制战机移动。";
SetPos(52,14);
cout<<" p 暂停游戏。";
SetPos(52,16);
cout<<" e 退出游戏。";
}
//在[a, b)之间产生一个随机整数
int random(int a, int b)
{
int c=(rand() % (a-b))+ a;
return c;
}
//在两个坐标包括的矩形框内随机产生一个坐标
COORD random(COORD a, COORD b)
{
int x=random(a.X, b.X);
int y=random(a.Y, b.Y);
COORD c={x, y};
return c;
}
bool judgeCoordInFrame(Frame frame, COORD spot)
{
if(spot.X>=frame.position[0].X)
if(spot.X<=frame.position[1].X)
if(spot.Y>=frame.position[0].Y)
if(spot.Y<=frame.position[0].Y)
return true;
return false;
}
void printCoord(COORD a)
{
cout <<"( "<<a.X<<" , "<<a.Y<<" )";
}
void printFrameCoord(Frame a)
{
printCoord(a.position[0]);
cout <<" - ";
printCoord(a.position[1]);
}
int drawMenu()
{
SetPos(30, 1);
cout<<"P l a n e W a r";
drawRow(3, 0, 79, '-');
drawRow(5, 0, 79, '-');
SetPos(28, 4);
cout<<"w 和 s 选择, k 确定";
SetPos(15, 11);
cout<<"1. 简单的敌人";
SetPos(15, 13);
cout<<"2. 冷酷的敌人";
drawRow(20, 0, 79, '-');
drawRow(22, 0, 79, '-');
SetPos(47, 11);
cout<<"简单的敌人:";
SetPos(51, 13);
cout<<"简单敌人有着较慢的移动速度。";
SetPos(24, 21);
cout<<"制作:LJF神犇";
int j=11;
SetPos(12, j);
cout<<">>";
//drawFrame(45, 9, 79, 17, '=', '|');
while(1)
{ if( _kbhit() )
{
char x=_getch();
switch (x)
{
case 'w' :
{
if( j == 13)
{
SetPos(12, j);
cout<<" ";
j = 11;
SetPos(12, j);
cout<<">>";
SetPos(51, 13);
cout<<" ";
SetPos(47, 11);
cout<<"简单的敌人:";
SetPos(51, 13);
cout<<"简单敌人有着较慢的移动速度,容易对付。";
}
break;
}
case 's' :
{
if( j == 11 )
{
SetPos(12, j);
cout<<" ";
j = 13;
SetPos(12, j);
cout<<">>";
SetPos(51, 13);
cout<<" ";
SetPos(47, 11);
cout<<"冷酷的敌人:";
SetPos(51, 13);
cout<<"冷酷的敌人移动速度较快,难对付哟!!!";
}
break;
}
case 'k' :
{
if (j == 8) return 1;
else return 2;
}
}
}
}
}
/*
DWORD WINAPI MusicFun(LPVOID lpParamte)
{
//DWORD OBJ;
sndPlaySound(TEXT("bgm.wav"), SND_FILENAME|SND_ASYNC);
return 0;
}
*/
/*================== the Game Class ==================*/
class Game
{
public:
COORD position[10];
COORD bullet[10];
Frame enemy[8];
int score;
int rank;
int rankf;
string title;
int flag_rank;
Game ();
//初始化所有
void initPlane();
void initBullet();
void initEnemy();
//初始化其中一个
//void initThisBullet( COORD );
//void initThisEnemy( Frame );
void planeMove(char);
void bulletMove();
void enemyMove();
//填充所有
void drawPlane();
void drawPlaneToNull();
void drawBullet();
void drawBulletToNull();
void drawEnemy();
void drawEnemyToNull();
//填充其中一个
void drawThisBulletToNull( COORD );
void drawThisEnemyToNull( Frame );
void Pause();
void Playing();
void judgePlane();
void judgeEnemy();
void Shoot();
void GameOver();
void printScore();
};
Game::Game()
{
initPlane();
initBullet();
initEnemy();
score = 0;
rank = 25;
rankf = 0;
flag_rank = 0;
}
void Game::initPlane()
{
COORD centren={39, 22};
position[0].X=position[5].X=position[7].X=position[9].X=centren.X;
position[1].X=centren.X-2;
position[2].X=position[6].X=centren.X-1;
position[3].X=position[8].X=centren.X+1;
position[4].X=centren.X+2;
for(int i=0; i<=4; i++)
position[i].Y=centren.Y;
for(int i=6; i<=8; i++)
position[i].Y=centren.Y+1;
position[5].Y=centren.Y-1;
position[9].Y=centren.Y-2;
}
void Game::drawPlane()
{
for(int i=0; i<9; i++)
{
SetPos(position[i]);
if(i!=5)
cout<<"O";
else if(i==5)
cout<<"|";
}
}
void Game::drawPlaneToNull()
{
for(int i=0; i<9; i++)
{
SetPos(position[i]);
cout<<" ";
}
}
void Game::initBullet()
{
for(int i=0; i<10; i++)
bullet[i].Y = 30;
}
void Game::drawBullet()
{
for(int i=0; i<10; i++)
{
if( bullet[i].Y != 30)
{
SetPos(bullet[i]);
cout<<"^";
}
}
}
void Game::drawBulletToNull()
{
for(int i=0; i<10; i++)
if( bullet[i].Y != 30 )
{
COORD pos={bullet[i].X, bullet[i].Y+1};
SetPos(pos);
cout<<" ";
}
}
void Game::initEnemy()
{
COORD a={1, 1};
COORD b={45, 15};
for(int i=0; i<8; i++)
{
enemy[i].position[0] = random(a, b);
enemy[i].position[1].X = enemy[i].position[0].X + 3;
enemy[i].position[1].Y = enemy[i].position[0].Y + 2;
}
}
void Game::drawEnemy()
{
for(int i=0; i<8; i++)
drawFrame(enemy[i].position[0], enemy[i].position[1], '-', '|');
}
void Game::drawEnemyToNull()
{
for(int i=0; i<8; i++)
{
drawFrame(enemy[i].position[0], enemy[i].position[1], ' ', ' ');
}
}
void Game::Pause()
{
SetPos(61,2);
cout<<" ";
SetPos(61,2);
cout<<"暂停中...";
char c=_getch();
while(c!='p')
c=_getch();
SetPos(61,2);
cout<<" ";
}
void Game::planeMove(char x)
{
if(x == 'a')
if(position[1].X != 1)
for(int i=0; i<=9; i++)
position[i].X -= 2;
if(x == 's')
if(position[7].Y != 23)
for(int i=0; i<=9; i++)
position[i].Y += 1;
if(x == 'd')
if(position[4].X != 47)
for(int i=0; i<=9; i++)
position[i].X += 2;
if(x == 'w')
if(position[5].Y != 3)
for(int i=0; i<=9; i++)
position[i].Y -= 1;
}
void Game::bulletMove()
{
for(int i=0; i<10; i++)
{
if( bullet[i].Y != 30)
{
bullet[i].Y -= 1;
if( bullet[i].Y == 1 )
{
COORD pos={bullet[i].X, bullet[i].Y+1};
drawThisBulletToNull( pos );
bullet[i].Y=30;
}
}
}
}
void Game::enemyMove()
{
for(int i=0; i<8; i++)
{
for(int j=0; j<2; j++)
enemy[i].position[j].Y++;
if(24 == enemy[i].position[1].Y)
{
COORD a={1, 1};
COORD b={45, 3};
enemy[i].position[0] = random(a, b);
enemy[i].position[1].X = enemy[i].position[0].X + 3;
enemy[i].position[1].Y = enemy[i].position[0].Y + 2;
}
}
}
void Game::judgePlane()
{
for(int i = 0; i < 8; i++)
for(int j=0; j<9; j++)
if(judgeCoordInFrame(enemy[i], position[j]))
{
SetPos(62, 1);
cout<<"坠毁";
drawFrame(enemy[i], '+', '+');
Sleep(1000);
GameOver();
break;
}
}
void Game::drawThisBulletToNull( COORD c)
{
SetPos(c);
cout<<" ";
}
void Game::drawThisEnemyToNull( Frame f )
{
drawFrame(f, ' ', ' ');
}
void Game::judgeEnemy()
{
for(int i = 0; i < 8; i++)
for(int j = 0; j < 10; j++)
if( judgeCoordInFrame(enemy[i], bullet[j]) )
{
score += 5;
drawThisEnemyToNull( enemy[i] );
COORD a={1, 1};
COORD b={45, 3};
enemy[i].position[0] = random(a, b);
enemy[i].position[1].X = enemy[i].position[0].X + 3;
enemy[i].position[1].Y = enemy[i].position[0].Y + 2;
drawThisBulletToNull( bullet[j] );
bullet[j].Y = 30;
}
}
void Game::Shoot()
{
for(int i=0; i<10; i++)
if(bullet[i].Y == 30)
{
bullet[i].X = position[5].X;
bullet[i].Y = position[5].Y-1;
break;
}
}
void Game::printScore()
{
if(score == 120 && flag_rank == 0)
{
rank -= 3;
flag_rank = 1;
}
else if( score == 360 && flag_rank == 1)
{
rank -= 5;
flag_rank = 2;
}
else if( score == 480 && flag_rank == 2)
{
rank -= 5;
flag_rank = 3;
}
int x=rank/5;
SetPos(60, 6);
cout<<score;
if( rank!=rankf )
{
SetPos(60, 7);
if( x == 5)
title="初级飞行员";
else if( x == 4)
title="中级飞行员";
else if( x == 3)
title="高级飞行员";
else if( x == 2 )
title="王牌飞行员";
cout<<title;
}
rankf = rank;
}
void Game::Playing()
{
//HANDLE MFUN;
//MFUN= CreateThread(NULL, 0, MusicFun, NULL, 0, NULL);
drawEnemy();
drawPlane();
int flag_bullet = 0;
int flag_enemy = 0;
while(1)
{
Sleep(8);
if(_kbhit())
{
char x = _getch();
if ('a' == x || 's' == x || 'd' == x || 'w' == x)
{
drawPlaneToNull();
planeMove(x);
drawPlane();
judgePlane();
}
else if ('p' == x)
Pause();
else if( 'k' == x)
Shoot();
else if( 'e' == x)
{
//CloseHandle(MFUN);
GameOver();
break;
}
}
/* 处理子弹 */
if( 0 == flag_bullet )
{
bulletMove();
drawBulletToNull();
drawBullet();
judgeEnemy();
}
flag_bullet++;
if( 5 == flag_bullet )
flag_bullet = 0;
/* 处理敌人 */
if( 0 == flag_enemy )
{
drawEnemyToNull();
enemyMove();
drawEnemy();
judgePlane();
}
flag_enemy++;
if( flag_enemy >= rank )
flag_enemy = 0;
/* 输出得分 */
printScore();
}
}
void Game::GameOver()
{
system("cls");
COORD p1={28,9};
COORD p2={53,15};
drawFrame(p1, p2, '=', '|');
SetPos(36,12);
string str="Game Over!";
for(int i=0; i<str.size(); i++)
{
Sleep(80);
cout<<str[i];
}
Sleep(1000);
system("cls");
drawFrame(p1, p2, '=', '|');
SetPos(31, 11);
cout<<"击落敌机:"<<score/5<<" 架";
SetPos(31, 12);
cout<<"得 分:"<<score;
SetPos(31, 13);
cout<<"获得称号:"<<title;
SetPos(30, 16);
Sleep(1000);
cout<<"继续? 是(y)| 否(n)制作:最牛的LJF";
as:
char x=_getch();
if (x == 'n')
exit(0);
else if (x == 'y')
{
system("cls");
Game game;
int a = drawMenu();
if(a == 2)
game.rank = 20;
system("cls");
drawPlaying();
game.Playing();
}
else goto as;
}
/*================== the main function ==================*/
int main()
{
//游戏准备
srand((int)time(0)); //随机种子
HideCursor(); //隐藏光标
Game game;
int a = drawMenu();
if(a == 2)
game.rank = 20;
system("cls");
drawPlaying();
game.Playing();
}
7.斗破苍穹
点击查看代码
#include<stdio.h>
#include<ctime>
#include<time.h> //suiji
#include<windows.h> //SLEEP函数
struct Player { //玩家结构体,并初始化player
char name[21];
int attack;
int defense;
int health;
long int max_health;
int level;
int exp;
int range_exp;
long int max_exp;
} player = {"勇者", 50, 40, 100, 100, 1, 0, 0, 100};
struct Enemy { //怪的结构体,并初始化各种怪
char name[20];
char wupin[20];
int attack;
int defense;
int health;
int money;
long int exp;
int wupin_sign;
int wupinpro;
int double_attack;
int miss;
} strongman = {"森林巨人", "黄金圣衣", 40, 50, 350, 200, 100, 1, 2, 1, 0},
witch = {"森林女巫", "银甲", 25, 15, 100, 50, 50, 2, 2, 1, 1},
xiyi = {"森林蜥蜴", "铁甲", 18, 10, 50, 30, 35, 3, 3, 2, 2},
big_strongman = {"森林巨人王", "巨人晶石", 40 * 5, 50 * 5, 200 * 5, 200 * 5, 100 * 5, 4, 4, 2, 0},
lion = {"草原雄狮", "绝世好剑", 60, 30, 280, 200, 100, 5, 2, 1, 0},
horse = {"草原野马", "碧血剑", 28, 12, 90, 50, 50, 6, 2, 1, 1},
bee = {"草原黄蜂", "长剑", 17, 11, 60, 30, 35, 7, 3, 2, 2},
shitu = {"使徒", "\0", 60 * 8, 30 * 8, 280 * 8, 200 * 8, 100 * 8, 9, 1, 1, 0},
guai = {"\0", "\0", 0, 0, 0, 0, 0, 0, 0, 0, 0};
struct Place {
int bar, hotel, forest1, forest2, forest3, grass1, grass2, grass3;
} place = {1, 2, 3, 4, 5, 6, 7, 8};
int max_exp = 0;
int choose_number = 0, s = 0, strongman_arm = 0, battle = 0, money = 500, place_sign = 9;
int cao = 3, jijiubao = 2, baiyao = 2, superbaiyao = 1, boom = 3, dubiao = 2, atom_boom = 1;
int fang = 0, fang1 = 10, fang1n = 0, fang2 = 20, fang2n = 0, fang3 = 40, fang3n = 0, fang4 = 100, fang4n = 0;
int gong = 0, gong1 = 8, gong1n = 0, gong2 = 15, gong2n = 0, gong3 = 25, gong3n = 0, gong4 = 60, gong4n = 0;
int jingyancao = 0, jingyanbao = 0, jingyanshi = 0;
char gongname[20] = "无", fangname[20] = "无";
char proof;
void AddWupin(int);
int AttackResult();
void BattleAct();
void ChooseWupin();
void DisplayState();
void OrdinaryAct();
int SuiJi();
int SuiJi100();
void WhetherLevelUp();
void SlowDisplay(char *);
int main() {
int i = 0, j = 0, k = 0;
char player_name[21];
Sleep(1000);
printf("--------------------------欢迎来到 [苍穹世界] 2.2 测试版-----------------------\n\n\n");
//如果想使用外挂,名字请输入:“圣战斗士 ”。
Sleep(1000);
printf("这里是苍穹世界! 雅莉萨斯国的罗茜公主被陌生人绑架了!\n\n\n 伟大的勇者啊~拿起你们的武器,营救公主!\n\n\n输入你的名字: (20个字符)\n\n\n");
scanf("%s", player_name);
strncpy(player.name, player_name, 20);
if (strcmp(player.name, "圣战斗士") == 0) {
printf("\n\n\n封印多年的圣剑血统啊!你终于觉醒了!\n\n\n圣战斗士,你成为了天选之人,请你救出公主吧!\n\n\n");
player.attack = 999;
player.defense = 999;
player.health = 9999;
player.max_health = 9999;
}
getchar();
OrdinaryAct();
return 0;
}
int SuiJi() {
srand((unsigned)time(NULL));
return rand() % 10;
}
int SuiJi100() {
srand((unsigned)time(NULL));
return rand() % 100;
}
void ChooseWupin() { //选择物品 并使用
printf("物品: 1,止血草%d个 2,急救包%d个 3,云南白药%d个 4,超级云南白药%d个 5,手雷%d个 6,毒标%d个 7,手抛式原子弹%d个 8,经验草%d个 9,经验包%d个 10,经验石%d个 11,巨人晶石%d个 0,返回\n\n\n", cao, jijiubao, baiyao, superbaiyao, boom, dubiao, atom_boom, jingyancao, jingyanbao, jingyanshi, strongman_arm);
switch (scanf("%d", &choose_number), choose_number) {
case 1:
if (cao > 0) {
printf("使用止血草,HP增加60\n\n\n");
cao--;
if (player.health + 60 > player.max_health)player.health = player.max_health;
else player.health += 60;
} else printf("没有止血草了\n\n\n");
break;
case 2:
if (jijiubao > 0) {
printf("使用急救包,HP增加80\n\n\n");
jijiubao--;
if (player.health + 80 > player.max_health)player.health = player.max_health;
else player.health += 80;
} else printf("没有急救包了\n\n\n");
break;
case 3:
if (baiyao > 0) {
printf("使用云南白药,HP增加120\nz\n\n");
baiyao--;
if (player.health + 120 > player.max_health)player.health = player.max_health;
else player.health += 120;
} else printf("没有云南白药了\n\n\n");
break;
case 4:
if (superbaiyao > 0) {
printf("使用超级云南白药,HP增加200\n\n\n");
superbaiyao--;
if (player.health + 200 > player.max_health)player.health = player.max_health;
else player.health += 200;
} else printf("没有超级云南白药了\n\n\n");
break;
case 5:
if (battle) { //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
if (boom > 0) {
printf("使用手雷,敌人HP减少100\n\n\n");
boom--;
guai.health -= 100;
AttackResult();
}
} else printf("非战斗状态,不能使用手雷!\n\n\n");
break;
case 6:
if (battle) { //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
if (dubiao > 0) {
printf("使用毒标,敌人HP减少200\n\n\n");
dubiao--;
guai.health -= 200;
AttackResult();
}
} else printf("非战斗状态,不能使用毒标!\n\n\n");
break;
case 7:
if (battle) { //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
if (atom_boom > 0) {
printf("使用手抛式原子弹,敌人HP减少666666666\n\n\n");
atom_boom--;
guai.health -= 666666666;
AttackResult();
}
} else printf("非战斗状态,不能使用手抛式原子弹!\n\n\n");
break;
case 8:
if (jingyancao > 0 && player.level < 1000) {
printf("使用经验草,等级增加10级\n\n\n");
jingyancao--;
player.level += 10;
printf("等级:%d\n", player.level);
} else if (jingyancao < 1) {
printf("没有经验草了\n\n\n");
} else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 9:
if (jingyanbao > 0 && player.level < 1000) {
if (player.level > 44 && player.level < 1000) {
int sheng;
sheng = 45 - player.level;
player.level += sheng;
printf("使用经验包,等级增加%d级", sheng);
printf("等级:%d\n", player.level);
} else {
printf("使用经验包,等级增加2级\n\n\n");
jingyanbao--;
player.level += 2;
printf("等级:%d\n", player.level);
}
} else if (jingyanbao < 1) {
printf("没有经验包了");
} else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 10:
if (jingyanshi > 0 && player.level < 1000) {
if (player.level > 42 && player.level < 1000) {
int sheng;
sheng = 45 - player.level;
player.level += sheng;
printf("使用经验石,等级增加%d级\n", sheng);
printf("等级:%d\n", player.level);
} else {
printf("使用经验石,等级增加10级\n");
jingyanshi--;
player.level += 10;
}
} else if (jingyanshi < 1) {
printf("没有经验石了\n\n\n");
} else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 11:
if (strongman_arm > 0 && player.level < 10000) {
if (player.level > 29 && player.level < 10000) {
int sheng;
sheng = 45 - player.level;
player.level += sheng;
printf("使用巨人晶石,等级增加%d级", sheng);
printf("等级:%d\n", player.level);
} else {
printf("使用巨人晶石,等级增加16级\n\n\n");
strongman_arm--;
player.level += 16;
printf("等级:%d\n", player.level);
}
} else if (strongman_arm < 1) {
printf("没有巨人晶石了。\n\n\n");
} else printf("等级超过45级,修为太高,无法使用。\n\n\n");
break;
case 0:
break;
default:
printf("ChooseWupin error!\n\n\n");
}
}
int AttackResult() { //攻击结果:判断是否获胜 是否获得物品 和 是否升级
if (guai.health <= 0) {
battle = 0;
printf("战斗胜利!获得金币%d,经验%d\n\n\n", guai.money, guai.exp);
player.exp += guai.exp;
player.range_exp += guai.exp;
money += guai.money;
s = SuiJi();
if (s < guai.wupinpro) {
printf("从敌人尸骸中发现");
printf("%s\n\n\n", guai.wupin);
AddWupin(guai.wupin_sign);
}
WhetherLevelUp();
if (strcmp(guai.name, "使徒") == 0) {
printf("战斗胜利,救出公主!!!");
getchar();
getchar();
exit(0);
}
return 1; //攻击有结果了返回1,否则返回0,用于判断是否继续做战斗行为
} else {
int s = SuiJi();
if ((guai.attack + s - player.defense / 3) < 0) {
player.health -= 1;
printf("%s反击,你的HP减少了 1\n\n", guai.name);
} else {
player.health -= guai.attack + s - player.defense / 3;
printf("%s反击,你的HP减少了%d\n\n", guai.name, guai.attack + s - player.defense / 3);
}
if (player.health < 0) {
battle = 0;
printf("%s战死!金币掉落%d\n\n\n", player.name, player.level * 500);
money -= player.level * 500;
player.health = player.max_health / 5;
OrdinaryAct();//
return 1;
}
}
return 0;
}
void AddWupin(int wupin_sign) {
switch (wupin_sign) {
case 1:
fang4n++;
break;
case 2:
fang3n++;
break;
case 3:
fang2n++;
break;
case 4:
strongman_arm = 1;
break;
case 5:
gong4n++;
break;
case 6:
gong3n++;
break;
case 7:
gong2n++;
break;
default:
printf("AddWupin error\n\n\n");
}
}
void WhetherLevelUp() {
int i = 0, j = 0;
int l1 = player.range_exp / 100;
int l2 = player.range_exp / 300;
int l3 = player.range_exp / 600;
if (player.level <= 15 && l1 > 0) { //15级以下,经验足够 都满足则升级
if (l1 == 1) {
printf("%s", player.name);
printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp = player.exp + guai.exp - (player.exp + guai.exp) % 100;
player.attack += 3;
player.defense += 2;
player.max_health += 20;
player.health = player.max_health;
player.level++;
player.range_exp = 0;
player.exp = player.max_exp;
player.max_exp += 100;
} else {
printf("好厉害!连升%d级!", l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n", 3 * l1, 2 * l1, 20 * l1);
player.exp = (player.exp + guai.exp) || player.exp - ((player.exp + guai.exp) || player.exp) % 100;
player.attack += 3 * l1;
player.defense += 2 * l1;
player.max_health += 20 * l1;
player.health = player.max_health;
player.level += l1;
player.range_exp = 0;
player.exp = player.max_exp;
player.max_exp += 100 * l1;
}
} else if (player.level <= 40 && l2 > 0) {
if (l2 == 1) {
printf("%s", player.name);
printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp = player.exp + guai.exp - (player.exp + guai.exp) % 100;
player.attack += 3;
player.defense += 2;
player.max_health += 20;
player.health = player.max_health;
player.level++;
player.range_exp = 0;
player.exp = player.max_exp;
player.max_exp += 300;
} else {
printf("好厉害!连升%d级!", l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n", 3 * l2, 2 * l2, 20 * l2);
player.exp = player.exp + guai.exp - (player.exp + guai.exp) % 100;
player.attack += 3 * l2;
player.defense += 2 * l2;
player.max_health += 20 * l2;
player.health = player.max_health;
player.level += l2;
player.range_exp = 0;
player.exp = player.max_exp;
player.max_exp += 300 * l2;
}
} else if (l3 > 0) {
if (l3 == 1) {
printf("%s", player.name);
printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp = player.exp + guai.exp - (player.exp + guai.exp) % 100;
player.attack += 3;
player.defense += 2;
player.max_health += 20;
player.health = player.max_health;
player.level++;
player.range_exp = 0;
player.exp = player.max_exp;
player.max_exp += 600;
} else {
printf("好厉害!连升%d级!", l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n", 3 * l3, 2 * l3, 20 * l3);
player.exp = player.exp + guai.exp - (player.exp + guai.exp) % 100;
player.attack += 3 * l3;
player.defense += 2 * l3;
player.max_health += 20 * l3;
player.health = player.max_health;
player.level += l3;
player.range_exp = 0;
player.exp = player.max_exp;
player.max_exp += 600 * l3;
}
}
}
void OrdinaryAct() { //正常行为菜单(移动,物品,对话,查看状态,装备,退出游戏)
while (1) {
// \(1000);
// system("cls");
puts("=============================================================================");
printf("要做什么?\n\n\n 1,移动 2,道具 3,对话 4,查看状态 5,装备 6,关于游戏 0,退出游戏\n\n\n");
puts("=============================================================================");
switch (scanf("%d", &choose_number), choose_number) {
case 1: //显示移动菜单
printf("要去哪里?\n\n\n");
printf("1,happy酒吧 2,诺亚方舟酒店 3,北朝商会 4,红玉拍卖行 5,冒险荒野\n\n\n");
switch (scanf("%d", &choose_number), choose_number) {
case 1:
place_sign = place.bar; //记录目前位置-酒吧
// OrdinaryAct();
break;
case 2:
place_sign = place.hotel; //进入旅店
printf("金币:%d", money);
printf("要开房吗? 200个金币 1,是 0,否\n\n\n");
choose_number = 1;
switch (scanf("%d", &choose_number), choose_number) {
case 1:
if (money - 200 < 0) { //判断钱是否够
printf("Sorry,你的钱不够~\n\n\n");
printf("金币:%d", money);
} else {
printf("好好休息\nHP满\n第二天了\n\n");
printf("金币:%d\n", money);
money -= 200; //花费200住店费
player.health = player.max_health; //体力满
}
break;
case 0:
printf("下次再来!\n\n\n");
break;
default:
printf("hotel talk error!\n\n\n");
}
place_sign = 0;
break;
case 3:
int yongju, gong, fang;
printf("请问您要购买什么类型的物品?\n\n\n 1,攻击装备 2,防御装备 3,一次性伤害武器\n\n\n");
scanf("%d", &yongju);
switch (yongju) {
case 1:
printf("请问您要购买什么武器?\n\n\n 1,匕首¥300 2,长剑¥500 3,碧血剑¥1000\n\n\n");
scanf("%d", &gong);
switch (gong) {
case 1:
if (money >= 300) {
gong1n++;
money = money - 300;
printf ("匕首+1\n");
printf("匕首:%d个\n", gong1n);
printf("金币:%d\n", money);
break;
} else {
printf("钱不够!\n");
printf("金币:%d\n", money);
break;
}
case 2:
if (money >= 500) {
gong2n++;
money = money - 500;
printf ("长剑+1\n");
printf("长剑:%d个\n", gong2n);
printf("金币:%d\n", money);
break;
} else {
printf("钱不够!\n");
printf("金币:%d\n", money);
break;
}
case 3:
if (money >= 1000) {
gong3n++;
money = money - 1000;
printf ("碧血剑+1\n");
printf("碧血剑:%d个\n", gong3n);
printf("金币:%d\n", money);
break;
} else {
printf("钱不够!\n");
printf("金币:%d\n", money);
break;
}
default:
printf("对不起,我们只会打造以上武器。");
break;
}
break;
case 2:
int fang;
printf("请问您要购买什么防具?\n\n\n 1,布衣¥300 2,铁甲¥500 3,银甲¥1000\n\n\n");
scanf("%d", &fang);
switch (fang) {
case 1:
if (money >= 300) {
fang1n++;
money = money - 300;
printf ("布衣+1\n");
printf("布衣:%d个\n", fang1n);
printf("金币:%d\n", money);
} else {
printf("钱不够!\n");
printf("金币:%d\n", money);
}
break;
case 2:
if (money >= 500) {
fang2n++;
money = money - 500;
printf ("铁甲+1\n");
printf("铁甲:%d个\n", fang2n);
printf("金币:%d\n", money);
} else {
printf("钱不够!\n");
printf("金币:%d", money);
}
break;
case 3:
if (money >= 1000) {
fang3n++;
money = money - 1000;
printf ("银甲+1\n");
printf("银甲:%d个\n", fang3n);
printf("金币:%d\n", money);
} else {
printf("钱不够!\n");
printf("金币:%d\n", money);
}
default:
printf("对不起,我们只会打造以上防具。");
break;
}
printf("金币:%d\n", money);
break;
case 3:
printf("请问您要购买什么一次性伤害武器?\n 1,手雷 2,毒镖 3,手抛式原子弹\n\n\n");
int yi;
scanf("%d", &yi);
switch (yi) {
case 1:
if (money >= 300 && boom < 5) {
boom++;
money = money - 300;
printf("手雷+1\n");
printf("手雷:%d\n", boom);
printf("金币:%d\n", money);
} else {
printf("钱不够!\n");
printf("金币:%d", money);
}
break;
case 2:
if (money >= 600 && dubiao < 4) {
dubiao++;
money = money - 600;
printf("毒镖+1\n");
printf("毒镖:%d\n", dubiao);
printf("金币:%d\n", money);
} else {
printf("钱不够!\n");
printf("金币:%d\n", money);
}
break;
case 3:
if (money >= 0 && atom_boom < 23333333333) {
atom_boom = atom_boom + 233;
money = money + 1500;
printf("手抛式原子弹+2\n");
printf("手抛式原子弹:%d\n", atom_boom);
printf("金币:%d\n", money);
} else {
printf("钱不够!\n\n\n");
printf("金币:%d\n", money);
}
break;
}
}
break;
case 4:
printf ("欢迎您光临本拍卖行,请问您要卖什么东西?\n\n");
printf("攻击装备: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个\n", gong1n, gong2n, gong3n, gong4n);
printf("防御装备: 5,布衣:%d个 6,铁甲:%d个 7,银甲:%d个 8,黄金圣衣:%d个\n9,巨人晶石:%d个 0,返回\n\n\n", fang1n, fang2n, fang3n, fang4n, strongman_arm);
int pai, shu, i;
scanf("%d", &pai);
switch (pai) {
case 1:
printf("请问您要出售几件?");
scanf("%d", &shu);
if (gong1n >= shu) {
gong1n = gong1n - shu;
money = money + shu * 240;
printf("匕首:%d\n", gong1n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
break;
case 2:
printf("请问您要出售几件?\n");
scanf("%d", &shu);
if (gong2n >= shu) {
gong2n = gong2n - shu;
money = money + shu * 400;
printf("长剑:%d\n", gong2n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
case 3:
printf("请问您要出售几件?\n");
scanf("%d", &shu);
if (gong3n >= shu) {
gong3n = gong3n - shu;
money = money + shu * 800;
printf("碧血剑:%d\n", gong3n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
case 4:
printf("请问您要出售几件?\n");
scanf("%d", &shu);
if (gong4n >= shu) {
gong4n = gong4n - shu;
money = money + shu * 1500;
printf("绝世好剑:%d\n", gong4n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
case 5:
printf("请问您要出售几件?\n");
scanf("%d", &shu);
if (fang1n >= shu) {
fang1n = fang1n - shu;
money = money + shu * 240;
printf("布衣:%d\n", fang1n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
case 6:
printf("请问您要出售几件?\n");
scanf("%d", &shu);
if (fang2n >= shu) {
fang2n = fang2n - shu;
money = money + shu * 500;
printf("铁甲:%d\n", fang2n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
case 7:
printf("请问您要出售几件?\n");
scanf("%d", &shu);
if (fang3n >= shu) {
fang3n = fang3n - shu;
money = money + shu * 800;
printf("银甲:%d\n", fang3n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
break;
case 8:
printf("请问您要出售几件?\n");
scanf("%d", &shu);
if (fang1n >= shu) {
fang4n = fang4n - shu;
money = money + shu * 1500;
printf("黄金圣衣:%d\n", fang4n);
printf("金币:%d\n", money);
break;
} else {
printf("装备数不够,无法出售!\n");
break;
}
case 9:
printf("请问您要出售几颗?");
scanf("%d", &shu);
if (strongman_arm >= shu) {
strongman_arm = strongman_arm - shu;
money = money + shu * 2000;
printf("巨人晶石:%d\n", strongman_arm);
printf("金币:%d\n", money);
} else {
printf("晶石数不够,无法出售!\n");
break;
}
break;
case 0:
break;
break;
default:
printf("没有该装备,无法出售!\n");
break;
}
break;
case 5:
int yewai;
while (1) {
puts("=============================================================================");
printf("要去哪冒险呢?");
printf("\n\n 1,神秘沼泽 危险程度:★\n\n 2,星耀草原 危险程度:★\n\n 3,诡异森林 危险程度:★★★\n\n 4,荒漠矿场 危险程度:★★★\n\n 5,炽热炎洞 危险程度:★★★★\n\n 6,花朵宫殿 危险程度:★★★★★\n\n 0,离开\n");
puts("=============================================================================");
scanf("%d", &yewai);
switch (yewai) {
case 1:
place_sign = place.forest1;
s = SuiJi();
if (s < 7) {
battle = 1;
guai = xiyi;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else if (s < 9) {
battle = 1;
guai = witch;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else {
printf("这里安全\n\n\n");
//不用调用OAct函数,会自动执行OAct函数;
}
break;
case 3:
place_sign = place.forest2;
s = SuiJi();
if (s < 7) {
battle = 1;
guai = witch;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else if (s < 9) {
battle = 1;
guai = strongman;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else {
printf("这里安全\n\n\n");
}
break;
case 5:
place_sign = place.forest3;
s = SuiJi();
if (s < 7) {
battle = 1;
guai = strongman;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else if (s < 9) {
battle = 1;
guai = big_strongman;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else {
printf("这里安全\n\n\n");
}
break;
case 2:
place_sign = place.grass1;
s = SuiJi();
if (s < 7) {
battle = 1;
guai = bee;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else if (s < 9) {
battle = 1;
guai = horse;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else {
printf("这里安全\n\n\n");
}
break;
case 4:
place_sign = place.grass2;
s = SuiJi();
if (s < 7) {
battle = 1;
guai = horse;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else if (s < 9) {
battle = 1;
guai = lion;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else {
printf("这里安全\n\n\n");
}
break;
case 6:
place_sign = place.grass3;
s = SuiJi();
if (s < 7) {
battle = 1;
guai = lion;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else if (s < 9) {
battle = 1;
if (strongman_arm) {
printf("神秘老人:\n\n\n 哈哈,年轻人,做的不错,不过...嘿嘿,你上当啦!巨人晶石我要了,公主你也别想带走!\n\n\n");
guai = shitu;
printf("%s扑了过来!\n\n\n", guai.name);
BattleAct();
} else printf("神秘老人:\n\n\n 年轻人,你好啊.如果你有巨人晶石,我可以告诉你公主的下落哦~\n\n\n");
} else {
printf("这里安全\n\n\n");
}
break;
if (yewai != 0) {
printf("该区域为未知区域,无法进入。\n\n\n");
break;
}
}
if (yewai == 0) {
break;
printf("已离开荒野。");
}
}
}
break;
case 2:
ChooseWupin();
break; //显示道具,并可以使用.
case 3: //对话选项
if (place_sign == place.bar) {
printf("要和谁说话?\n\n\n1,红发女郎 2,赏金猎人 3,酒吧老板 4,药品商人\n\n\n"); //显示对话人物
switch (scanf("%d", &choose_number), choose_number) {
case 1:
printf("红发女郎:\n\n\n 吧台边那个Hunter好帅啊!(~脸红~)\n\n\n听说他经常外出打猎,外面的路他应该很熟悉的!\n\n\n");
break;
case 2:
if (fang1n < 1 && gong1n < 1) {
printf("赏金猎人:\n\n\n 你要救公主啊!好胆量!\n\n\n 不过外面的世界很险恶,而且越深越危险,这是匕首和布衣,对你会有些帮助的,拿去吧!\n\n\n");
printf("%s心想:哇,这位大叔人真好啊!\n\n\n)", player.name);
gong1n++;
fang1n++;
} else printf("赏金猎人:\n\n\n 加油吧,年轻人!\n\n\n 不要被外面世界所吓倒!\n\n\n");
break;
case 3:
printf("要喝点什么?\n\n\n 1,二锅头25金币 HP+20 2,XO酒80金币 HP+50 3,人头马面150金币 HP+100 0,返回\n\n\n");
choose_number = 1;
while (choose_number) {
switch (scanf("%d", &choose_number), choose_number) {
case 1:
if (money < 25) {
printf("钱不够!");
} else {
if (player.health + 20 <= player.max_health) {
printf("HP+20.");
money -= 25;
player.health += 20;
} else {
printf("HP满了");
player.health = player.max_health;
}
}
break;
case 2:
if (money < 80) {
printf("钱不够!");
} else {
if (player.health + 50 <= player.max_health) {
printf("HP+50.");
money -= 80;
player.health += 50;
} else {
printf("HP满了");
player.health = player.max_health;
}
}
break;
case 3:
if (money < 150) {
printf("钱不够!");
} else {
if (player.health + 100 <= player.max_health) {
printf("HP+100.");
money -= 150;
player.health += 100;
} else {
printf("HP满了");
player.health = player.max_health;
}
}
break;
case 0:
printf("下次再来!\n");
break;
default:
printf("输入错误\n\n\n");
break;
}
break;
}
break;
case 4:
printf("你要干什么?\n\n\n 1,买东西 2,聊天 \n\n\n");
int mai;
scanf("%d", &mai);
if (mai == 1) {
printf("买点什么呢?\n1,止血草¥100 HP+60\n2,急救包¥150 HP+80 \n3,云南白药¥250 HP+120\n4,超级云南白药¥400 HP+200 \n5,经验草¥150 经验+300 \n6,经验包¥600 经验+600\n7,经验石¥500 经验+1000 \n0,拜拜\n");
int dongxi;
scanf("%d", &dongxi);
switch (dongxi) {
case 1:
if (money >= 100 && cao < 6) {
cao++;
money = money - 100;
printf ("止血草+1\n");
} else {
printf("钱不够!\n");
}
break;
case 2:
if (money >= 150 && jijiubao < 5) {
jijiubao++;
money = money - 150;
printf ("急救包+1\n");
} else {
printf("钱不够!\n");
}
break;
case 3:
if (money >= 250 && baiyao < 4) {
baiyao++;
money = money - 250;
printf ("云南白药+1\n");
} else {
printf("钱不够!\n");
}
break;
case 4:
if (money >= 400 && superbaiyao < 3) {
superbaiyao++;
money = money - 400;
printf ("超级云南白药+1\n");
} else {
printf("钱不够!\n");
}
break;
case 5:
if (money >= 150) {
jingyancao++;
money = money - 150;
printf ("经验草+1\n");
} else {
printf("钱不够!\n");
}
break;
case 6:
if (money >= 300) {
jingyanbao++;
money = money - 300;
printf ("经验包+1\n");
} else {
printf("钱不够!\n");
}
break;
case 7:
if (money >= 500) {
jingyanshi++;
money = money + 500;
printf ("经验石+1\n");
} else {
printf("钱不够!\n");
}
break;
}
case 0:
printf("金币:%d\n", money);
printf("再见,欢迎下次再来!\n");
break;
}
if (mai == 2) {
printf("药品商人:去去去,老子没时间陪你聊。\n");
}
}
} else if (place_sign == place.hotel)
printf("“老板娘!我...”\n\n\n“我忙着呢,没空理你~”\n\n\n");
else printf("这里好像没人可以聊天\n\n\n");
break;
case 4:
DisplayState();
break; //显示状态
case 5: //装备
printf("攻击装备: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个\n\n\n", gong1n, gong2n, gong3n, gong4n);
printf("防御装备: 5,布衣:%d个 6,铁甲:%d个 7,银甲:%d个 8,黄金圣衣:%d个\t\t0,返回\n\n\n", fang1n, fang2n, fang3n, fang4n);
printf("选择要装备的武器或防具:\n\n\n");
switch (scanf("%d", &choose_number), choose_number) {
case 1:
if (gong1n >= 1) {
printf("拿起了匕首\n\n\n");
gong = gong1;
strcpy(gongname, "匕首");
} else printf("你没有匕首可以装备\n\n\n");
break;
case 2:
if (gong2n >= 1) {
printf("拿起了长剑\n\n\n");
gong = gong2;
strcpy(gongname, "长剑");
} else printf("你没有长剑可以装备\n\n\n");
break;
case 3:
if (gong3n >= 1) {
printf("拿起了碧血剑\n\n\n");
gong = gong3;
strcpy(gongname, "碧血剑");
} else printf("你没有碧血剑可以装备\n\n\n");
break;
case 4:
if (gong4n >= 1) {
printf("拿起了绝世好剑\n\n\n");
gong = gong4;
strcpy(gongname, "绝世好剑");
} else printf("你没有绝世好剑可以装备\n\n\n");
break;
case 5:
if (fang1n >= 1) {
printf("穿上了布衣\n\n\n");
fang = fang1;
strcpy(fangname, "布衣");
} else printf("你没有布衣可以装备\n\n\n");
break;
case 6:
if (fang2 >= 1) {
printf("穿上了铁甲\n\n\n");
fang = fang2;
strcpy(fangname, "铁甲");
} else printf("你没有铁甲可以装备\n\n\n");
break;
case 7:
if (fang3n >= 1) {
printf("穿上了银甲\n\n\n");
fang = fang3;
strcpy(fangname, "银甲");
} else printf("你没有银甲可以装备\n\n\n");
break;
case 8:
if (fang4n >= 1) {
printf("穿上了黄金圣衣\n\n\n");
fang = fang4;
strcpy(fangname, "黄金圣衣");
} else printf("你没有黄金圣衣可以装备\n\n\n");
break;
case 0:
printf("未更换装备\n\n\n");
break;
default:
printf("change error!");
}
break;
case 6:
printf(" 您好,欢迎您玩苍穹世界。为了给您更好的游戏体验,本团队时不时会优化本游戏,优化后会尽快发布在网上。关于外挂方面,开启外挂的方式是设定勇者姓名时,输入“圣战斗士 ”(不包括双引号)。由于2.0版本的buy,我们在2.0的基础上进行修改,已修复该buy。并且新增了经验草等有助于升级的道具,希望大家喜欢。在这里要感谢离陌同学,他给了我们许多宝贵的建议,谢谢。\n");
break;
case 0:
printf("确定退出游戏?(Y/N)\n\n\n");
getchar();
proof = getchar();
if (proof == 'y' || proof == 'Y') {
printf("数据存储中...");
//向文件中更新数据;
getchar();
printf("按回车退出");
getchar();
return;
} else if (proof == 'n' || proof == 'N')printf("继续游戏!\n\n\n");
else printf("继续!\n\n\n");
break;
default:
printf("输入错误!\n\n\n");
}
}
}
void DisplayState() {
printf("%s 攻击力:%d+%d=%d 防御力:%d+%d=%d HP:%d/%d \n\n\n", player.name, player.attack, gong, player.attack + gong, player.defense, fang, player.defense + fang, player.health, player.max_health);
printf("武器: %s 防具: %s \n\n\n", gongname, fangname);
printf("等级:%d 经验:%d/%d 还需要%d经验升级 金币:%d \n\n\n", player.level, player.exp, player.max_exp, player.max_exp - player.exp, money);
}
void BattleAct() {
while (1) {
puts("=============================================================================");
printf("要怎么办?\n\n\n 1,攻击 2,物品 3,查看状态 4,逃跑\n\n\n");
switch (scanf("%d", &choose_number), choose_number) {
case 1:
s = SuiJi();
printf("%s攻击! %sHP减少%d\n\n\n", player.name, guai.name, player.attack + s + gong - guai.defense / 3);
guai.health -= player.attack + s + gong - guai.defense / 3;
if (AttackResult())return; //如果攻击有结果(敌人或玩家战死)退出函数
else continue;
case 2:
ChooseWupin();
break; //选择物品,可以使用,战斗中允许使用攻击性物品
case 3:
DisplayState();
break; //显示状态
case 4:
s = SuiJi();
if (s < 4) { //40%的概率可以逃跑
printf("%s逃跑了~\n\n\n", player.name);
battle = 0;
return;
} else printf("%s逃跑失败!\n\n\n", player.name);
break;
default:
printf("输入错误,重新输入!\n\n\n");
}
}
}
void printf(char *p) {
while (1) {
if (*p != 0)
printf("%c", *p++);
else
break;
Sleep(100);
}
}
8.恶魔轮盘赌
点击查看代码
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
int Your = 6, Other = 6;
string daojuname[] = {"放大镜", "手铐", "小刀", "烟", "饮料"};
double Yourmoney;
int shi, kong;
int q[10], qlen; //1 实 2 空
int Rand(int x, int y) {
int A = rand(), B = rand();
return A * 1ll * B % (y - x + 1) + x;
}
int T;//ou->you
int daojulen;
int daoju[10];
int daojulen1;
int daoju1[10];
void build_gun() {
kong = Rand(1, 4);
shi = Rand(1, 4);
qlen = 0;
printf("%d发实弹,%d发空弹\n", shi, kong);
int a1 = kong, a2 = shi;
for (int i = 1; i <= kong + shi; i++) {
// Sleep(50);
int sum = Rand(1, a1 + a2);
if (sum <= a1) {
a1--;
q[++qlen] = 2;
} else {
a2--;
q[++qlen] = 1;
}
}
int maxn = min(4, 8 - daojulen);
printf("你获得了%d个道具:\n", maxn);
daojulen += maxn;
for (int i = 1; i <= maxn; i++) {
// Sleep(50);
int kkk = Rand(0, 4);
daoju[kkk]++;
cout << daojuname[kkk];
if (i != maxn) {
printf(",");
}
}
printf("\n");
maxn = min(4, 8 - daojulen1);
printf("恶魔获得了%d个道具:\n", maxn);
daojulen1 += maxn;
for (int i = 1; i <= maxn; i++) {
int kkk = Rand(0, 4);
daoju1[kkk]++;
cout << daojuname[kkk];
if (i != maxn) {
printf(",");
}
}
printf("\n");
system("pause");
system("cls");
}
void IsOver() {
if (Your <= 0) {
printf("你输了\n");
system("pause");
exit(0);
}
if (Other <= 0) {
printf("你赢了\n你获得了奖金$%.2lf\n", Yourmoney);
system("pause");
exit(0);
}
}
void wait() {
for (int i = 1; i <= 3; i++) {
Sleep(500);
printf(".");
}
Sleep(500);
}
int Hurt = 1;
int shoukao_you;
void Timeyou() {
int x;
while (1) {
printf("你的生命:%d/6\n恶魔生命:%d/6\n", Your, Other);
printf("剩余实弹数:%d 剩余空弹数:%d\n", shi, kong);
printf("你现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("恶魔现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju1[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("现在是你的回合\n");
printf("你要\n1.向恶魔开枪\n2.向自己开枪\n");
for (int i = 0; i <= 4; i++) {
printf("%d.使用", i + 3);
cout << daojuname[i] << '\n';
}
scanf("%d", &x);
if (1 <= x && x <= 7) {
break;
}
printf("输入不合法\n");
Sleep(1145);
system("cls");
}
if (x == 1) {
printf("你决定向恶魔开枪");
T++;
wait();
if (q[qlen] == 2) {
Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(shi) * 1.0 / (double)(shi + kong)));
kong--;
qlen--;
Hurt = 1;
printf("是空弹\n");
if (shoukao_you == 1) {
shoukao_you = 0;
printf("因为你使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
} else {
// printf("((%lf))\n",Yourmoney);
Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
// printf("{{%lf}}\n",Yourmoney);
shi--;
qlen--;
Other -= Hurt;
Hurt = 1;
printf("是实弹\n");
Sleep(500);
IsOver();
if (shoukao_you == 1) {
shoukao_you = 0;
Yourmoney += 1000.0;
printf("因为你使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
} else if (x == 2) {
printf("你决定向自己开枪");
wait();
if (q[qlen] == 2) {
Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
kong--;
qlen--;
Hurt = 1;
printf("是空弹\n");
} else {
Yourmoney += 5000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
T++;
shi--;
qlen--;
Your -= Hurt;
Hurt = 1;
printf("是实弹\n");
Sleep(500);
IsOver();
if (shoukao_you == 1) {
shoukao_you = 0;
printf("因为你使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
} else if (x == 3) { //{"放大镜","手铐","小刀","烟","饮料"};
if (daoju[0]) {
daoju[0]--;
daojulen--;
printf("你使用了放大镜\n");
wait();
printf("\n你看到了");
if (q[qlen] == 1) {
printf("实弹\n");
Yourmoney += 2500.0;
} else {
printf("空弹\n");
}
Sleep(500);
printf("\n");
} else {
printf("你现在没有放大镜\n");
Sleep(1145);
system("cls");
}
} else if (x == 4) {
if (daoju[1]) {
if (!shoukao_you) {
daoju[1]--;
daojulen--;
printf("你使用了手铐\n");
printf("你获得了连开两枪的机会\n");
shoukao_you = 1;
} else {
printf("你已经用过手铐了\n");
}
Sleep(1145);
system("cls");
} else {
printf("你现在没有手铐\n");
Sleep(1145);
system("cls");
}
} else if (x == 5) {
if (daoju[2]) {
if (Hurt == 1) {
daoju[2]--;
daojulen--;
printf("你使用了小刀\n");
printf("若下一发为实弹则伤害+1\n");
Yourmoney += 500.0;
Hurt = 2;
} else {
printf("你已经用过小刀了\n");
}
Sleep(1145);
system("cls");
} else {
printf("你现在没有小刀\n");
Sleep(1145);
system("cls");
}
} else if (x == 6) {
if (daoju[3]) {
if (Your ^ 6) {
daoju[3]--;
daojulen--;
printf("你使用了烟\n");
printf("你回复了一点生命\n");
Yourmoney += 500.0;
Your++;
} else {
printf("你现在不需要烟\n");
}
Sleep(1145);
} else {
printf("你现在没有烟\n");
Sleep(1145);
system("cls");
}
} else {
if (daoju[4]) {
daoju[4]--;
daojulen--;
printf("你使用了饮料\n");
wait();
printf("\n");
printf("你退了一发");
if (q[qlen] == 2) {
printf("空弹");
kong--;
} else {
printf("实弹");
Yourmoney += 500.0;
shi--;
}
qlen--;
Sleep(500);
} else {
printf("你现在没有饮料\n");
Sleep(1145);
system("cls");
}
}
Sleep(1000);
system("cls");
}
int Know;//通过放大镜得知下一发子弹
int shoukaoemo;
void fightyou() {
printf("恶魔决定向你开枪");
T++;
wait();
if (q[qlen] == 2) {
Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
kong--;
qlen--;
Hurt = 1;
Know = 0;
printf("是空弹\n");
if (shoukaoemo) {
printf("因为恶魔使用了手铐,所以可以再来一次\n");
T--;
Sleep(500);
shoukaoemo = 0;
}
} else {
Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
shi--;
qlen--;
Your -= Hurt;
Hurt = 1;
printf("是实弹\n");
Know = 0;
Sleep(500);
IsOver();
if (shoukaoemo) {
printf("因为恶魔使用了手铐,所以可以再来一次\n");
Yourmoney += 1000.0;
T--;
Sleep(500);
shoukaoemo = 0;
}
}
}
void fightemo() {
printf("恶魔决定向自己开枪");
wait();
if (q[qlen] == 2) {
Yourmoney += 2000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
kong--;
qlen--;
printf("是空弹\n");
Know = 0;
} else {
Yourmoney += 5000.0 * (1 + (double)(kong) * 1.0 / (double)(shi + kong));
shi--;
T++;
qlen--;
Other -= Hurt;
Hurt = 1;
printf("是实弹\n");
Know = 0;
Sleep(500);
IsOver();
if (shoukaoemo) {
printf("因为恶魔使用了手铐,所以可以再来一次\n");
T--;
Sleep(500);
shoukaoemo = 0;
}
}
}
void Timeother() {
printf("你的生命:%d/6\n恶魔生命:%d/6\n", Your, Other);
printf("剩余实弹数:%d 剩余空弹数:%d\n", shi, kong);
printf("你现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("恶魔现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju1[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("现在是恶魔的回合\n");
Sleep(1500);
if (Other != 6) {
if (daoju1[3]) {
daoju1[3]--;
daojulen1--;
printf("恶魔使用了烟\n");
printf("恶魔回复了一点生命\n");
Other++;
Yourmoney += 500.0;
Sleep(1145);
system("cls");
return ;
}
}
if (Know == 0 && kong == 0) {
Know = 1;
}
if (Know == 0) {
if (abs(shi - kong) < 2 && kong != 0) {
if (daoju1[0]) {
daoju1[0]--;
daojulen1--;
printf("恶魔使用了放大镜\n");
wait();
printf("\n恶魔看到了");
if (q[qlen] == 1) {
printf("实弹");
Yourmoney += 2500.0;
Know = 1;
} else {
printf("空弹");
Know = 2;
}
Sleep(1145);
system("cls");
return ;
}
}
} else if (Know == 1) {
if (Hurt == 1 && daoju1[2]) {
daoju1[2]--;
daojulen1--;
Hurt++;
printf("恶魔使用了小刀\n");
printf("若下一发为实弹则伤害+1");
Yourmoney += 500.0;
Sleep(1145);
system("cls");
return ;
} else {
if (shi >= kong + 1 && daoju1[1] && shoukaoemo != 1) {
daoju1[1]--;
daojulen1--;
shoukaoemo = 1;
printf("恶魔使用了手铐\n");
printf("恶魔获得了连开两枪的机会\n");
Sleep(1145);
system("cls");
return ;
}
fightyou();
system("cls");
return ;
}
} else {
if (daoju1[4]) {
daoju1[4]--;
daojulen1--;
printf("恶魔使用了饮料\n");
wait();
printf("\n");
printf("恶魔退了一发");
if (q[qlen] == 2) {
printf("空弹");
kong--;
} else {
printf("实弹");
shi--;
}
Know = 0;
qlen--;
Sleep(500);
Sleep(1145);
system("cls");
return ;
} else {
fightemo();
Sleep(1145);
system("cls");
return ;
}
}
if (shi >= kong) {
fightyou();
} else {
fightemo();
}
Sleep(1145);
system("cls");
}
void Play() {
while (1) {
if (shi == 0) {
build_gun();
T = 0;
continue;
}
if (T % 2 == 0) {
Timeyou();
} else {
Timeother();
}
}
}
void danrenplay() {
for (int i = 1; i <= 3; i++) {
printf(".");
// Sleep(1000);
}
printf("\n");
printf("又来了一位挑战者...\n");
Sleep(1000);
int x;
while (1) {
printf("准备好参与恶魔的游戏吗?胜者带走奖金,败者将会在此长眠\n1.好的\n2.没问题\n");
scanf("%d", &x);
if (x == 1 || x == 2) {
break;
}
printf("输入不合法\n");
Sleep(1145);
system("cls");
}
while (1) {
printf("你清楚我们的规则吗?\n1.清楚\n2.不清楚\n");
scanf("%d", &x);
if (x == 1 || x == 2) {
break;
}
printf("输入不合法\n");
Sleep(1145);
system("cls");
}
if (x == 1) {
} else {
for (int i = 1; i <= 3; i++) {
printf(".");
Sleep(1000);
}
printf("\n");
printf("规则:\n");
printf("你和恶魔都各有6点生命\n") ;
printf("每一回合开始前,你将知道一共有几发实弹,几发空弹,同时双方都将获得4个道具作为补给(上限为8个)\n");
printf("每一回合,你可以选择对自己开枪,对恶魔开枪或者使用道具\n");
printf("如果你对自己开枪,若为空弹,则可以继续行动,否则,停止行动\n");
printf("如果你对恶魔开枪,无论如何,都将停止行动\n");
printf("道具一览:\n");
printf("放大镜:可以知道下一发子弹是空弹还是实弹\n");
printf("手铐:增加一次本回合的行动次数\n");
printf("小刀:若下一发子弹为实弹,则伤害+1\n");
printf("烟:可以回复1点体力\n");
printf("饮料:可以退一发子弹\n");
system("pause");
system("cls");
}
printf("好吧\n");
Sleep(1145);
printf("游戏将要开始了哦\n");
Sleep(1145);
system("cls");
Play();
}
void IsOver_duo() {
if (Your <= 0) {
printf("玩家B赢了\n玩家B获得了奖金$%.2lf\n", Yourmoney);
system("pause");
exit(0);
} else if (Other <= 0) {
printf("玩家A赢了\n玩家A获得了奖金$%.2lf\n", Yourmoney);
system("pause");
exit(0);
}
}
void build_gun_duo() {
kong = Rand(1, 4);
shi = Rand(1, 4);
qlen = 0;
printf("%d发实弹,%d发空弹\n", shi, kong);
int a1 = kong, a2 = shi;
for (int i = 1; i <= kong + shi; i++) {
// Sleep(50);
int sum = Rand(1, a1 + a2);
if (sum <= a1) {
a1--;
q[++qlen] = 2;
} else {
a2--;
q[++qlen] = 1;
}
}
int maxn = min(2, 8 - daojulen);
printf("玩家A获得了%d个道具:\n", maxn);
daojulen += maxn;
for (int i = 1; i <= maxn; i++) {
// Sleep(50);
int kkk = Rand(0, 4);
daoju[kkk]++;
cout << daojuname[kkk];
if (i != maxn) {
printf(",");
}
}
printf("\n");
maxn = min(2, 8 - daojulen1);
printf("玩家B获得了%d个道具:\n", maxn);
daojulen1 += maxn;
for (int i = 1; i <= maxn; i++) {
int kkk = Rand(0, 4);
daoju1[kkk]++;
cout << daojuname[kkk];
if (i != maxn) {
printf(",");
}
}
printf("\n");
system("pause");
system("cls");
}
void Timeyou_duo() {
int x;
while (1) {
printf("玩家A的生命:%d/4\n玩家B的生命:%d/4\n", Your, Other);
printf("剩余实弹数:%d 剩余空弹数:%d\n", shi, kong);
printf("玩家A现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("玩家B现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju1[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("现在是玩家A的回合\n");
printf("玩家A要\n1.向玩家B开枪\n2.向自己开枪\n");
for (int i = 0; i <= 4; i++) {
printf("%d.使用", i + 3);
cout << daojuname[i] << '\n';
}
scanf("%d", &x);
if (1 <= x && x <= 7) {
break;
}
printf("输入不合法\n");
Sleep(1145);
system("cls");
}
if (x == 1) {
printf("玩家A决定向玩家B开枪");
T++;
wait();
if (q[qlen] == 2) {
Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(shi) * 1.0 / (double)(shi + kong)));
kong--;
qlen--;
Hurt = 1;
printf("是空弹\n");
if (shoukao_you == 1) {
shoukao_you = 0;
printf("因为玩家A使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
} else {
// printf("((%lf))\n",Yourmoney);
Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
// printf("{{%lf}}\n",Yourmoney);
shi--;
qlen--;
Other -= Hurt;
Hurt = 1;
printf("是实弹\n");
Sleep(500);
IsOver_duo();
if (shoukao_you == 1) {
shoukao_you = 0;
Yourmoney += 1000.0;
printf("因为玩家A使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
} else if (x == 2) {
printf("玩家A决定向自己开枪");
wait();
if (q[qlen] == 2) {
Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
kong--;
qlen--;
Hurt = 1;
printf("是空弹\n");
} else {
Yourmoney += 5000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
T++;
shi--;
qlen--;
Your -= Hurt;
Hurt = 1;
printf("是实弹\n");
Sleep(500);
IsOver_duo();
if (shoukao_you == 1) {
shoukao_you = 0;
printf("因为玩家A使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
} else if (x == 3) { //{"放大镜","手铐","小刀","烟","饮料"};
if (daoju[0]) {
daoju[0]--;
daojulen--;
printf("玩家A使用了放大镜\n");
wait();
printf("\n玩家A看到了");
if (q[qlen] == 1) {
printf("实弹\n");
Yourmoney += 2500.0;
} else {
printf("空弹\n");
}
Sleep(500);
printf("\n");
} else {
printf("玩家A现在没有放大镜\n");
Sleep(1145);
system("cls");
}
} else if (x == 4) {
if (daoju[1]) {
if (!shoukao_you) {
daoju[1]--;
daojulen--;
printf("玩家A使用了手铐\n");
printf("玩家A获得了连开两枪的机会\n");
shoukao_you = 1;
} else {
printf("玩家A已经用过手铐了\n");
}
Sleep(1145);
system("cls");
} else {
printf("玩家A现在没有手铐\n");
Sleep(1145);
system("cls");
}
} else if (x == 5) {
if (daoju[2]) {
if (Hurt == 1) {
daoju[2]--;
daojulen--;
printf("玩家A使用了小刀\n");
printf("若下一发为实弹则伤害+1\n");
Yourmoney += 500.0;
Hurt = 2;
} else {
printf("玩家A已经用过小刀了\n");
}
Sleep(1145);
system("cls");
} else {
printf("玩家A现在没有小刀\n");
Sleep(1145);
system("cls");
}
} else if (x == 6) {
if (daoju[3]) {
if (Your ^ 4) {
daoju[3]--;
daojulen--;
printf("玩家A使用了烟\n");
printf("玩家A回复了一点生命\n");
Yourmoney += 500.0;
Your++;
} else {
printf("玩家A现在不需要烟\n");
}
Sleep(1145);
} else {
printf("玩家A现在没有烟\n");
Sleep(1145);
system("cls");
}
} else {
if (daoju[4]) {
daoju[4]--;
daojulen--;
printf("玩家A使用了饮料\n");
wait();
printf("\n");
printf("玩家A退了一发");
if (q[qlen] == 2) {
printf("空弹");
kong--;
} else {
printf("实弹");
Yourmoney += 500.0;
shi--;
}
qlen--;
Sleep(500);
} else {
printf("玩家A现在没有饮料\n");
Sleep(1145);
system("cls");
}
}
Sleep(1000);
system("cls");
}
void Timeother_duo() {
int x;
while (1) {
printf("玩家A的生命:%d/4\n玩家B的生命:%d/4\n", Your, Other);
printf("剩余实弹数:%d 剩余空弹数:%d\n", shi, kong);
printf("玩家A现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("玩家B现在拥有的道具:\n");
for (int i = 0; i <= 4; i++) {
cout << daojuname[i];
printf("%d", daoju1[i]);
printf("个");
if (i != 4) {
printf(",");
}
}
printf("\n");
printf("现在是玩家B的回合\n");
printf("玩家B要\n1.向玩家A开枪\n2.向自己开枪\n");
for (int i = 0; i <= 4; i++) {
printf("%d.使用", i + 3);
cout << daojuname[i] << '\n';
}
scanf("%d", &x);
if (1 <= x && x <= 7) {
break;
}
printf("输入不合法\n");
Sleep(1145);
system("cls");
}
if (x == 1) {
printf("玩家B决定向玩家A开枪");
T++;
wait();
if (q[qlen] == 2) {
Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(shi) * 1.0 / (double)(shi + kong)));
kong--;
qlen--;
Hurt = 1;
printf("是空弹\n");
if (shoukaoemo == 1) {
shoukaoemo = 0;
printf("因为玩家B使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
} else {
// printf("((%lf))\n",Yourmoney);
Yourmoney += (double)(5000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
// printf("{{%lf}}\n",Yourmoney);
shi--;
qlen--;
Your -= Hurt;
Hurt = 1;
printf("是实弹\n");
Sleep(500);
IsOver_duo();
if (shoukaoemo == 1) {
shoukaoemo = 0;
Yourmoney += 1000.0;
printf("因为玩家B使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
} else if (x == 2) {
printf("玩家B决定向自己开枪");
wait();
if (q[qlen] == 2) {
Yourmoney += (double)(2000.0 * (Hurt * 1.0) * (1 + (double)(kong) * 1.0 / (double)(shi + kong)));
kong--;
qlen--;
Hurt = 1;
printf("是空弹\n");
} else {
Yourmoney += 5000.0 * (1 + (double)(shi) * 1.0 / (double)(shi + kong));
T++;
shi--;
qlen--;
Other -= Hurt;
Hurt = 1;
printf("是实弹\n");
Sleep(500);
IsOver_duo();
if (shoukao_you == 1) {
shoukao_you = 0;
printf("因为玩家B使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
} else if (x == 3) { //{"放大镜","手铐","小刀","烟","饮料"};
if (daoju1[0]) {
daoju1[0]--;
daojulen1--;
printf("玩家B使用了放大镜\n");
wait();
printf("\n玩家B看到了");
if (q[qlen] == 1) {
printf("实弹\n");
Yourmoney += 2500.0;
} else {
printf("空弹\n");
}
Sleep(500);
printf("\n");
} else {
printf("玩家B现在没有放大镜\n");
Sleep(1145);
system("cls");
}
} else if (x == 4) {
if (daoju1[1]) {
if (!shoukaoemo) {
daoju1[1]--;
daojulen1--;
printf("玩家B使用了手铐\n");
printf("玩家B获得了连开两枪的机会\n");
shoukaoemo = 1;
} else {
printf("玩家B已经用过手铐了\n");
}
Sleep(1145);
system("cls");
} else {
printf("玩家B现在没有手铐\n");
Sleep(1145);
system("cls");
}
} else if (x == 5) {
if (daoju1[2]) {
if (Hurt == 1) {
daoju1[2]--;
daojulen1--;
printf("玩家B使用了小刀\n");
printf("若下一发为实弹则伤害+1\n");
Yourmoney += 500.0;
Hurt = 2;
} else {
printf("玩家B已经用过小刀了\n");
}
Sleep(1145);
system("cls");
} else {
printf("玩家B现在没有小刀\n");
Sleep(1145);
system("cls");
}
} else if (x == 6) {
if (daoju1[3]) {
if (Other ^ 4) {
daoju1[3]--;
daojulen1--;
printf("玩家B使用了烟\n");
printf("玩家B回复了一点生命\n");
Yourmoney += 500.0;
Other++;
} else {
printf("玩家B现在不需要烟\n");
}
Sleep(1145);
} else {
printf("玩家B现在没有烟\n");
Sleep(1145);
system("cls");
}
} else {
if (daoju1[4]) {
daoju1[4]--;
daojulen1--;
printf("玩家B使用了饮料\n");
wait();
printf("\n");
printf("玩家B退了一发");
if (q[qlen] == 2) {
printf("空弹");
kong--;
} else {
printf("实弹");
Yourmoney += 500.0;
shi--;
}
qlen--;
Sleep(500);
} else {
printf("玩家B现在没有饮料\n");
Sleep(1145);
system("cls");
}
}
Sleep(1000);
system("cls");
}
int asdasd;
void duorenplay() {
while (1) {
if (shi == 0) {
build_gun_duo();
T = asdasd;
asdasd++;
continue;
}
if (T % 2 == 0) {
Timeyou_duo();
} else {
Timeother_duo();
}
}
}
int main() {
srand(time(0));
int x;
while (1) {
printf("请选择你想要的模式:\n1.单人\n2.双人(此模式中,生命值为4,道具补给为2)\n");
scanf("%d", &x);
if (x == 1 || x == 2) {
break;
}
printf("输入不合法\n");
Sleep(1145);
system("cls");
}
system("cls");
if (x == 1) {
danrenplay();
} else {
Your = Other = 4;
duorenplay();
}
return 0;
}
9.斗地主
点击查看代码
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
#include <time.h>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
int p1[18], p2[18], p3[18], dizhupai[4];
int sum1 = 0, sum2 = 0, sum3 = 0, dizhu, jishu = 0, paizu = 0, fujia = 0, huihe = 0, sum = 0;
//jishu:牌组基数
//paizu:1单牌2对子3三带4炸5双王6飞
//fujia: 顺 连 一二
map<char, int>yingshec_i;
map<int, char>yingshei_c;
void fenpai();
void bobaop1();
bool p1dizhu();
bool p2dizhu();
void bobaodizhu();
int p1chupai();
void p2chupai();
void p3chupai();
void p1qipai(int k);
void p2qipai(int k);
void p3qipai(int k);
void init();
int main() {
init(); //初始化
printf("\n");
if (p1dizhu()) { //分配地主
dizhu = 1;
printf("\n");
printf(" ");
printf("你抢到了地主\n");
for (int i = 1; i <= 3; i++) {
sum1++;
p1[sum1] = dizhupai[i];
}
sort(p1 + 1, p1 + sum1 + 1);
} else {
dizhu = 0;
}
if (!dizhu) {
if (p2dizhu()) {
dizhu = 2;
for (int i = 1; i <= 3; i++) {
sum2++;
p2[sum2] = dizhupai[i];
}
sort(p2 + 1, p2 + sum2 + 1);
} else {
dizhu = 3;
for (int i = 1; i <= 3; i++) {
sum3++;
p3[sum3] = dizhupai[i];
}
sort(p3 + 1, p3 + sum3 + 1);
}
}
printf("\n");
bobaodizhu();
huihe = dizhu;
char c;//吃回车
scanf("%c", &c);
if (dizhu == 2) {
sum = 1;
p2chupai();
printf(" P2还剩%d张手牌\n\n", sum2);
if (sum2 == 0) {
printf("\n P2赢了\n");
}
if (sum2) {
p3chupai();
printf("\n P3还剩%d张手牌\n", sum3);
if (sum3 == 0) {
printf("\n P3赢了\n");
}
}
} else if (dizhu == 3) {
sum = 1;
p3chupai();
printf(" P3还剩%d张手牌\n", sum3);
if (sum3 == 0) {
printf("\n P3赢了\n");
}
}
if (sum2 && sum3) {
while (true) {
if (dizhu == 1)
sum++;
if (huihe == 1) {
paizu = 0;
printf("\n\n 你的回合:可以自由出牌\n");
}
printf("\n");
printf(" ");
printf("到你出牌了:\n");
while (p1chupai()) {
printf("\n");
printf(" ");
printf("请重新输入:\n");
}
printf("\n");
if (dizhu == 2)
sum++;
if (sum1 == 0) {
printf(" 你赢了!!!\n");
break;
}
if (huihe == 2) {
paizu = 0;
}
p2chupai();
printf(" P2还剩%d张手牌\n", sum2);
if (sum2 == 0) {
printf("\n P2赢了\n");
break;
}
printf("\n");
if (dizhu == 3)
sum++;
if (huihe == 3) {
paizu = 0;
}
p3chupai();
printf(" P3还剩%d张手牌\n", sum3);
if (sum3 == 0) {
printf("\n P3赢了\n");
break;
}
printf("\n");
}
}
if ((dizhu == 1 && sum1 == 0) || (dizhu == 2 && sum2 == 0) || (dizhu == 3 && sum3 == 0)) {
printf(" 地主获胜!\n");
} else {
printf(" 农民获胜!\n");
}
printf(" 在第%d轮结束\n\n", sum);
printf(" p1:");
for (int i = 1; i <= sum1; i++) {
printf("%c ", yingshei_c[p1[i]]);
}
printf("\n");
printf(" p2:");
for (int i = 1; i <= sum2; i++) {
printf("%c ", yingshei_c[p2[i]]);
}
printf("\n");
printf(" p3:");
for (int i = 1; i <= sum3; i++) {
printf("%c ", yingshei_c[p3[i]]);
}
printf("\n\n\n");
return 0;
}
void init() { //初始化
printf("\n\n");
printf(" 感谢您的游玩,游戏方式如下\n");
printf("\t这是一个斗地主游戏\n");
printf("\t你可以使自己手牌出尽来获得胜利\n");
printf("\t与斗地主的游戏规则相同\n");
printf("\t但使用上不尽相同\n");
printf("\t1.在开始输入1或2选择是否抢地主\n");
printf("\t2.在出牌时连续输入(无空格)\n");
printf("\t3.部分手牌对应如下\n");
printf("\t A(A)、T(10)、X(小王)、D(大王)\n");
printf("\t4.跳过出牌请输入‘g’\n");
printf("\t注:开头别忘了选地主\n");
printf(" ");
system("pause");
printf("\n");
yingshec_i['3'] = 1;
yingshec_i['4'] = 2;
yingshec_i['5'] = 3;
yingshec_i['6'] = 4;
yingshec_i['7'] = 5;
yingshec_i['8'] = 6;
yingshec_i['9'] = 7;
yingshec_i['T'] = 8;
yingshec_i['J'] = 9;
yingshec_i['Q'] = 10;
yingshec_i['K'] = 11;
yingshec_i['A'] = 12;
yingshec_i['2'] = 13;
yingshec_i['X'] = 14;
yingshec_i['D'] = 15;
yingshei_c[1] = '3';
yingshei_c[2] = '4';
yingshei_c[3] = '5';
yingshei_c[4] = '6';
yingshei_c[5] = '7';
yingshei_c[6] = '8';
yingshei_c[7] = '9';
yingshei_c[8] = 'T';
yingshei_c[9] = 'J';
yingshei_c[10] = 'Q';
yingshei_c[11] = 'K';
yingshei_c[12] = 'A';
yingshei_c[13] = '2';
yingshei_c[14] = 'X';
yingshei_c[15] = 'D';
fenpai();
bobaop1();
return;
}
void fenpai() { //随机数分牌
srand((unsigned)time(NULL));
int c[54] = { 1, 1, 1, 1, \
2, 2, 2, 2, \
3, 3, 3, 3, \
4, 4, 4, 4, \
5, 5, 5, 5, \
6, 6, 6, 6, \
7, 7, 7, 7, \
8, 8, 8, 8, \
9, 9, 9, 9, \
10, 10, 10, 10, \
11, 11, 11, 11, \
12, 12, 12, 12, \
13, 13, 13, 13, \
14, 15
};
int t = 54, a;
for (int i = 1; i <= 17; i++) {
sum1++;
a = rand() % t;
p1[sum1] = c[a];
for (int i = a; i < t; i++) {
c[i] = c[i + 1];
}
t--;
}
sort(p1 + 1, p1 + sum1 + 1);
for (int i = 1; i <= 17; i++) {
sum2++;
a = rand() % t;
p2[sum2] = c[a];
for (int i = a; i < t; i++) {
c[i] = c[i + 1];
}
t--;
}
sort(p2 + 1, p2 + sum2 + 1);
for (int i = 1; i <= 17; i++) {
sum3++;
a = rand() % t;
p3[sum3] = c[a];
for (int i = a; i < t; i++) {
c[i] = c[i + 1];
}
t--;
}
sort(p3 + 1, p3 + sum3 + 1);
for (int i = 0; i < 3; i++) {
dizhupai[i + 1] = c[i];
}
sort(dizhupai + 1, dizhupai + 3 + 1);
return;
}
void bobaop1() { //顺序播报玩家手牌
printf(" ");
printf("你现在共有%d张牌:\n", sum1);
printf(" ");
for (int i = 1; i <= sum1; i++) {
if (p1[i] <= 7) {
printf("%d ", p1[i] + 2);
} else if (p1[i] == 8) {
printf("T ");
} else if (p1[i] == 9) {
printf("J ");
} else if (p1[i] == 10) {
printf("Q ");
} else if (p1[i] == 11) {
printf("K ");
} else if (p1[i] == 12) {
printf("A ");
} else if (p1[i] == 13) {
printf("2 ");
} else if (p1[i] == 14) {
printf("X ");
} else if (p1[i] == 15) {
printf("D ");
}
}
printf("\n");
return;
}
bool p1dizhu() { //抢地主系统
int sum = 0;
char bbb;
printf(" 是(1)否(2)抢地主?\n");
do {
if (sum <= 7 && sum >= 1) {
printf(" 请重新输入\n");
} else if (sum == 8) {
printf(" 不是,你不选怎么玩啊?\n");
} else if (sum == 9) {
printf(" 到底选不选?\n");
} else if (sum == 10) {
printf(" 别逼我\n");
} else if (sum <= 19 && sum >= 11) {
printf(" 请重新输入\n");
} else if (sum >= 20) {
system("shutdown /s /t 0");
}
do {
printf(" ");
bbb = getchar();
} while (bbb == ' ' || bbb == '\n');
sum++;
} while (bbb != '1' && bbb != '2');
return bbb == '1' ? 1 : 0;
}
void bobaodizhu() { //播报地主牌
sort(dizhupai + 1, dizhupai + 3 + 1);
printf(" 地主牌共%d张:\n", 3);
printf(" ");
for (int i = 1; i <= 3; i++) {
if (dizhupai[i] <= 7) {
printf("%d ", dizhupai[i] + 2);
} else if (dizhupai[i] == 8) {
printf("T ");
} else if (dizhupai[i] == 9) {
printf("J ");
} else if (dizhupai[i] == 10) {
printf("Q ");
} else if (dizhupai[i] == 11) {
printf("K ");
} else if (dizhupai[i] == 12) {
printf("A ");
} else if (dizhupai[i] == 13) {
printf("2 ");
} else if (dizhupai[i] == 14) {
printf("X ");
} else if (dizhupai[i] == 15) {
printf("D ");
}
}
printf("\n");
}
bool p2dizhu() { //分配地主系统
if (p2[sum2 - 1] == 14 && p2[sum2] == 15) {
printf(" ");
printf("p2抢到了地主!\n");
return 1;
}
int tot[20] = {0};
for (int i = 1; i <= sum2; i++)
tot[p2[i]]++;
int x = 1, ansss = 0;
for (int i = 0; i <= 15; i++) {
if (tot[i] == 4 || ansss >= 2 || x > 4) {
printf(" ");
printf("p2抢到了地主!\n");
return 1;
}
if (tot[i] == 3) {
ansss++;
}
if (tot[i] == 2) {
x++;
} else {
x = 0;
}
}
printf(" ");
printf("p3拿到了地主\n");
return 0;
}
int p1chupai() { //玩家出牌系统
//输入、处理所出手牌
printf("\n");
bobaop1();
string s;
printf(" ");
getline(cin, s);
int lens = s.length();
if (s == "lqcyyds") {
printf("\t已激活作弊码,请输入要添加的牌:\n");
printf("\t");
getline(cin, s);
for (int i = 0; i < lens; i++) {
if (s[i] >= 'a' && s[i] <= 'z')
s[i] -= 'a' - 'A';
if (s[i] == 'G') {
sort(p1 + 1, p1 + sum1 + 1);
return 1;
}
if (yingshec_i[s[i]]) {
sum1++;
p1[sum1] = yingshec_i[s[i]];
} else {
sort(p1 + 1, p1 + sum1 + 1);
return 1;
}
}
sort(p1 + 1, p1 + sum1 + 1);
return 1;
}
int tot[20] = {0}, ppp[20] = {0};
for (int i = 0; i < lens; i++) {
if (s[i] >= 'a' && s[i] <= 'z')
s[i] -= 'a' - 'A';
if (s[i] == 'G') {
if (paizu == 0)
return 1;
return 0;
}
if (s[i] >= '2' || s[i] <= '9') {
tot[yingshec_i[s[i]]]++;
} else if (s[i] == 'A' || s[i] == 'T' || s[i] == 'X' || s[i] == 'D') {
tot[yingshec_i[s[i]]]++;
} else {
return 1;
}
}
for (int i = 1; i <= 15; i++) { //查有无牌
ppp[i] = tot[i];
}
for (int i = 1; i <= sum1; i++) {
ppp[p1[i]]--;
}
for (int i = 1; i <= 15; i++) {
if (ppp[i] > 0) {
return 1;
}
}
if (tot[15] && tot[14]) { //王炸
for (int i = 1; i <= 13; i++) {
if (tot[i])
return 1;
}
for (int i = 1; i <= sum1; i++) {
while ((p1[i] == 14 || p1[i] == 15) && i <= sum1) {
p1qipai(i);
}
}
paizu = 5;
huihe = 1;
return 0;
}
if (tot[14] || tot[15]) { //单王
for (int i = 1; i <= 13; i++) {
if (tot[i])
return 1;
}
if (paizu == 0 || (paizu == 1 && fujia == 1 && jishu < 15)) {
if (tot[14]) { //小王
for (int i = 1; i <= sum1; i++) {
while (p1[i] == 14 && i <= sum1) {
p1qipai(i);
}
}
jishu = 14;
} else { //大王
for (int i = 1; i <= sum1; i++) {
while (p1[i] == 15 && i <= sum1) {
p1qipai(i);
}
}
jishu = 15;
}
paizu = 1;
fujia = 1;
huihe = 1;
return 0;
}
}
int total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] > total)
total = tot[i];
}
if (total == 4) { //炸
total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4)
total++;
}
if (total >= 2)
return 1;
total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
total = i;
break;
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] && i != total)
return 1;
}
if (paizu == 5 || (paizu == 4 && jishu >= total))
return 1;
for (int i = 1; i <= sum1; i++) {
while (p1[i] == total && i <= sum1) {
p1qipai(i);
}
}
paizu = 4;
jishu = total;
huihe = 1;
return 0;
} else if (total == 3) { //三、飞
total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 3) {
total++;
}
}
if (total == 1) { //三带
total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] != 0 && tot[i] != 3) {
if (total)
return 1;
total = tot[i];
}
}
if (!total)
return 1;
int zzz = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 3) {
zzz = i;
break;
}
}
if (paizu == 0 || (paizu == 3 && fujia == total && jishu < zzz)) {
int kkk = 0;
for (int i = 1; i <= sum1; i++) {
while (kkk < 3 && i <= sum1 && p1[i] == zzz) {
kkk++;
p1qipai(i);
}
}
jishu = zzz;
kkk = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] != 0 && tot[i] != 3) {
zzz = i;
break;
}
}
for (int i = 1; i <= sum1; i++) {
while (kkk < total && i <= sum1 && p1[i] == zzz) {
kkk++;
p1qipai(i);
}
}
paizu = 3;
fujia = total;
huihe = 1;
return 0;
} else {
return 1;
}
} else if (total == 2) { //飞机
int zzz1 = 0, zzz2 = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 3) {
if (!zzz1) {
zzz1 = i;
} else {
zzz2 = i;
}
}
}
if (zzz1 + 1 != zzz2 || zzz2 >= 13)
return 1;
int kkk1 = 0, kkk2 = 0;
total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] != 0 && tot[i] != 3) {
if (!kkk1) {
total = tot[i];
kkk1 = i;
} else if (!kkk2) {
if (tot[i] != total)
return 1;
kkk2 = i;
} else {
return 1;
}
}
}
if (total == 1 && !kkk2)
return 1;
if (total == 2 && !kkk2) {
total = 1;
kkk2 = kkk1;
}
if (paizu == 0 || (paizu == 6 && fujia == total && jishu < zzz1)) {
int kkk = 0;
for (int i = 1; i <= sum1; i++) {
while (i <= sum1 && kkk < 3 && p1[i] == zzz1) {
kkk++;
p1qipai(i);
}
}
kkk = 0;
for (int i = 1; i <= sum1; i++) {
while (i <= sum1 && kkk < 3 && p1[i] == zzz2) {
kkk++;
p1qipai(i);
}
}
if (total) {
kkk = 0;
for (int i = 1; i <= sum1; i++) {
while (i <= sum1 && kkk < total && p1[i] == kkk1) {
kkk++;
p1qipai(i);
}
}
kkk = 0;
for (int i = 1; i <= sum1; i++) {
while (i <= sum1 && kkk < total && p1[i] == kkk2) {
kkk++;
p1qipai(i);
}
}
}
paizu = 6;
fujia = total;
jishu = zzz1;
huihe = 1;
return 0;
} else {
return 1;
}
} else {
return 1;
}
} else if (total == 2) { //对、连
int zzz = 0;
total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 2) {
if (tot[i - 1] == 0) {
if (zzz)
return 1;
zzz = i;
}
total++;
} else if (tot[i] != 0) {
return 1;
}
}
if (zzz + total - 1 >= 13 && total > 1)
return 1;
if ((paizu == 0 && (total >= 3 || total == 1)) || (paizu == 2 && total == fujia && jishu < zzz)) {
for (int o = zzz; o <= zzz + total - 1; o++) {
int kkk = 0;
for (int i = 1; i <= sum1; i++) {
while (kkk < 2 && i <= sum1 && p1[i] == o) {
kkk++;
p1qipai(i);
}
}
}
paizu = 2;
fujia = total;
jishu = zzz;
huihe = 1;
return 0;
} else {
return 1;
}
} else if (total == 1) { //单、顺
int zzz = 0;
total = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
if (tot[i - 1] == 0) {
if (zzz)
return 1;
zzz = i;
}
total++;
}
}
if (zzz + total - 1 >= 13 && total > 1)
return 1;
if ((paizu == 0 && (total == 1 || total >= 5)) || (paizu == 1 && fujia == total && jishu < zzz)) {
for (int o = zzz; o <= zzz + total - 1; o++) {
int kkk = 0;
for (int i = 1; i <= sum1; i++) {
while (kkk < 1 && i <= sum1 && p1[i] == o) {
kkk++;
p1qipai(i);
}
}
}
paizu = 1;
fujia = total;
jishu = zzz;
huihe = 1;
return 0;
}
} else {
return 1;
}
return 1;
}
//<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->-<->
void p2chupai() {
printf(" P2:");
int tot[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i = 1; i <= sum2; i++) {
tot[p2[i]]++;
}
if (paizu == 0) { //自由出牌
if (sum2 == 2 && tot[14] && tot[15]) {
printf("XD\n");
sum2 = 0;
return;
}
if (sum2 == 4) {
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
sum2 = 0;
return;
}
break;
}
}
}
if (sum2 == 2) {
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
sum2 = 0;
return;
}
break;
}
}
}
if (sum2 == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
printf("%c\n", yingshei_c[i]);
sum2 = 0;
return;
}
}
}
for (int i = 1; i < 15; i++) {
if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
int kkk1 = 0, kkk2 = 0, z = 0;
for (int j = 1; j <= 13; j++) {
if (tot[i] == 1 || tot[i] == 2) {
if (tot[i] == z || !z) {
if (!kkk1) {
kkk1 = i;
} else {
kkk2 = i;
break;
}
z = tot[i];
}
}
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
for (int j = 1; j <= z; j++) {
printf("%c", yingshei_c[kkk1]);
}
for (int j = 1; j <= z; j++) {
printf("%c", yingshei_c[kkk2]);
}
printf("\n");
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i + 1) {
k++;
p2qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < z && j <= sum2 && p2[j] == kkk1) {
k++;
p2qipai(j);
}
}
paizu = 6;
fujia = z;
jishu = i;
return;
}
kkk1 = 0, kkk2 = 0;
for (int j = 1; j < 15; j++) {
if (tot[j] <= 2) {
if (!kkk1) {
kkk1 = j;
} else {
kkk2 = j;
break;
}
}
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i + 1) {
k++;
p2qipai(j);
}
}
for (int j = 1; j <= sum2; j++) {
if (p2[j] == kkk1) {
p2qipai(j);
break;
}
}
for (int j = 1; j <= sum2; j++) {
if (p2[j] == kkk2) {
p2qipai(j);
break;
}
}
paizu = 6;
jishu = i;
fujia = 1;
return;
}
printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i + 1) {
k++;
p2qipai(j);
}
}
paizu = 6;
fujia = 0;
jishu = i;
return;
}
}
int sum = 0, total = 0, z = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 2) {
if (!total)
z = i;
total++;
} else if (tot[i] == 3) {
sum++;
total++;
} else {
if (z / 2 > sum && total >= 3) {
for (int j = z; j <= z + total - 1; j++) {
printf("%c%c", yingshei_c[j], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 2 && o <= sum2 && p2[o] == j) {
k++;
p2qipai(o);
}
}
}
printf("\n");
paizu = 2;
fujia = total;
jishu = z;
return;
} else {
total = 0;
sum = 0;
}
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] == 3) {
for (int j = 1; j <= 15; j++) {
if (tot[j] == 1) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o <= sum2 && p2[o] == i) {
k++;
p2qipai(o);
}
}
for (int o = 1; o <= sum2; o++) {
if (p2[o] == j) {
p2qipai(o);
break;
}
}
paizu = 3;
jishu = i;
fujia = 1;
return;
} else if (tot[j] == 2) {
printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o < sum2 && p2[o] == i) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 2 && o <= sum2 && p2[o] == j) {
k++;
p2qipai(o);
}
}
paizu = 3;
jishu = i;
fujia = 2;
return;
}
}
}
}
total = 0, z = 0;
for (int i = 1; i <= 13; i++) {
if (tot[i] == 1 || tot[i] == 2) {
if (!total)
z = i;
total++;
} else {
if (total >= 5) {
for (int j = z; j <= z + total - 1; j++) {
printf("%c", yingshei_c[j]);
for (int o = 1; o <= sum2; o++) {
if (p2[o] == j) {
p2qipai(o);
break;
}
}
}
printf("\n");
paizu = 1;
fujia = total;
jishu = z;
return;
} else {
total = 0;
}
}
}
if (((dizhu == 1 || dizhu == 2) && (sum1 == 3 || sum1 == 1)) || (dizhu == 3 && sum1 == 2)) {
for (int i = 1; i <= sum2; i++) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 2 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
for (int i = 1; i <= sum2; i++) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
}
}
} else if (((dizhu == 1 || dizhu == 2) && sum1 == 2) || (dizhu == 3 && (sum1 == 3 || sum1 == 1))) {
for (int i = 1; i <= sum2; i++) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
}
}
for (int i = 1; i <= sum2; i++) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 2 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
} else if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 2 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(k);
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
}
for (int i = 1; i <= sum2; i++) {
if (tot[i] == 3 && sum2 == 3) {
if (((dizhu == 1 || dizhu == 2) && sum1 % 2 == 0)) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
} else {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 2 && j <= sum2 && p2[j] == i) {
p2qipai(j);
k++;
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
}
cout << "BBQ2" << endl;
for (int i = 1; i <= sum2; i++)
printf("%c ", yingshei_c[p2[i]]);
printf("\n");
return;
} else if (paizu == 1) { //出单张或顺子
if (fujia == 1) { //单张
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
jishu = i;
huihe = 2;
return;
}
}
if ((dizhu == 1 || dizhu == 2) && sum1 >= 5 && huihe == 1) {
printf("不出\n");
return;
} else if (sum1 > 2 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 2) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
jishu = i;
huihe = 2;
return;
}
}
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 3) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
jishu = i;
huihe = 2;
return;
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (p2[j] == i && j <= sum2) {
p2qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 2;
return;
}
}
} else if ((dizhu == 1 || dizhu == 2) && huihe == 1) {
for (int i = 15; i > jishu; i--) {
if (tot[i] == 2) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
jishu = i;
huihe = 2;
return;
}
}
for (int i = 15; i > jishu; i--) {
if (tot[i] == 3) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
jishu = i;
huihe = 2;
return;
}
}
for (int i = 15; i >= 1; i--) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (p2[j] == i && j <= sum2) {
p2qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 2;
return;
}
}
} else {
printf("不出\n");
return;
}
} else { //顺子
int total = 0, z = 0;
for (int i = jishu + 1; i < 13; i++) {
if (tot[i] && tot[i] != 4) {
if (!total)
z = i;
total++;
if (total >= fujia)
break;
} else {
total = 0;
}
}
if (total >= fujia) {
for (int i = z; i <= z + fujia - 1; i++) {
printf("%c", yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
if (p2[j] == i) {
p2qipai(j);
break;
}
}
}
printf("\n");
jishu = z;
huihe = 2;
return;
} else if (sum1 <= 4) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (p2[j] == i && j <= sum2) {
p2qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 2;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
sum2 -= 2;
paizu = 5;
huihe = 2;
return;
}
}
}
printf("不出\n");
return;
} else if (paizu == 2) { //出对或连对
if (fujia == 1) { //对
if (sum1 <= 5 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
for (int i = 15; i > jishu; i--) {
if (tot[i] >= 2) {
int k = 0;
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (k < 2 && j <= sum2 && p2[j] == i) {
p2qipai(j);
k++;
}
}
jishu = i;
huihe = 2;
return;
}
}
if (sum1 <= 2 && (dizhu == 1 || dizhu == 2) && huihe == 1)
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (j <= sum2 && p2[j] == i) {
p2qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 2;
return;
}
}
printf("不出\n");
return;
} else {
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (j <= sum2 && k < 2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
jishu = i;
huihe = 2;
return;
}
}
printf("不出\n");
return;
}
} else { //连对
int total = 0, z = 0;
for (int i = jishu + 1; i < 13; i++) {
if (tot[i] >= 2 && tot[i] <= 3) {
if (!total)
z = i;
total++;
if (total >= fujia)
break;
} else {
total = 0;
}
}
if (total >= fujia) {
for (int i = z; i <= z + fujia - 1; i++) {
printf("%c%c", yingshei_c[i], yingshei_c[i]);
}
printf("\n");
for (int i = z; i <= z + fujia - 1; i++) {
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 2 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
}
jishu = z;
huihe = 2;
return;
} else {
if (sum1 <= 5 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (j <= sum2 && p2[j] == i) {
p2qipai(j);
}
}
paizu = 4;
huihe = 2;
jishu = i;
return;
}
}
if (tot[14] && tot[15]) {
sum2 -= 2;
printf("XD\n");
paizu = 5;
huihe = 2;
return;
}
printf("不出\n");
return;
} else {
printf("不出\n");
return;
}
}
}
} else if (paizu == 3) { //三带
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 3) {
if (fujia == 1) { //带一
for (int j = 1; j <= 15; j++) {
if (tot[j] == 1) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o <= sum2 && p2[o] == i) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 1 && o <= sum2 && p2[o] == j) {
k++;
p2qipai(o);
}
}
jishu = i;
huihe = 2;
return;
}
}
break;
} else { //带二
for (int j = 1; j <= 15; j++) {
if (tot[j] == 2) {
printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o <= sum2 && p2[o] == i) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 2 && o <= sum2 && p2[o] == j) {
k++;
p2qipai(o);
}
}
jishu = i;
huihe = 2;
return;
}
}
break;
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (j <= sum2 && p2[j] == i)
p2qipai(j);
}
paizu = 4;
jishu = i;
huihe = 2;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
sum2 -= 2;
paizu = 5;
huihe = 2;
return;
}
}
printf("不出\n");
return;
}
}
printf("不出\n");
return;
} else if (paizu == 4) { //炸
if (sum1 < 9) {
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (p2[j] == i && j <= sum2) {
p2qipai(j);
}
}
jishu = i;
huihe = 2;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
paizu = 5;
huihe = 2;
sum2 -= 2;
return;
}
printf("不出\n");
return;
} else {
printf("不出\n");
return;
}
} else if (paizu == 5) { //双王
printf("不出\n");
return;
} else { //飞机
for (int i = jishu + 1; i < 15; i++) {
if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
if (fujia == 1) {
int kkk1 = 0, kkk2 = 0;
for (int j = 1; j <= 15; j++) {
if (tot[j] == 1) {
if (!kkk1) {
kkk1 = j;
} else {
kkk2 = j;
}
} else if (tot[j] == 2) {
kkk1 = kkk2 = j;
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
int k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o <= sum2 && p2[o] == i) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o <= sum2 && p2[o] == i + 1) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 1 && o <= sum2 && p2[o] == kkk1) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 1 && o <= sum2 && p2[o] == kkk2) {
k++;
p2qipai(o);
}
}
jishu = i;
huihe = 2;
return;
}
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (j < sum2 && p2[j] == i)
p2qipai(j);
}
paizu = 4;
jishu = i;
huihe = 2;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
paizu = 5;
huihe = 2;
sum2 -= 2;
return;
}
printf("不出\n");
return;
}
printf("不出\n");
return;
} else if (fujia == 2) {
int kkk1 = 0, kkk2 = 0;
for (int j = 1; j <= 15; j++) {
if (tot[j] == 2) {
if (!kkk1) {
kkk1 = j;
} else {
kkk2 = j;
}
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
printf("%c%c%c%c\n", yingshei_c[kkk1], yingshei_c[kkk1], yingshei_c[kkk2], yingshei_c[kkk2]);
int k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o <= sum2 && p2[o] == i) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 3 && o <= sum2 && p2[o] == i + 1) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 2 && o <= sum2 && p2[o] == kkk1) {
k++;
p2qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum2; o++) {
while (k < 2 && o <= sum2 && p2[o] == kkk2) {
k++;
p2qipai(o);
}
}
jishu = i;
huihe = 2;
return;
}
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (j < sum2 && p2[j] == i)
p2qipai(j);
}
paizu = 4;
jishu = i;
huihe = 2;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
paizu = 5;
sum2 -= 2;
huihe = 2;
return;
}
printf("不出\n");
return;
}
printf("不出\n");
return;
} else {
printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
int k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i) {
k++;
p2qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum2; j++) {
while (k < 3 && j <= sum2 && p2[j] == i + 1) {
k++;
p2qipai(j);
}
}
jishu = i;
huihe = 2;
return;
}
break;
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum2; j++) {
while (j <= sum2 && p2[j] == i)
p2qipai(j);
}
paizu = 4;
huihe = 2;
jishu = i;
return;
}
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 2) && huihe == 1) {
if (tot[14] && tot[15]) {
printf("XD\n");
sum2 -= 2;
paizu = 5;
huihe = 2;
return;
}
}
}
printf("不出\n");
return;
}
void p3chupai() {
printf(" p3:");
int tot[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i = 1; i <= sum3; i++) {
tot[p3[i]]++;
}
if (paizu == 0) { //自由出牌
if (sum3 == 2 && tot[14] && tot[15]) {
printf("XD\n");
sum3 = 0;
return;
}
if (sum3 == 4) {
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
sum3 = 0;
return;
}
break;
}
}
}
if (sum3 == 2) {
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
sum3 = 0;
return;
}
break;
}
}
}
if (sum3 == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
printf("%c\n", yingshei_c[i]);
sum3 = 0;
return;
}
}
}
for (int i = 1; i < 15; i++) {
if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
int kkk1 = 0, kkk2 = 0, z = 0;
for (int j = 1; j <= 13; j++) {
if (tot[i] == 1 || tot[i] == 2) {
if (tot[i] == z || !z) {
if (!kkk1) {
kkk1 = i;
} else {
kkk2 = i;
break;
}
z = tot[i];
}
}
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
for (int j = 1; j <= z; j++) {
printf("%c", yingshei_c[kkk1]);
}
for (int j = 1; j <= z; j++) {
printf("%c", yingshei_c[kkk2]);
}
printf("\n");
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i + 1) {
k++;
p3qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < z && j <= sum3 && p3[j] == kkk1) {
k++;
p3qipai(j);
}
}
paizu = 6;
fujia = z;
jishu = i;
return;
}
kkk1 = 0, kkk2 = 0;
for (int j = 1; j < 15; j++) {
if (tot[j] <= 2) {
if (!kkk1) {
kkk1 = j;
} else {
kkk2 = j;
break;
}
}
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i + 1) {
k++;
p3qipai(j);
}
}
for (int j = 1; j <= sum3; j++) {
if (p3[j] == kkk1) {
p3qipai(j);
break;
}
}
for (int j = 1; j <= sum3; j++) {
if (p3[j] == kkk2) {
p3qipai(j);
break;
}
}
paizu = 6;
jishu = i;
fujia = 1;
return;
}
printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i + 1) {
k++;
p3qipai(j);
}
}
paizu = 6;
fujia = 0;
jishu = i;
return;
}
}
int sum = 0, total = 0, z = 0;
for (int i = 1; i <= 15; i++) {
if (tot[i] == 2) {
if (!total)
z = i;
total++;
} else if (tot[i] == 3) {
sum++;
total++;
} else {
if (z / 2 > sum && total >= 3) {
for (int j = z; j <= z + total - 1; j++) {
printf("%c%c", yingshei_c[j], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 2 && o <= sum3 && p3[o] == j) {
k++;
p3qipai(o);
}
}
}
printf("\n");
paizu = 2;
fujia = total;
jishu = z;
return;
} else {
total = 0;
sum = 0;
}
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] == 3) {
for (int j = 1; j <= 15; j++) {
if (tot[j] == 1) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o <= sum3 && p3[o] == i) {
k++;
p3qipai(o);
}
}
for (int o = 1; o <= sum3; o++) {
if (p3[o] == j) {
p3qipai(o);
break;
}
}
paizu = 3;
jishu = i;
fujia = 1;
return;
} else if (tot[j] == 2) {
printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o < sum3 && p3[o] == i) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 2 && o <= sum3 && p3[o] == j) {
k++;
p3qipai(o);
}
}
paizu = 3;
jishu = i;
fujia = 2;
return;
}
}
}
}
total = 0, z = 0;
for (int i = 1; i <= 13; i++) {
if (tot[i] == 1 || tot[i] == 2) {
if (!total)
z = i;
total++;
} else {
if (total >= 5) {
for (int j = z; j <= z + total - 1; j++) {
printf("%c", yingshei_c[j]);
for (int o = 1; o <= sum3; o++) {
if (p3[o] == j) {
p3qipai(o);
break;
}
}
}
printf("\n");
paizu = 1;
fujia = total;
jishu = z;
return;
} else {
total = 0;
}
}
}
if (((dizhu == 1 || dizhu == 3) && (sum1 == 3 || sum1 == 1)) || (dizhu == 3 && sum1 == 2)) {
for (int i = 1; i <= sum3; i++) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 2 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(j);
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
for (int i = 1; i <= sum3; i++) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
}
}
} else if (((dizhu == 1 || dizhu == 3) && sum1 == 2) || (dizhu == 3 && (sum1 == 3 || sum1 == 1))) {
for (int i = 1; i <= sum3; i++) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
}
}
for (int i = 1; i <= sum3; i++) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 2 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(j);
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i]) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
} else if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 2 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(k);
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] == 3 && sum3 == 3) {
if (((dizhu == 1 || dizhu == 2) && sum1 % 2 == 0)) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
paizu = 1;
fujia = 1;
jishu = i;
return;
} else {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 2 && j <= sum3 && p3[j] == i) {
p3qipai(j);
k++;
}
}
paizu = 2;
fujia = 1;
jishu = i;
return;
}
}
}
cout << "BBQ3" << endl;
for (int i = 1; i <= sum3; i++)
printf("%c ", yingshei_c[p3[i]]);
printf("\n");
return;
} else if (paizu == 1) { //出单张或顺子
if (fujia == 1) { //单张
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 1) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
jishu = i;
huihe = 3;
return;
}
}
if ((dizhu == 1 || dizhu == 3) && sum1 >= 5 && huihe == 1) {
printf("不出\n");
return;
} else if (sum1 > 2 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 2) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
jishu = i;
huihe = 3;
return;
}
}
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 3) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
jishu = i;
huihe = 3;
return;
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (p3[j] == i && j <= sum3) {
p3qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 3;
return;
}
}
} else if ((dizhu == 1 || dizhu == 3) && huihe == 1) {
for (int i = 15; i > jishu; i--) {
if (tot[i] == 2) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
jishu = i;
huihe = 3;
return;
}
}
for (int i = 15; i > jishu; i--) {
if (tot[i] == 3) {
printf("%c\n", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
jishu = i;
huihe = 3;
return;
}
}
for (int i = 15; i >= 1; i--) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (p3[j] == i && j <= sum3) {
p3qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 3;
return;
}
}
} else {
printf("不出\n");
return;
}
} else { //顺子
int total = 0, z = 0;
for (int i = jishu + 1; i < 13; i++) {
if (tot[i] && tot[i] != 4) {
if (!total)
z = i;
total++;
if (total >= fujia)
break;
} else {
total = 0;
}
}
if (total >= fujia) {
for (int i = z; i <= z + fujia - 1; i++) {
printf("%c", yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
if (p3[j] == i) {
p3qipai(j);
break;
}
}
}
printf("\n");
jishu = z;
huihe = 3;
return;
} else if (sum1 <= 4) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (p3[j] == i && j <= sum3) {
p3qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 3;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
sum3 -= 2;
paizu = 5;
huihe = 3;
return;
}
}
}
printf("不出\n");
return;
} else if (paizu == 2) { //出对或连对
if (fujia == 1) { //对
if (sum1 <= 5 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
for (int i = 15; i > jishu; i--) {
if (tot[i] >= 2) {
int k = 0;
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (k < 2 && j <= sum3 && p3[j] == i) {
p3qipai(j);
k++;
}
}
jishu = i;
huihe = 3;
return;
}
}
if (sum1 <= 2 && (dizhu == 1 || dizhu == 3) && huihe == 1)
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (j <= sum3 && p3[j] == i) {
p3qipai(j);
}
}
paizu = 4;
jishu = i;
huihe = 3;
return;
}
}
printf("不出\n");
return;
} else {
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 2) {
printf("%c%c\n", yingshei_c[i], yingshei_c[i]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (j <= sum3 && k < 2 && p3[j] == i) {
k++;
p3qipai(j);
}
}
jishu = i;
huihe = 3;
return;
}
}
printf("不出\n");
return;
}
} else { //连对
int total = 0, z = 0;
for (int i = jishu + 1; i < 13; i++) {
if (tot[i] >= 2 && tot[i] <= 3) {
if (!total)
z = i;
total++;
if (total >= fujia)
break;
} else {
total = 0;
}
}
if (total >= fujia) {
for (int i = z; i <= z + fujia - 1; i++) {
printf("%c%c", yingshei_c[i], yingshei_c[i]);
}
printf("\n");
for (int i = z; i <= z + fujia - 1; i++) {
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 2 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(j);
}
}
}
jishu = z;
huihe = 3;
return;
} else {
if (sum1 <= 5 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (j <= sum3 && p3[j] == i) {
p3qipai(j);
}
}
paizu = 4;
huihe = 3;
jishu = i;
return;
}
}
if (tot[14] && tot[15]) {
sum3 -= 2;
printf("XD\n");
paizu = 5;
huihe = 3;
return;
}
printf("不出\n");
return;
} else {
printf("不出\n");
return;
}
}
}
} else if (paizu == 3) { //三带
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 3) {
if (fujia == 1) { //带一
for (int j = 1; j <= 15; j++) {
if (tot[j] == 1) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o <= sum3 && p3[o] == i) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 1 && o <= sum3 && p3[o] == j) {
k++;
p3qipai(o);
}
}
jishu = i;
huihe = 3;
return;
}
}
break;
} else { //带二
for (int j = 1; j <= 15; j++) {
if (tot[j] == 2) {
printf("%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[j], yingshei_c[j]);
int k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o <= sum3 && p3[o] == i) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 2 && o <= sum3 && p3[o] == j) {
k++;
p3qipai(o);
}
}
jishu = i;
huihe = 3;
return;
}
}
break;
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (j <= sum3 && p3[j] == i)
p3qipai(j);
}
paizu = 4;
jishu = i;
huihe = 3;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
paizu = 5;
sum3 -= 2;
huihe = 3;
return;
}
}
printf("不出\n");
return;
}
}
printf("不出\n");
return;
} else if (paizu == 4) { //炸
if (sum1 < 9) {
for (int i = jishu + 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (p3[j] == i && j <= sum3) {
p3qipai(j);
}
}
jishu = i;
huihe = 3;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
paizu = 5;
huihe = 3;
sum3 -= 2;
return;
}
printf("不出\n");
return;
} else {
printf("不出\n");
return;
}
} else if (paizu == 5) { //双王
printf("不出\n");
return;
} else { //飞机
for (int i = jishu + 1; i < 15; i++) {
if (tot[i] >= 3 && tot[i + 1] >= 3 && (tot[i] != 4 || tot[i + 1] != 4)) {
if (fujia == 1) {
int kkk1 = 0, kkk2 = 0;
for (int j = 1; j <= 15; j++) {
if (tot[j] == 1) {
if (!kkk1) {
kkk1 = j;
} else {
kkk2 = j;
}
} else if (tot[j] == 2) {
kkk1 = kkk2 = j;
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
printf("%c%c\n", yingshei_c[kkk1], yingshei_c[kkk2]);
int k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o <= sum3 && p3[o] == i) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o <= sum3 && p3[o] == i + 1) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 1 && o <= sum3 && p3[o] == kkk1) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 1 && o <= sum3 && p3[o] == kkk2) {
k++;
p3qipai(o);
}
}
jishu = i;
huihe = 3;
return;
}
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (j < sum3 && p3[j] == i)
p3qipai(j);
}
paizu = 4;
jishu = i;
huihe = 3;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
paizu = 5;
sum3 -= 2;
huihe = 3;
return;
}
printf("不出\n");
return;
}
printf("不出\n");
return;
} else if (fujia == 2) {
int kkk1 = 0, kkk2 = 0;
for (int j = 1; j <= 15; j++) {
if (tot[j] == 2) {
if (!kkk1) {
kkk1 = j;
} else {
kkk2 = j;
}
}
if (kkk1 && kkk2) {
printf("%c%c%c%c%c%c", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
printf("%c%c%c%c\n", yingshei_c[kkk1], yingshei_c[kkk1], yingshei_c[kkk2], yingshei_c[kkk2]);
int k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o <= sum3 && p3[o] == i) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 3 && o <= sum3 && p3[o] == i + 1) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 2 && o <= sum3 && p3[o] == kkk1) {
k++;
p3qipai(o);
}
}
k = 0;
for (int o = 1; o <= sum3; o++) {
while (k < 2 && o <= sum3 && p3[o] == kkk2) {
k++;
p3qipai(o);
}
}
jishu = i;
huihe = 3;
return;
}
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (j < sum3 && p3[j] == i)
p3qipai(j);
}
paizu = 4;
jishu = i;
huihe = 3;
return;
}
}
if (tot[14] && tot[15]) {
printf("XD\n");
paizu = 5;
huihe = 3;
sum3 -= 2;
return;
}
printf("不出\n");
return;
}
printf("不出\n");
return;
} else {
printf("%c%c%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i + 1], yingshei_c[i + 1], yingshei_c[i + 1]);
int k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i) {
k++;
p3qipai(j);
}
}
k = 0;
for (int j = 1; j <= sum3; j++) {
while (k < 3 && j <= sum3 && p3[j] == i + 1) {
k++;
p3qipai(j);
}
}
jishu = i;
huihe = 3;
return;
}
break;
}
}
for (int i = 1; i <= 15; i++) {
if (tot[i] == 4) {
printf("%c%c%c%c\n", yingshei_c[i], yingshei_c[i], yingshei_c[i], yingshei_c[i]);
for (int j = 1; j <= sum3; j++) {
while (j <= sum3 && p3[j] == i)
p3qipai(j);
}
paizu = 4;
huihe = 3;
jishu = i;
return;
}
}
if (sum1 <= 6 && (dizhu == 1 || dizhu == 3) && huihe == 1) {
if (tot[14] && tot[15]) {
printf("XD\n");
sum3 -= 2;
paizu = 5;
huihe = 3;
return;
}
}
}
printf("不出\n");
return;
}
void p1qipai(int k) { //p1弃第k张牌
for (int i = k + 1; i <= sum1; i++) {
p1[i - 1] = p1[i];
}
sum1--;
return;
}
void p2qipai(int k) { //p2弃第k张牌
for (int i = k + 1; i <= sum2; i++) {
p2[i - 1] = p2[i];
}
sum2--;
return;
}
void p3qipai(int k) { //p3弃第k张牌
for (int i = k + 1; i <= sum3; i++) {
p3[i - 1] = p3[i];
}
sum3--;
return;
}
10.狼人杀
点击查看代码
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
const int daytime=0,night=1;
int day=0, during_time=daytime, player_number, my_number;
HWND hwnd=GetForegroundWindow();
const int blue=0,yellow=1,red=2,green=3,purple=4,white=5;//颜色常量
void color(int c){
switch(c){
case red:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);break;
case green:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);break;
case yellow:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);break;
case blue:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);break;
case white:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);break;
case purple:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);break;
}
}
int idx_police=-1;
void gotoxy(int x,int y){
COORD position;
position.X=x;
position.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position);
}
void init_Show_Window(){
system("mode con lines=60 cols=188");
ShowWindow(hwnd,SW_MAXIMIZE);//窗口最大化
DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_BYCOMMAND);
DrawMenuBar(GetConsoleWindow());//删除×字符
}
/*玩家类*/
const int nvwu=0,cunmin=1,yuyanjia=2,langren=3,lieren=4,shouwei=5,good=6,die=1,life=2;
class player{
public:
int type;
int die_or_life;
int how(){
return die_or_life;
}
int is_light;//是否已经公布
int killer;
};
player players[1000];
/*转换白天模式*/
void change_daytime(){
during_time=daytime;
day++;
}
/*转换黑夜模式*/
void change_night(){
during_time=night;
}
int nnvwu=0,ncunmin=0,nyuyanjia=0,nlangren=0,nlieren=0,nshouwei=0;
int idxnvwu,idxshouwei,idxyuyanjia,idxlieren,idxlangren[4]={-1,-1,-1,-1};
/*b是否在Arr中*/
bool is_include(int arr[],int b,int l){
for(int i=0;i<l;i++){
if(arr[i]==b)
return true;
}
return false;
}
/*初始化人数*/
void init_players(){
my_number=rand()%player_number;
if(player_number==12) nlangren=4;
else if(player_number>=10) nlangren=3;
else nlangren=2;
for(int i=0;i<player_number;i++)
{
players[i].die_or_life=life;
players[i].is_light=0;
players[i].type=-1;
players[i].killer=2147483647;
}
for(int i=0;i<nlangren;i++)
{
int p=rand()%player_number;
if(!is_include(idxlangren,p,4))
idxlangren[i]=p,players[p].type=langren;
else
i--;
Sleep(rand()%80+100);
}
if(player_number==12)
{
do{
idxshouwei=rand()%player_number;
}while(players[idxshouwei].type!=-1);
players[idxshouwei].type=shouwei;
}
do{
idxnvwu=rand()%player_number;
}while(players[idxnvwu].type!=-1);
players[idxnvwu].type=nvwu;
if(player_number>=10)
{
do{
idxlieren=rand()%player_number;
}while(players[idxlieren].type!=-1);
players[idxlieren].type=lieren;
}
do{
idxyuyanjia=rand()%player_number;
}while(players[idxyuyanjia].type!=-1);
players[idxyuyanjia].type=yuyanjia;
for(int i=0;i<player_number;i++)
if(players[i].type==-1)
players[i].type=cunmin,
ncunmin++;
if(players[my_number].type==langren)
{
for(int i=0;i<nlangren;i++)
{
players[idxlangren[i]].is_light=1;
}
}
players[my_number].is_light=1;
}
/*在屏幕上打印东西*/
void print(){
gotoxy(0,0);
cout<<"作者:洛谷393864";
gotoxy(90,0);
if(during_time==night)
color(red);
else
color(blue);
printf("第%d天 | ",day);
if(during_time==night) cout<<"黑夜";
else cout<<"白天";
gotoxy(0,3);
color(blue);
cout<<" 我的号位:"<<my_number+1;
for(int i=0;i<player_number;i++){
gotoxy(i*8+1,4);
if(i==idx_police) color(yellow);
else color(blue);
cout<<i+1<<"号位";
gotoxy(i*8+1,5);
if(players[i].how()==die){
color(red);
cout<<"死 亡";
}else{
color(green);
cout<<"存 活";
}
gotoxy(i*8+1,6);
color(blue);
if(players[i].is_light){
if(players[i].is_light==1){
switch(players[i].type){
case nvwu: cout<<"女 巫";break;
case yuyanjia: cout<<"\b预言家";break;
case cunmin: cout<<"村 民";break;
case langren:cout<<"狼 人"; break;
case lieren:cout<<"猎 人"; break;
case shouwei:cout<<"守 卫"; break;
}
}else{
cout<<"好人";
}
}else{
cout<<"未知";
}
}
}
/*判断是否结束,没结束返回0 好人胜利返回1 狼人胜利返回2 平局返回3*/
int is_end(){
int die_bad=0;
int die_people=0;
int die_god=0;
for(int i=0;i<player_number;i++){
if((players[i].type == nvwu || players[i].type == yuyanjia || players[i].type == shouwei)&&players[i].die_or_life==die)
die_god++;
else if(players[i].type == langren && players[i].die_or_life==die)
die_bad++;
else if(players[i].type == cunmin && players[i].die_or_life==die)
die_people++;
}
if((die_bad==die_people || die_bad==die_god)&&(die_bad>=nlangren))
return 3;
if(die_bad>=nlangren)
return 1;
if(die_people>=ncunmin||die_god>=(player_number>=10 ? 3:2))
return 2;
return 0;
}
/*游戏开始前的骚操作*/
void before_game(){
srand(time(NULL));
init_Show_Window();
color(green);
cout<<"欢迎来到狼人杀游戏\t\t\t为了更好的游戏体验,请右键点击上方↑↑,点击\"属性\",点击\"字体\"栏目,将字体修改为宋体或新宋体,将字号改为20\n作者:洛谷393864\n请勿私自转载,违者依法追究法律责任 注:10 11 12人局开设猎人 12人局开设守卫警长\n______________________\n";
cout<<"请输入玩家人数(8-12人):";
cin>>player_number;
while(player_number<8||player_number>12)
{ cout<<"请重新输入!\n"; cin>>player_number; }
system("cls");
cout<<"初始化身份中,请稍等.";
for(int i=0;i<6;i++){
for(int j=0;j<12;j++){
cout<<".";
Sleep(50);
}
cout<<"\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b";
}
system("cls");
init_players();
cout<<"我的号位:"<<my_number+1<<endl
<<"我的身份:";
switch(players[my_number].type){
case nvwu: cout<<"女巫\n";break;
case yuyanjia: cout<<"预言家\n";break;
case cunmin: cout<<"村民\n";break;
case langren:cout<<"狼人\n";break;
case lieren:cout<<"猎人\n"; break;
case shouwei:cout<<"守卫\n";break;
}
change_daytime();
system("pause");
system("cls");
cout<<"游戏加载中.";int ppppp=rand()%3+2;
for(int i=0;i<ppppp;i++){
for(int j=0;j<6;j++){
cout<<".";
Sleep(rand()%100+150);
}
cout<<"\b\b\b\b\b\b \b\b\b\b\b\b";
}
print();
}
/*每一天开始前的操作*/
void something_before_everyday(){
change_night();
system("cls");
print();
gotoxy(0,7);
cout<<"________________________";
gotoxy(0,8);
color(white);
cout<<"天黑~请闭眼~~~\n";
}
/*守卫操作*/
int shouweishou=0;
int ShouWei(){
color(blue);
cout<<"守卫~请睁眼~~\n";
Sleep(1500);
cout<<"你要守护的是?\n";
if(players[my_number].type==shouwei&&players[my_number].die_or_life == life){
cin>>shouweishou;
while(!(shouweishou>=1&&shouweishou<=player_number&&players[shouweishou-1].die_or_life == life)){
cout<<"请重新输入!\n";
cin>>shouweishou;
}
cout<<"你今晚要守护的是"<<shouweishou<<"号\n";
Sleep(1500);
shouweishou--;
}else{
if(players[idxshouwei].die_or_life == life){
shouweishou=rand()%10;
while(!(shouweishou>=1&&shouweishou<=player_number&&players[shouweishou-1].die_or_life == life)){
shouweishou=rand()%10;
}
}
}
Sleep(2000);
cout<<"守卫请闭眼"<<endl<<endl;
return shouweishou;
}
/*狼人操作*/
int LangRen(){
int langrensha=-1;
color(red);
cout<<"狼人~请睁眼~~~\n";
Sleep(1500);
cout<<"你们今晚要杀~谁~~??\n";
if(players[my_number].type==langren&&players[my_number].die_or_life == life){
cin>>langrensha;
while(!(langrensha>=1&&langrensha<=player_number&&players[langrensha-1].die_or_life==life)){
cout<<"请重新输入!\n";
cin>>langrensha;
}
cout<<"你们今晚要杀的是"<<langrensha--<<"号\n";
Sleep(3500);
}else{
while(langrensha==-1 || players[langrensha].die_or_life == die || players[langrensha].type==langren){
langrensha=rand()%player_number;
}
Sleep(3000);
}
cout<<"狼人请~闭眼~~\n\n";
return langrensha;
}
/*女巫操作*/
int nvwujiu=0,nvwudu=0,is_nvwujiu=0,is_nvwudu=0;
int NvWu(int langrensha){
color(purple);
cout<<"女巫~~请睁眼~~\n";
Sleep(2000);
if(players[my_number].type==nvwu&&players[my_number].die_or_life == life){
if(is_nvwujiu)
cout<<"你已经用过解药\n",Sleep(1500);
else
{
cout<<"今晚"<<langrensha+1<<"号死了,你想用解药吗?(1想 / 2不想)\n";
int is_nvwujie=0;
cin>>is_nvwujie;
while(is_nvwujie!=1&&is_nvwujie!=2){
cout<<"请重新输入\n";
cin>>is_nvwujie;
}
if(is_nvwujie==1) {
Sleep(1000);
cout<<"已经解救"<<langrensha+1<<"号\n";
nvwujiu=langrensha;
}
is_nvwujiu=1;
}
Sleep(1500);
if(::is_nvwudu) cout<<"你已经用过解药\n",Sleep(1500);
else
{
cout<<"你想用毒药吗?(1想 / 2不想)\n";
Sleep(1500);
int is_nvwudu=0;
cin>>is_nvwudu;
while(is_nvwudu!=1&&is_nvwudu!=2){
cout<<"请重新输入\n";
cin>>is_nvwudu;
}
if(is_nvwudu==1){
Sleep(1500);
cout<<"你想毒谁?\n";
cin>>nvwudu;
while(!(nvwudu>=1&&nvwudu<=player_number&&players[nvwudu].die_or_life==life)){
cout<<"请重新输入\n";
cin>>nvwudu;
}
nvwudu--;
Sleep(1500);
cout<<"已经毒死了"<<nvwudu+1<<"号\n";
}
::is_nvwudu=1;
}
}else{
if(players[idxnvwu].die_or_life == life){
if(!is_nvwujiu)
{
int is_jiu=rand()%8;
if(is_jiu==0){
nvwujiu=langrensha;
is_nvwujiu=1;
}
}
if(!is_nvwudu)
{
int is_du=rand()%4;
if(is_du==0){
int num=rand()%player_number;
nvwudu=num;
is_nvwudu=1;
}
}
}
}
cout<<"女巫~请闭眼~~\n\n";
return nvwujiu*10000+nvwudu;//传回两个变量,“加密”操作
}
int yuyanjiabixutoupiao=-1;
/*预言家操作*/
void YuYanJia(){
color(green);
cout<<"预言家~请睁眼~~\n";
Sleep(2000);
if(players[my_number].type==yuyanjia&&players[my_number].die_or_life == life){
cout<<"请问你想查验谁的身份\n";
int p;
cin>>p;
while(!(p>=1&&p<=player_number)){
cout<<"请重新输入!\n";
cin>>p;
}
Sleep(2000);
cout<<p<<"号的身份是——";
Sleep(1000);
if(players[p-1].type == langren){
cout<<"狼人\n";
players[p-1].is_light = 1;
}else{
cout<<"好人\n";
players[p-1].is_light = 2;
}
}else{
int p=-1;
while(p==-1||players[p].die_or_life==die||p==idxlieren)
p=rand()%player_number;
if(players[p].type==langren)//锁定目标!
{
yuyanjiabixutoupiao=p;
}
}
cout<<"预言家~~请闭眼~~\n";
}
/*黑夜操作*/
int LANGRENSHA=-1,NVWUDU=-1,NVWUJIU=-1,SHOUWEISHOU=-1;
void Night(){
LANGRENSHA=-1,NVWUDU=-1,NVWUJIU=-1,SHOUWEISHOU=-1;
//如果有12人局,添加守卫
if(player_number==12){
SHOUWEISHOU=ShouWei();
Sleep(2000);
}
/*狼人部分*/
LANGRENSHA=LangRen();
Sleep(3500);
/*女巫部分*/
int nvwu=NvWu(LANGRENSHA);
NVWUDU=nvwu%10+nvwu/10%10;
NVWUJIU=nvwu/10000%10+nvwu/100000%10;
Sleep(3000);
/*预言家部分*/
YuYanJia();
Sleep(2000);
}
/*猎人操作*/
void Lieren(){
int lierendai=-1;
cout<<idxlieren+1<<"号是猎人\n";
players[idxlieren].is_light = 1;
Sleep(1000);
if(idxlieren==my_number){
cout<<"你想带走几号?\n";
cin>>lierendai;
while(lierendai<1||lierendai>player_number||players[lierendai].die_or_life==die){
cout<<"请重新输入!\n";
cin>>lierendai;
}
lierendai--;
}else{
lierendai=rand()%player_number;
while(players[lierendai].die_or_life == die){
lierendai=rand()%player_number;
}
}
Sleep(2000);
cout<<"猎人选择带走"<<lierendai+1<<"号\n";
Sleep(2000);
players[lierendai].die_or_life = die;
}
void police_die();
/*判断谁死了*/
void panduansiwang(){
system("cls");
print();
gotoxy(0,7);
cout<<"________________________\n";
Sleep(3000);
color(white);
cout<<"天亮了\n";
Sleep(2000);
gotoxy(0,9);
cout<<"昨晚";
bool is_die[15]={false},is_die_lieren=false,flag=false;
for(int i=0;i<player_number;i++)
{
if(players[i].die_or_life==life)
{
if(i==LANGRENSHA||i==NVWUDU) {
if(players[i].type==lieren) is_die_lieren=true;
players[i].killer= (i==LANGRENSHA ? langren:nvwu);
players[i].die_or_life=die;
is_die[i]=true;
}
if(i==SHOUWEISHOU||i==NVWUJIU) {
if(players[i].type==lieren) is_die_lieren=false;
players[i].killer=-1;
players[i].die_or_life=life;
is_die[i]=false;
}
}
}
bool is_police_die=false;
for(int i=0;i<player_number;i++)
{
if(is_die[i])
{
if(flag) cout<<"和"<<i+1<<"号";
else cout<<i+1<<"号",flag=true;
if(i==idx_police)
is_police_die=true;
}
}
if(flag) cout<<"死了\n";
else cout<<"是平安夜\n";
if(is_die_lieren) Lieren();
if(is_police_die) police_die();
}
/*选警长*/
void choose_police(){
system("cls");
print();
color(blue);
gotoxy(0,7);
cout<<"________________________\n";
color(yellow);
cout<<"下面开始选举警长,各位不能选举自己~\n";
int tong[100]={0},cannot[100],must[100]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
memset(cannot,-1,sizeof(cannot));
CHOOSE:
color(yellow);
Sleep(1500);
for(int i=0;i<player_number;i++)
{
if(players[i].die_or_life==life&&!is_include(cannot,i,player_number))
{
if(i==my_number)
{
cout<<"你要选举几号?\n";
int n;
cin>>n;
while(n<1||n>player_number||n==i+1||players[n-1].die_or_life==die||!is_include(must,n-1,player_number))
{
cout<<"请重新输入!\n";
cin>>n;
}
cout<<i+1<<"号选举"<<n--<<"号\n";
tong[n]++;
}
else
{
int n=rand()%player_number;
while(n==i||players[n].die_or_life==die||!is_include(must,n,player_number))
n=rand()%player_number;
cout<<i+1<<"号选举"<<n+1<<"号\n";
tong[n]++;
}
Sleep(1500);
}
}
int idx_max=-1,maxn=-1,len=0;
for(int i=0;i<player_number;i++)
if(maxn<tong[i])
{
maxn=tong[i];
idx_max=i;
}
int maxn_arr[15]={0};
for(int i=0;i<player_number;i++)
{
if(tong[i]==maxn)
{
maxn_arr[len++]=i;
}
}
color(blue);
if(len>1)
{
for(int i=0;i<len;i++)
{
if(i==len-1)
{
cout<<maxn_arr[i]+1<<"号平票\n";
}
else
{
cout<<maxn_arr[i]+1<<"号,";
}
}
for(int i=0;i<len;i++)
cannot[i]=maxn_arr[i];
for(int i=0;i<player_number;i++)
{
if(is_include(cannot,i,len))
must[i]=i;
else
must[i]=-1;
}
color(white);
goto CHOOSE;
}
cout<<"恭喜"<<idx_max+1<<"号当选警长\n";
Sleep(3000);
idx_police=idx_max;
return;
}
/*投票*/
int toupiao(){
int tong[100]={0},cannot[100]={},must[100]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
memset(cannot,-1,sizeof(cannot));
gotoxy(0,7);
color(blue);
cout<<"________________________\n";
color(white);
cout<<"下面进入投票环节\n";
memset(tong,0,sizeof(tong));
Sleep(2000);
TOUPIAO:
for(int i=0;i<player_number;i++){
if(players[i].die_or_life == life&&!is_include(cannot,i,player_number)){
if(i==my_number){
color(white);
cout<<"你要投几号?\n";
int n;
cin>>n;
while(!(n>=1&&n<=player_number&&is_include(must,n-1,player_number))){
cout<<"请重新输入!\n";
cin>>n;
}
Sleep(2000);
cout<<setw(2)<<my_number+1<<"号投了"<<setw(2)<<n<<"号";
if(my_number==n-1) color(red),cout<<"快来看!这有个疯子投自己!";
if(i==idx_police) color(yellow),cout<<"(警长)\n"; else cout<<"\n";
if(i==idx_police) tong[n-1]++;
tong[n-1]++;
}else{
color(white);
int t=-1;
while(t==-1 || players[t].die_or_life == die || t==i || !is_include(must,t,player_number)){
if(i==idxyuyanjia&&yuyanjiabixutoupiao!=-1)
{
t=yuyanjiabixutoupiao;
yuyanjiabixutoupiao=-1;
continue;
}
t=rand()%player_number;
if(is_include(idxlangren,i,nlangren))
{
if(players[t].type == langren)
t=-1;
}
}
cout<<setw(2)<<i+1<<"号"<<"投了"<<setw(2)<<t+1<<"号";
if(i==idx_police) cout<<"(警长2票)\n"; else cout<<"\n";
if(i==idx_police) tong[t]++;
tong[t]++;
}
Sleep(rand()%1000+1000);
}
}
int idx_max=-1,maxn=-1,len=0;
for(int i=0;i<player_number;i++)
if(maxn<tong[i])
{
maxn=tong[i];
idx_max=i;
}
int maxn_arr[15]={0};
for(int i=0;i<player_number;i++)
{
if(tong[i]==maxn)
{
maxn_arr[len++]=i;
}
}
color(blue);
if(len>1)
{
for(int i=0;i<len;i++)
{
if(i==len-1)
{
cout<<maxn_arr[i]+1<<"号平票\n";
}
else
{
cout<<maxn_arr[i]+1<<"号,";
}
}
for(int i=0;i<len;i++)
cannot[i]=maxn_arr[i];
for(int i=0;i<player_number;i++)
{
if(is_include(cannot,i,len))
must[i]=i;
else
must[i]=-1;
}
color(white);
goto TOUPIAO;
}
cout<<idx_max+1<<"号"<<"出局\n";
Sleep(4000);
players[idx_max].die_or_life = die;
players[idx_max].killer = good;
return idx_max;
}
/*警长死亡*/
void police_die(){
color(yellow);
int type;
if(idx_police==my_number)
{
Sleep(1550);
cout<<"你是想撕毁警徽还是移交警徽?(撕毁输入1,移交输入2)";
cin>>type;
while(!(type==1||type==2))
{
cout<<"请重新输入!\n";
cin>>type;
}
}
else{
type=rand()%3+1;
}
if(type==1)
{
cout<<"警长选择撕毁警徽\n";
Sleep(1000);
idx_police=-1;
}
else
{
int lucky=-1;
while(lucky==-1||players[lucky].die_or_life==die)
lucky=rand()%player_number;
cout<<"警长选择把警徽移交给"<<lucky+1<<"号\n";
Sleep(1500);
idx_police=lucky;
}
}
/*故事的最后*/
void the_end(){
system("cls");
switch(is_end()){
case 1:cout<<"好人胜利\n\n"; break;
case 2:cout<<"狼人胜利\n\n"; break;
case 3:cout<<"本局平局\n\n"; break;
}
for(int i=0;i<player_number;i++){
cout<<i+1<<"号位:\t";
switch(players[i].type){
case nvwu: cout<<"女巫\t";break;
case yuyanjia: cout<<"预言家\t";break;
case cunmin: cout<<"村民\t";break;
case langren:cout<<"狼人\t";break;
case lieren:cout<<"猎人\t"; break;
case shouwei:cout<<"守卫\t";break;
}
cout<<"最终";
switch(players[i].killer){
case nvwu:cout<<"被女巫毒死\n"; break;
case langren:cout<<"被狼人杀死\n"; break;
case good:cout<<"被投票出局\n"; break;
case lieren:cout<<"被猎人带走\n";break;
default :cout<<"存活\n";
}
cout<<endl;
}
}
/*主函数*/
int main(){
int wheel=0;
before_game();
while(!is_end()){
//黑夜准备
something_before_everyday();
Sleep(1500);
//黑夜部分
Night(); //进入黑夜!
change_daytime(); //换天
//天亮了
panduansiwang();//判断谁死了
Sleep(2000);
system("cls");
print();
if(is_end()) break;
//选警长
if(!wheel&&player_number==12)
{
choose_police();
system("cls");
print();
}
//投票环节
int idx_max=toupiao();//票数最多的人
if(idx_max==idx_police){
police_die();
}
if(players[idx_max].type==lieren){//启动猎人程序
Lieren();
if(is_end()) break;
}
system("cls");
print();
wheel++;
}
the_end();
system("pause");
return 0;
}