职业战争1.0

今天我又来写程序了。
项目就不截图了,因电脑的问题😭😭
源代码:

#include<iostream>
#include<cstdlib>
#include<ctime>
#include<cstring>
#include<string>
#include<windows.h>
using namespace std;
int i, H[3], S[3], K[3], p = 1, Y, C;
string P[3];
bool game = 1;
void a(int i) {
	for (; i; i--);
}
void help() {
	cout << "杀手:\nHP:100\nSP:5\nkill:3\n";
	cout << "医生:\nHP:75\nSP:7\nkill:2\n";
	cout << "法师:\nHP:144\nSP:3\nkill:1\n";
	cin >> i;
}
void killer() {
	P[p] += "杀手";
	H[p] = 100;
	S[p] = 5;
	K[p] = 3;
}
void doctor() {
	P[p] += "医生";
	H[p] = 75;
	S[p] = 7;
	K[p] = 2;
}
void engineer() {
	P[p] += "法师";
	H[p] = 144;
	S[p] = 3;
	K[p] = 1;
}
void e(int j) {
	if (j == 2 && S[Y] >= 2) {
		int w = rand() % 2;
		if (Y == 1) cout << "你使用技能\n";
		else cout << "电脑使用技能\n";
		K[Y] += w;
		cout << "攻击力(kill)+" << w << endl;
		w = rand() % 5 - 1;
		w = int(1.2*(K[Y] + w));
		H[C] -= w;
		if (H[C] <= 0) game = 0;
		if (Y == 1) cout << "你杀了电脑 ";
		else cout << "你被电脑杀了 ";
		cout << w;
		if (Y == 1) cout << endl;
		S[Y] -= 2;
	}
	if (j == 3 && S[Y] >= 5) {
		int w = rand() % 10;
		if (Y == 1) cout << "你使用大杀特杀\n";
		else cout << "电脑使用大杀特杀\n";
		K[Y] += w;
		cout << "攻击力(kill)+" << w << endl;
		w = rand() % 5 - 1;
		w = int(1.2*(K[Y] + w));
		H[C] -= w;
		if (H[C] <= 0) game = 0;
		if (Y == 1) cout << "你杀了电脑 ";
		else cout << "你被电脑杀了 ";
		cout << w;
		if (Y == 1) cout << endl;
		S[Y] -= 5;
	}
}
void k(int j) {
	if (j == 2 && S[Y] >= 2) {
		if (Y == 1) cout << "YOU 使用技能\n";
		else cout << "The computer 使用技能\n";
		int w = rand() % 4 + 1;
		H[C] -= int(1.5*K[Y] + w);
		if (H[C] <= 0) game = 0;
		if (Y == 1) cout << "你杀了电脑 ";
		else cout << "你被电脑杀了 ";
		cout << int(1.5*K[Y] + w);
		cout << endl;
		S[Y] -= 2;
	}
	if (j == 3 && S[Y] >= 5) {
		int w = rand() % 10;
		if (Y == 1) cout << "你使用大杀特杀\n";
		else cout << "电脑使用大杀特杀\n";
		K[Y] += w;
		cout << "攻击力(kill)+" << w << endl;
		w = rand() % 5 - 1;
		w = int(1.2*(K[Y] + w));
		H[C] -= w;
		if (H[C] <= 0) game = 0;
		if (Y == 1) cout << "你杀了电脑 ";
		else cout << "你被电脑杀了 ";
		cout << w;
		if (Y == 1) cout << endl;
		S[Y] -= 5;
	}
}
void d(int j) {
	if (j == 2 && S[Y] >= 2) {
		if (Y == 1) cout << "YOU 使用技能\n";
		else cout << "The computer 使用技能\n";
		int w = rand() % 5;
		H[Y] += K[Y] + w;
		if (Y == 1) cout << "YOU HP+";
		else cout << "The computer HP+";
		cout << K[Y] + w;
		if (Y == 1) cout << endl;
		S[Y] -= 2;
	}
	if (j == 3 && S[Y] >= 5) {
		int w = rand() % 10;
		if (Y == 1) cout << "你使用大杀特杀\n";
		else cout << "电脑使用大杀特杀\n";
		K[Y] += w;
		cout << "攻击力(kill)+" << w << endl;
		w = rand() % 5 - 1;
		w = int(1.2*(K[Y] + w));
		H[C] -= w;
		if (H[C] <= 0) game = 0;
		if (Y == 1) cout << "你杀了电脑 ";
		else cout << "你被电脑杀了 ";
		cout << w;
		if (Y == 1) cout << endl;
		S[Y] -= 5;
	}
}
void play() {
	system("cls");
	cout << "Game start!!!!!!!!!!!!!!!!";
	Sleep(500);
	system("cls");
	int r = 1, j;
	// bool game=1;
	while (game) {
		Y = 1;
		C = 2;
		cout << "Round " << r << "\n";
		Sleep(500);
		cout << "The 电脑 HP:" << H[2] << " SP:" << S[2] << " kill:" << K[2] << "\t" << P[2];
		cout << "\n\n\n\nYour HP:" << H[1] << " SP:" << S[1] << " kill:" << K[1] << "\t" << P[1];
		Sleep(500);
		cout << "\nYou choose:\n1.攻击(1SP)\n2.技能(2SP)\n3.大杀特杀(5SP)\n4.蓄力(+1~3SP)\n5.修炼(+0~2kill)\n6.挂机(0SP)\n";
		cin >> j;
		if (j == 1 && S[Y]>0) {
			int w = rand() % 5 - 1;
			S[Y]--;
			H[C] -= K[Y] + w;
			if (H[C] <= 0) game = 0;
			cout << "You kill the computer" << K[Y] + w << endl;
		}
		else {
			if (j == 4) {
				int w = rand() % 3 + 1;
				S[Y] += w;
				cout << "YOU SP+" << w << endl;
			}
			else {
				if (j == 5) {
					int w = rand() % 3;
					K[Y] += w;
					cout << "YOU kill+" << w << endl;
				}
				else {
					if (P[Y] == "杀手") k(j);
					if (P[Y] == "医生") d(j);
					if (P[Y] == "法师") e(j);
				}
			}
		}
		if (game) {
			j = rand() % 6 + 1;
			C = 1;
			Y = 2;
			while (j != 1 && j != 2 && j != 4 && j != 5) j = rand() % 6 + 1;
			if (j == 1 && S[2]>1) {
				int w = rand() % 5 - 1;
				S[2]--;
				H[1] -= K[2] + w;
				if (H[1] <= 0) game = 0;
				cout << "你被电脑杀了" << K[2] + w;
			}
			else {
				if (j == 4) {
					int w = rand() % 3 + 1;
					S[2] += w;
					cout << "The computer SP+" << w;
				}
				else {
					if (j == 5) {
						int w = rand() % 3;
						K[2] += w;
						cout << "The computer kill+" << w;
					}
					else {
						if (P[Y] == "杀手") k(j);
						if (P[Y] == "医生") d(j);
						if (P[Y] == "法师") e(j);
					}
				}
			}
			if (game) Sleep(1000);
		}
		r++;
		system("cls");
	}
}
int main() {
	srand((unsigned)time(NULL));
	cout << "Welcome to my game!!!!!!!!!!!!\n";
	Sleep(500);
	system("cls");
	cout << "Please choose:\n1.killer\n2.doctor\n3.engineer\n4.help\n";
	cin >> i;
	if (i == 4) help();
	cout << "You choose ";
	if (i == 1) killer();
	if (i == 2) doctor();
	if (i == 3) engineer();
	cout << P[p] << endl;
	i = rand() % 3 + 1;
	p++;
	cout << "The computer chooses ";
	if (i == 1) killer();
	if (i == 2) doctor();
	if (i == 3) engineer();
	cout << P[p] << endl;
	system("pause");
	play();
	if (H[1] <= 0) cout << "YOU LOSE~~~~~~~~~~~~~~~~~";
	else cout << "YOU WIN!!!!!!!!!!!!!!!!!!!";



	getchar();
	getchar();
	return 0;
}

一句制作不易,勿喷点赞啊!
(我还是个学生党)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值