跳到正文

闲话

武器大战

note_dance约 7 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年7月22日
篇幅
约 7 分钟

版本

  1. v1当前

呵呵,武器大战在2024/11/5 20:03被做出来,
而我的生日是2014/12/2 11:57
不废话了,上代码

C++
#include <bits/stdc++.h>
#include <windows.h>
#define slp Sleep(1000)
#define cls system("cls")
using namespace std;

struct wuqi {
	string name;
	int m_1shanghai;
	int m_2shanghai;
	int lq;
	friend ostream &operator<<(ostream &os, wuqi wq);
};

vector<int> ran(int mod, int l) {
	srand(time(NULL));
	vector<int> v;
	for (int i = 1; i <= l; i++)
		v.push_back(rand() % mod);
	return v;
}

ostream &operator<<(ostream &os, wuqi wq) {
	cout << "名称:" << wq.name << " 对自己的";
	if (wq.m_1shanghai < 0)
		cout << "加血量";
	else
		cout << "扣血量";
	cout << "为:";
	if (wq.m_1shanghai < 0)
		cout << 0 - wq.m_1shanghai;
	else
		cout << wq.m_1shanghai;
	cout << " 对敌方的";
	if (wq.m_2shanghai < 0)
		cout << "加血量";
	else
		cout << "扣血量";
	cout << "为:";
	if (wq.m_2shanghai < 0)
		cout << 0 - wq.m_2shanghai;
	else
		cout << wq.m_2shanghai;
	cout << " 冷却时间为:" << wq.lq;
	return os;
}

wuqi wq[100] = {{"0", 0, 0, 0}, {"大刀", 0, 10, 3}, {"激光炮", 2, 15, 5}, {"枪", 1, 15, 10}};
wuqi wq2[100] = {{"0", 0, 0, 0}, {"食品", -5, 0, 2}, {"加血台", -10, -1, 5}, {"加血炮", -10, 1, 15}};
wuqi me[2], com[2];
int myxue = 150, comxue = 150, myl1 = 100, myl2 = 100, col1 = 100, col2 = 100;

void zhan() {
	while (myxue > 0 && comxue > 0) {
go1:
		cout << myxue << '/' << comxue << endl;
		cout << "你想干什么?1.普攻(拳头,伤害为1) 2.攻击 3.防御";
		int tm;
		cin >> tm;
		if (tm == 1)
			cout << "你使用普攻", comxue--;
		else if (tm == 2) {
			if (myl1 <= me[0].lq) {
				cout << "还没冷却好,请重选";
				slp;
				cls;
				goto go1;
			}
			cout << "你使用攻击";
			myxue -= me[0].m_1shanghai;
			comxue -= me[0].m_2shanghai;
			myl1 = 0;
		} else if (tm == 3) {
			if (myl2 <= me[1].lq) {
				cout << "还没冷却好,请重选";
				cls;
				goto go1;
			}
			cout << "你使用防御";
			myxue -= me[1].m_1shanghai;
			comxue -= me[1].m_2shanghai;
			myl2 = 0;
		}
		cout << '\n';
go2:
		tm = ran(3, 2)[0] + 1;
		if (tm == 1)
			cout << "敌方使用普攻", myxue--;
		else if (tm == 2) {
			if (col1 <= com[0].lq)
				goto go2;
			cout << "敌方使用攻击";
			myxue -= com[0].m_2shanghai;
			comxue -= com[0].m_1shanghai;
			col1 = 0;
		} else if (tm == 3) {
			if (col2 <= com[1].lq)
				goto go2;
			cout << "敌方使用防御";
			myxue -= com[0].m_2shanghai;
			comxue -= com[0].m_1shanghai;
			col2 = 0;
		}
		slp;
		slp;
		slp;
		cls;
		myl1++;
		myl2++;
		col1++;
		col2++;
	}
	if (myxue <= 0 && comxue > 0)
		cout << "你死了";
	if (comxue <= 0 && myxue > 0)
		cout << "电脑死了";
	else
		cout << "你们同归于尽";
	exit(0);
}

int main() {
	cout << "_____________________\n";
	cout << "| 稀 硝 酸  出 版 社 |\n";
	cout << "|       大           |\n";
	cout << "|____________________|";
	slp;
	cls;
	cout << "_____________________\n";
	cout << "| 稀 硝 酸  出 版 社 |\n";
	cout << "|       大  战       |\n";
	cout << "|____________________|";
	slp;
	slp;
	cls;
	cout << "作者:胡铄岩\n";
	slp;
	cout << "洛谷名字:hushuoyan\n";
	slp;
	cout << "UID:1411725\n";
	slp;
	slp;
	cls;
	cout << "警告:本品著作权稀硝酸出版社,若要转载,请注明。";
	slp;
	cout << "Tips:能用攻击就攻击,不用攻击用防御,都不能用用普攻!";
	slp;
	cls;
	cout << "攻击技能:\n";
	slp;
	for (int i = 1; i <= 3; i++) {
		cout << i << ':' << wq[i] << endl;
		slp;
	}
	cout << "防御技能:\n";
	slp;
	for (int i = 1; i <= 3; i++) {
		cout << i << ':' << wq2[i] << endl;
		slp;
	}
	cout << "请输入两个数字:";
	string s;
	cin >> s;
	int a = s[0] - '0';
	int b = s[1] - '0';
	me[0] = wq[a];
	me[1] = wq2[b];
	vector<int> v = ran(3, 2);
	cout << "敌方选择的是";
	com[0] = wq[v[0] + 1];
	com[1] = wq2[v[1] + 1];
	cout << wq[v[0] + 1].name << "和" << wq2[v[1] + 1].name;
	cout << "\n开始战斗!";
	slp;
	cls;
	zhan();
}
原文