跳到正文

休闲·娱乐

双人竞技场

koukou约 23 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年6月5日
篇幅
约 23 分钟
获赞
2

版本

  1. v1当前

一个以前乱搞的东西,现在不想写了

C++
#include<bits/stdc++.h>
#include<Windows.h>
using namespace std;
string a, b;
int chuzhao, x, shei, huibi/*回避*/, xdz;
int t[2][100];//对应:体力 攻击 防御 速度  灼烧(5回合自动消失) 铁壁状态 冰冻状态 防御增加值 中毒状态(5回合) 中毒伤害 狂暴状态 狂暴攻击加成 反伤状态 反伤比例
			 //满级:400  100  100  1000
string jineng[]= {"火球术", "雷击术", "治愈术", "铁壁", "生命之轮", "冰冻术", "毒雾", "狂暴", "反伤甲", "闪电风暴"};
void work()
{
	// 灼烧状态处理
	if(t[0][4] != 0)
	{
		cout << a << "受到灼烧伤害,体力-5!\n";
		Sleep(1000);
		t[0][0] -= 5;
		t[0][4]++;
		if(t[0][4] >= 5)
		{
			cout << a << "的灼烧状态解除了!\n";
			Sleep(1000);
			t[0][4] = 0;
		}
	}
	if(t[1][4] != 0)
	{
		cout << b << "受到灼烧伤害,体力-5!\n";
		Sleep(1000);
		t[1][0] -= 5;
		t[1][4]++;
		if(t[1][4] >= 5)
		{
			cout << b << "的灼烧状态解除了!\n";
			Sleep(1000);
			t[1][4] = 0;
		}
	}

	// 中毒状态处理
	if(t[0][8] != 0)
	{
		cout << a << "受到中毒伤害,体力-" << t[0][9] << "!\n";
		Sleep(1000);
		t[0][0] -= t[0][9];
		t[0][8]++;
		if(t[0][8] >= 5)
		{
			cout << a << "的毒雾状态解除了!\n";
			Sleep(1000);
			t[0][8] = 0;
			t[0][9] = 0;
		}
	}
	if(t[1][8] != 0)
	{
		cout << b << "受到中毒伤害,体力-" << t[1][9] << "!\n";
		Sleep(1000);
		t[1][0] -= t[1][9];
		t[1][8]++;
		if(t[1][8] >= 5)
		{
			cout << b << "的毒雾状态解除了!\n";
			Sleep(1000);
			t[1][8] = 0;
			t[1][9] = 0;
		}
	}

	// 铁壁状态处理
	if(t[0][5] > 0)
	{
		t[0][5]--;
		if(t[0][5] == 0)
		{
			cout << a << "的铁壁状态结束了,防御力恢复!\n";
			t[0][2] -= t[0][7]; // 恢复防御力
			t[0][7] = 0;
			Sleep(1000);
		}
	}
	if(t[1][5] > 0)
	{
		t[1][5]--;
		if(t[1][5] == 0)
		{
			cout << b << "的铁壁状态结束了,防御力恢复!\n";
			t[1][2] -= t[1][7];
			t[1][7] = 0;
			Sleep(1000);
		}
	}

	// 狂暴状态处理
	if(t[0][10] > 0)
	{
		t[0][10]--;
		if(t[0][10] == 0)
		{
			cout << a << "的狂暴状态结束了,攻击力恢复!\n";
			t[0][1] -= t[0][11];
			t[0][11] = 0;
			Sleep(1000);
		}
	}
	if(t[1][10] > 0)
	{
		t[1][10]--;
		if(t[1][10] == 0)
		{
			cout << b << "的狂暴状态结束了,攻击力恢复!\n";
			t[1][1] -= t[1][11];
			t[1][11] = 0;
			Sleep(1000);
		}
	}

	// 反伤状态处理
	if(t[0][12] > 0)
	{
		t[0][12]--;
		if(t[0][12] == 0)
		{
			cout << a << "的反伤甲效果消失了!\n";
			Sleep(1000);
		}
	}
	if(t[1][12] > 0)
	{
		t[1][12]--;
		if(t[1][12] == 0)
		{
			cout << b << "的反伤甲效果消失了!\n";
			Sleep(1000);
		}
	}

	// 冰冻状态处理
	if(t[0][6] > 0)
	{
		cout << a << "处于冰冻状态,无法行动!\n";
		Sleep(1000);
		t[0][6] = 0;
		return;
	}
	if(t[1][6] > 0)
	{
		cout << b << "处于冰冻状态,无法行动!\n";
		Sleep(1000);
		t[1][6] = 0;
		return;
	}

	shei = rand() % 2;
	chuzhao = rand() % 3;
	if(chuzhao <= 1)
	{
		x = rand() % 121 + 1, huibi = rand() % 1000;
		if(shei == 0)
		{
			if(huibi >= t[1][3])
			{
				cout << a << "攻击" << b << "造成了" << x << "点伤害!\n";
				t[1][0] -= x;

				// 反伤效果
				if(t[1][12] > 0)
				{
					int reflect = x * t[1][13] / 100;
					cout << b << "的反伤甲生效," << a << "受到" << reflect << "点反弹伤害!\n";
					t[0][0] -= reflect;
					Sleep(1000);
				}
			}
			else
			{
				cout << a << "攻击," << b << "回避了攻击!\n";
			}
			Sleep(1000);
		}
		else if(shei == 1)
		{
			if(huibi >= t[0][3])
			{
				cout << b << "攻击" << a << "造成了" << x << "点伤害!\n";
				t[0][0] -= x;

				// 反伤效果
				if(t[0][12] > 0)
				{
					int reflect = x * t[0][13] / 100;
					cout << a << "的反伤甲生效," << b << "受到" << reflect << "点反弹伤害!\n";
					t[1][0] -= reflect;
					Sleep(1000);
				}
			}
			else
			{
				cout << b << "攻击," << a << "回避了攻击!\n";
			}
			Sleep(1000);
		}
	}
	else
	{
		xdz = rand() % 10; // 现在有10种技能
		if(xdz == 0) // 火球术
		{
			x = rand() % 101 + 50, huibi = rand() % 1000;
			if(shei == 0)
			{
				if(huibi >= t[1][3])
				{
					cout << a << "使用火球术,造成了" << x << "点伤害!\n";
					Sleep(1000);
					cout << b << "进入灼烧状态!\n";
					t[1][0] -= x;
					t[1][4] = 1;
				}
				else
				{
					cout << a << "使用火球术," << b << "回避了攻击!\n";
				}
				Sleep(1000);
			}
			else if(shei == 1)
			{
				if(huibi >= t[0][3])
				{
					cout << b << "使用火球术,造成了" << x << "点伤害!\n";
					Sleep(1000);
					cout << a << "进入灼烧状态!\n";
					t[0][0] -= x;
					t[0][4] = 1;
				}
				else
				{
					cout << b << "使用火球术," << a << "回避了攻击!\n";
				}
				Sleep(1000);
			}
		}
		else if(xdz == 1) // 雷击术
		{
			if(shei == 0)
			{
				int tmp = 0;
				cout << a << "使用雷击术!\n";
				Sleep(1000);
				while(1)
				{
					x = rand() % 70 + 1, huibi = rand() % 1000;
					if(huibi >= t[1][3] && tmp < 5)
					{
						cout << b << "受到了" << x << "点伤害!\n";
						t[1][0] -= x;
					}
					else if(huibi < t[1][3] || tmp >= 5)
					{
						cout << b << "回避了攻击!\n";
						break;
					}
					tmp++;
					Sleep(1000);
				}
			}
			else if(shei == 1)
			{
				int tmp = 0;
				cout << b << "使用雷击术!\n";
				Sleep(1000);
				while(1)
				{
					x = rand() % 70 + 1, huibi = rand() % 1000;
					if(huibi >= t[0][3] && tmp < 5)
					{
						cout << a << "受到了" << x << "点伤害!\n";
						t[0][0] -= x;
					}
					else if(huibi < t[0][3] || tmp >= 5)
					{
						cout << a << "回避了攻击!\n";
						break;
					}
					tmp++;
					Sleep(1000);
				}
			}
		}
		else if(xdz == 2) // 治愈术
		{
			x = rand() % 50 + 1;
			if(shei == 0)
			{
				cout << a << "使用治愈术!\n";
				Sleep(1000);
				cout << "恢复" << x << "点血!\n";
				Sleep(1000);
				t[0][0] += x;
				if(t[0][0] > 400) t[0][0] = 400;
			}
			else if(shei == 1)
			{
				cout << b << "使用治愈术!\n";
				Sleep(1000);
				cout << "恢复" << x << "点血!\n";
				Sleep(1000);
				t[1][0] += x;
				if(t[1][0] > 400) t[1][0] = 400;
			}
		}
		else if(xdz == 3) // 铁壁
		{
			if(shei == 0)
			{
				if(t[0][5] == 0)
				{
					cout << a << "使用铁壁!\n";
					Sleep(1000);
					int add_def = rand() % 30 + 20; // 随机增加20-50防御
					t[0][2] += add_def;
					t[0][7] = add_def; // 记录增加的防御值
					t[0][5] = 3; // 持续3回合
					cout << a << "防御力提升" << add_def << "点,持续3回合!\n";
				}
				else
				{
					cout << a << "的铁壁效果还在持续中!\n";
					work(); // 重新选择技能
					return;
				}
			}
			else
			{
				if(t[1][5] == 0)
				{
					cout << b << "使用铁壁!\n";
					Sleep(1000);
					int add_def = rand() % 30 + 20;
					t[1][2] += add_def;
					t[1][7] = add_def;
					t[1][5] = 3;
					cout << b << "防御力提升" << add_def << "点,持续3回合!\n";
				}
				else
				{
					cout << b << "的铁壁效果还在持续中!\n";
					work();
					return;
				}
			}
			Sleep(1000);
		}
		else if(xdz == 4) // 生命之轮
		{
			x = rand() % 101 + 100; // 恢复100-200点生命
			if(shei == 0)
			{
				cout << a << "使用生命之轮!\n";
				Sleep(1000);
				cout << "恢复" << x << "点血!\n";
				Sleep(1000);
				t[0][0] += x;
				if(t[0][0] > 400) t[0][0] = 400;
			}
			else
			{
				cout << b << "使用生命之轮!\n";
				Sleep(1000);
				cout << "恢复" << x << "点血!\n";
				Sleep(1000);
				t[1][0] += x;
				if(t[1][0] > 400) t[1][0] = 400;
			}
		}
		else if(xdz == 5) // 冰冻术
		{
			x = rand() % 81 + 70; // 70-150伤害
			huibi = rand() % 1000;
			if(shei == 0)
			{
				if(huibi >= t[1][3])
				{
					cout << a << "使用冰冻术,造成了" << x << "点伤害!\n";
					t[1][0] -= x;
					if(rand() % 100 < 70) // 70%概率冰冻
					{
						cout << b << "被冰冻了!\n";
						t[1][6] = 1; // 冰冻1回合
					}
				}
				else
				{
					cout << a << "使用冰冻术," << b << "回避了攻击!\n";
				}
			}
			else
			{
				if(huibi >= t[0][3])
				{
					cout << b << "使用冰冻术,造成了" << x << "点伤害!\n";
					t[0][0] -= x;
					if(rand() % 100 < 70)
					{
						cout << a << "被冰冻了!\n";
						t[0][6] = 1;
					}
				}
				else
				{
					cout << b << "使用冰冻术," << a << "回避了攻击!\n";
				}
			}
			Sleep(1000);
		}
		else if(xdz == 6) // 毒雾
		{
			x = rand() % 60 + 40; // 40-100伤害
			int poison = rand() % 15 + 10; // 10-25中毒伤害
			huibi = rand() % 1000;
			if(shei == 0)
			{
				if(huibi >= t[1][3])
				{
					cout << a << "使用毒雾,造成了" << x << "点伤害!\n";
					t[1][0] -= x;
					cout << b << "中毒了,每回合将受到" << poison << "点伤害!\n";
					t[1][8] = 1;
					t[1][9] = poison;
				}
				else
				{
					cout << a << "使用毒雾," << b << "回避了攻击!\n";
				}
			}
			else
			{
				if(huibi >= t[0][3])
				{
					cout << b << "使用毒雾,造成了" << x << "点伤害!\n";
					t[0][0] -= x;
					cout << a << "中毒了,每回合将受到" << poison << "点伤害!\n";
					t[0][8] = 1;
					t[0][9] = poison;
				}
				else
				{
					cout << b << "使用毒雾," << a << "回避了攻击!\n";
				}
			}
			Sleep(1000);
		}
		else if(xdz == 7) // 狂暴
		{
			if(shei == 0)
			{
				if(t[0][10] == 0)
				{
					cout << a << "进入狂暴状态!\n";
					Sleep(1000);
					int add_atk = rand() % 30 + 20; // 20-50攻击加成
					t[0][1] += add_atk;
					t[0][11] = add_atk;
					t[0][10] = 3; // 持续3回合
					cout << a << "攻击力提升" << add_atk << "点,持续3回合!\n";
				}
				else
				{
					cout << a << "已经在狂暴状态中了!\n";
					work();
					return;
				}
			}
			else
			{
				if(t[1][10] == 0)
				{
					cout << b << "进入狂暴状态!\n";
					Sleep(1000);
					int add_atk = rand() % 30 + 20;
					t[1][1] += add_atk;
					t[1][11] = add_atk;
					t[1][10] = 3;
					cout << b << "攻击力提升" << add_atk << "点,持续3回合!\n";
				}
				else
				{
					cout << b << "已经在狂暴状态中了!\n";
					work();
					return;
				}
			}
			Sleep(1000);
		}
		else if(xdz == 8) // 反伤甲
		{
			int reflect_percent = rand() % 30 + 20; // 20-50%反伤比例
			if(shei == 0)
			{
				cout << a << "使用反伤甲!\n";
				Sleep(1000);
				t[0][12] = 3; // 持续3回合
				t[0][13] = reflect_percent;
				cout << "接下来3回合," << a << "将反弹" << reflect_percent << "%的伤害!\n";
			}
			else
			{
				cout << b << "使用反伤甲!\n";
				Sleep(1000);
				t[1][12] = 3;
				t[1][13] = reflect_percent;
				cout << "接下来3回合," << b << "将反弹" << reflect_percent << "%的伤害!\n";
			}
			Sleep(1000);
		}
		else if(xdz == 9) // 闪电风暴
		{
			cout << (shei == 0 ? a : b) << "召唤闪电风暴!\n";
			Sleep(1000);

			int strikes = rand() % 4 + 3; // 3-6次闪电
			for(int i = 0; i < strikes; i++)
			{
				int target = rand() % 2; // 随机目标
				x = rand() % 51 + 30; // 30-80伤害

				if(target == 0)
				{
					huibi = rand() % 1000;
					if(huibi >= t[0][3])
					{
						cout << a << "被闪电击中,受到" << x << "点伤害!\n";
						t[0][0] -= x;
					}
					else
					{
						cout << a << "躲过了闪电!\n";
					}
				}
				else
				{
					huibi = rand() % 1000;
					if(huibi >= t[1][3])
					{
						cout << b << "被闪电击中,受到" << x << "点伤害!\n";
						t[1][0] -= x;
					}
					else
					{
						cout << b << "躲过了闪电!\n";
					}
				}
				Sleep(800);
			}
			Sleep(1000);
		}
	}
}
int main()
{
	system("mode con lines=25 cols=60");
	while(1)
	{
		cout << "|--------------双人竞技场--------------|\n";
		cout << "|---------------150粉特辑--------------|\n";
		srand(time(NULL));
		cout << "请输入玩家1和玩家2的名字:\n";
		cin >> a >> b;
		// 初始化所有状态
		for(int i = 0; i < 2; i++) {
			for(int j = 4; j < 15; j++) {
				t[i][j] = 0;
			}
		}

		if(a == "koukou")
		{
			t[0][0] = 400, t[0][1] = 100, t[0][2] = 100, t[0][3] = 1000;
			t[1][0] = rand() % 351 + 50, t[1][1] = rand() % 100 + 1, t[1][2] = rand() % 100 + 1, t[1][3] = rand() % 300 + 1;
		}
		else if(b == "koukou")
		{
			t[1][0] = 400, t[1][1] = 100, t[1][2] = 100, t[1][3] = 1000;
			t[0][0] = rand() % 351 + 50, t[0][1] = rand() % 100 + 1, t[0][2] = rand() % 100 + 1, t[0][3] = rand() % 300 + 1;
		}
		else
		{
			t[0][0] = rand() % 351 + 50, t[0][1] = rand() % 100 + 1, t[0][2] = rand() % 100 + 1, t[0][3] = rand() % 300 + 1;
			t[1][0] = rand() % 351 + 50, t[1][1] = rand() % 100 + 1, t[1][2] = rand() % 100 + 1, t[1][3] = rand() % 300 + 1;
		}
		cout << a << "\n体力:" << t[0][0] << " 攻击:" << t[0][1] << " 防御:" << t[0][2] << " 速度:" << t[0][3] << endl;
		cout << b << "\n体力:" << t[1][0] << " 攻击:" << t[1][1] << " 防御:" << t[1][2] << " 速度:" << t[1][3] << endl;
		system("pause");
		system("cls");
		while(t[0][0] > 0 && t[1][0] > 0)
		{
			work();
			cout << a << "还有" << t[0][0] << "点血\n";
			cout << b << "还有" << t[1][0] << "点血\n\n";
			Sleep(1500);
	//		system("cls");
		}
		if(t[0][0] > 0)
		{
			cout << a << " Win!!!\n";
		}
		else
		{
			cout << b << " Win!!!\n";
		}
		system("pause");
		system("cls");
	}
	return 0;
}
原文