跳到正文

个人记录

模拟名字竞技场

zhazha_855384约 9 分钟
原文
文章信息与版本

文章信息

发布
2021年7月9日
收录
2025年12月12日
更新
2026年11月15日
篇幅
约 9 分钟

版本

  1. v2当前
  2. v1

名字竞技场是一个游戏

http://deepmess.com/namerena/ 是它的网址

玩法:在文本框中输入几个名字点击开始就可以进入战斗,之后不需要任何操作,战斗的过程和结果由输入的名字直接决定。每次输入相同的名字都会得到相同结果,即使改变名字的顺序结果也不会变。

这是一个山寨版名字竞技场代码,由我编写,由于我太蒟了,所以目前只支持2人战斗。

以后也许会支持多人虽然作为一名鸽子这似乎不大可能。

持续更新虽然有时我会咕的你以为停更了。

话不多说,上c++代码

C++
//3.3.7

#include <bits/stdc++.h>

using namespace std;

int blood[2]/* = {10000,10000}*/;
int attack[2]/* = {200,200}*/;
long long ttime[2] /*= {130000090,150000000}*/;
int overAtk[2]/* = {3,11}*/;
int curse[2];
int ifCursed[2] = {0,0};
int huibi[2];
int heal[2];
int maxbl[2];
int stru[2];
int defence[2]/* = {2, 19}*/;
int xixue[2]/* = {17, 29}*/;
int magic[2];
string a,b;

void atk(int atker,int defer){
	int seed = clock();
	srand(seed);
	int atkb = rand() % 50 + attack[atker] - 25;
	if(atkb < 0){
		atkb == 0;
	}
	seed = clock();
	srand(seed);
	if(rand() % 203 <= huibi[defer]){
		atkb = 0;
		cout << "[DODGE]";
		return;
	}
	if(ifCursed[defer]){
		atkb *= 3;
		atkb /= 2;
		ifCursed[defer]--;
	}
	if(rand() % 273 <= overAtk[atker]){
		atkb *= 3;
		atkb /= 2;
		cout << "[OVERATTACK]";
	}

	/*if(rand() % defence[defer] == 0){
		blood[atker] += atkb / 2;
		cout << "[XIXUE]:" << (char)(atker + 97) << ":" << blood[atker] ;
	}
	if(rand() % defence[defer] == 0){
		atkb /= 2;
		cout << "[DEFENCE]";
	}*/
	if(rand() % 397 <= heal[atker] && blood[atker] != maxbl[atker]){
		atkb *= 2;
		cout << "[HEAL] ";
		blood[atker] = min(maxbl[atker], blood[atker] + atkb);
		cout <<(char)(atker + 'a') << ":" << blood[atker] << " ";
		return;
	}
	if(rand() % 379 <= curse[atker]){
		atkb /= 2;
		ifCursed[defer] += 2;
		cout << "[CURSED]";
	}

	blood[defer] -= atkb;
}
bool ifDead(int sb){
	if(blood[sb] < 1){
		int seed = clock();
		srand(seed);
		if(rand()%293<=stru[sb]){
			blood[sb] = rand() % 29 + 30;
			cout << (char)(sb + 'a') << "[STRUGGLED] " << (char)(sb + 'a') << ":" << blood[sb];
			return false;
		}
		return true;
	}
	return false;
}

int main(){
	getline(cin,a);
	getline(cin,b);
	int as = a.size();
	int bs = b.size();
	blood[0] = abs(a[0] + a[1%as] + a[2%as])%180+180;
	blood[1] = abs(b[0] + b[1%bs] + b[2%bs])%180+180;
	maxbl[0] = blood[0];
	maxbl[1] = blood[1];
	attack[0] = abs(a[3%as]*a[4%as])%65 +35;
	attack[1] = abs(b[3%bs]*b[4%bs])%65 +35;
	overAtk[0] = abs(a[5%as]*a[6%as]*a[7%as] - a[8%as])%65+35;
	overAtk[1] = abs(b[5%bs]*b[6%bs]*b[7%bs] - b[8%bs])%65+35;
	heal[0] = abs(a[5%as]*a[6%as]-a[8%as]*a[7%as])%65+35;
	heal[1] = abs(b[5%bs]*b[6%bs]-b[8%bs]*b[7%bs])%65+35;
	stru[0] = abs(a[2%as]*a[5%as]/a[3%as]+a[9%as])%65+35;
	stru[1] = abs(b[2%bs]*b[5%bs]/b[3%bs]+b[9%bs])%65+35;
	magic[0] = (overAtk[0] + heal[0] + stru[0])/3;
	magic[1] = (overAtk[1] + heal[1] + stru[1])/3;
	huibi[0] = abs(a[7%as]*(a[8%as]+4)*a[9%as] - a[2%as])%65+35;
	huibi[1] = abs(b[7%bs]*(b[8%bs] + 4) * b[9 % bs] - b[2%bs])%65+35;
	curse[0] = abs(a[2%as]*(a[8%as]-4)*a[3%as] + a[2%as])%65+35;
	curse[1] = abs(b[2%bs]*(b[8%bs] - 4) * b[3 % bs] + b[2%bs])%65+35;
	int tta = abs(a[5%as]+a[6%as]*a[7%as])%65+35;
	int ttb = abs(b[5%bs]+b[6%bs]*b[7%bs])%65+35;
	if(a == "LM@!"){
		tta = 300;
	}
	if(b == "LM@!"){
		ttb = 300;
	}
	ttime[0] = 10000000000 / tta;
	ttime[1] = 10000000000 / ttb;
	int awei = blood[0] / 3 + attack[0]+tta + overAtk[0] + huibi[0];
	int bwei = blood[1] / 3 + attack[1]+ttb + overAtk[1] + huibi[1];
	cout << "a:HP " << blood[0] << "  ATK " << attack[0] << "  SPE " << tta << "  MAG " << magic[0] << "  DGE " << huibi[0];
	if(awei >= 392){
		if(awei >= 422){
			if(awei >= 452){
				cout << "[>o<]";
			}else{
				cout << "[^v^]";
			}
		}else{
			cout << "[^_^]";
		}
	}
	if(awei < 262){
		cout << "[-]";
	}
	cout << endl;
	cout << "b:HP " << blood[1] << "  ATK " << attack[1] << "  SPE " << ttb << "  MAG " << magic[1] << "  DGE " << huibi[1];
	if(bwei >= 400){
		if(bwei >= 430){
			if(bwei >= 460){
				cout << "[>o<]";
			}else{
				cout << "[^v^]";
			}
		}else{
			cout << "[^_^]";
		}
	}
	if(bwei < 250){
		cout << "[-]";
	}
	cout <<endl;

	for(long long i = 1;;i++){
		if(i % ttime[0] == 0){
			atk(0, 1);
			srand(time(0));
			cout << "a attack b, b:" << blood[1] << endl;
			if(ifDead(1)){
				cout << "b dead,a win";
				return 0;
			}
		}
		if(i % ttime[1] == 0){
			atk(1, 0);
			cout << "b attack a, a:" << blood[0] << endl;
			if(ifDead(0)){
				cout << "a dead,b win";
				return 0;
			}
		}
	}
}
原文
抓取于
  1. Zhengsiwei

    太强了