改编游戏,看原作者请点 这个
#include <bits/stdc++.h> // 好渴鹅原创python版机房大乱斗 C++解析版 不保证输出完全一样
#include <conio.h>//有狼殉星改编过的加入了新技能
#include <windows.h>
using namespace std;
int minsh=10000000;
struct Player { // 玩家数
string name;
int mhp, hp, atk, br,zdsj,tbsj,jysj;bool zd,xx,ss;
};
int dainum;
int maxs;
int n; // 玩家数
vector<Player> player; // 玩家列表
string haokee; // 逝世记录 https://www.luogu.com.cn/user/661980
Player make_player(string name, int hp, int atk, int br) {
Player player;
player.name = name;
player.hp = hp;
player.mhp = hp;
player.atk = atk;
player.br = br;
player.zd=0;
player.xx=0;
player.zdsj=0;
player.tbsj=0;
player.ss=0;
player.jysj=0;
return player;
}
bool checkFile() { // 判断路径
ifstream in("选手.txt");
if(!in.is_open())
return false;
return true;
}
void readPlayer() { // 读入选手
ifstream in("选手.txt");
string name;
int hp, atk, br;
while(in >> name >> hp >> atk >> br) {
n++;
maxs = max(maxs, int(name.size()));
minsh=min(minsh,atk);
if(!hp)hp=rand()%2000+1;
if(!atk)atk=rand()%500+1;
if(!br)br=rand()%500+1;
player.push_back(make_player(name, hp, atk, br)); // 创建选手
}
}
bool init() { // 初始化
if(checkFile() == false) return false;
readPlayer();
return true;
}
int hasPlayer() { // 是否还有两个以上的选手存在
unordered_map<string, int> m;
int count = 0;
for(int i = 0; i < player.size(); i++)
if(player[i].hp > 0 and !m[player[i].name]) count++, m[player[i].name] = 1;
return count;
}
string gameOver() { // 结束游戏,如果同归于尽就是“煞笔”
string winner = "作者这个煞笔";
for(int i = 0; i < player.size(); i++)
if(player[i].hp > 0) {
winner = player[i].name;
break;
}
cout << "获胜者是:" << winner << endl;
return "获胜者是:" + winner;
}
void play() { // 游玩
srand(time(0)); // 这里和python版不同,C++版需要播放随机种子
ofstream out("游玩结果.txt");
while(1) {
if(hasPlayer() <= 1) {
out << gameOver() << endl;
out << "死亡名单:\n" + haokee << endl;
return;
}
Sleep(200);
int sum = 0;
int p1 = rand() % n;
int p2 = rand() % n;
while(player[p1].hp <= 0)p1 = rand() % n;
while(player[p1].name == player[p2].name or player[p2].hp <= 0)p2 = rand() % n;
int chicken = rand() % 50 + 1,sccz=rand()*rand()%40+1;
if(player[p1].jysj>0)
{
player[p1].jysj--;
cout<<player[p1].name<<"你谷管理员提醒:禁言时间内禁止攻击\n";
out<<player[p1].name<<"你谷管理员提醒:禁言时间内禁止攻击\n";
goto GG;
}
else if(chicken == 1) {
}else if(chicken==11&&player[p1].name=="张角")
{
Sleep(500);
cout << player[p1].name << " 使用了九p1=15; 天玄雷!" << endl;
out << player[p1].name << " 使用了九天玄雷!" << endl;
system("color 84");
chicken=11;
Sleep(1000);
cout<<"苍天已死,\n";Sleep(1000);cout<<"黄天当立.\n";Sleep(1000);cout<<"岁在甲子,\n";Sleep(1000);cout<<"天下大吉!\n";Sleep(1000);cout<<"坤坤助我,\n";Sleep(1000);cout<<"一统江湖!\n";Sleep(1000);
for(int i=0;i<3;i++)
{
int r=rand()%player[p1].atk+ceil(double(player[p1].atk)/2.0)*10;
cout << player[p1].name << " 九天玄雷!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
player[p2].hp-=r;
player[p2].xx=0;
sum+=r;
out << player[p1].name << " 九天玄雷!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
Sleep(50);
system("color F0");
Sleep(100);
system("color 30");
Sleep(50);
system("color 07");
}
if(player[p2].hp<=0)
{
dainum++;
cout << player[p2].name << " 没有血了!" << endl;
out << player[p2].name << " 没有血了!" << endl;
haokee += player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++) haokee += ' ';
haokee += "致命一击:" + player[p1].name + '\n';
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p1].name.size(); i++)haokee+=' ';
haokee+="死因:五雷轰顶\n";
goto GG;
}
}
else if(chicken==11)
{
cout << player[p1].name << " 使用了雷击术!" << endl;
out << player[p1].name << " 使用了雷击术!" << endl;
for(int i=0;i<3;i++)
{
int r=rand()%player[p1].atk+ceil(double(player[p1].atk)/2.0);
cout << player[p1].name << " 雷击术!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
player[p2].hp-=r;
player[p2].xx=0;
sum+=r;
out << player[p1].name << " 雷击术!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
Sleep(50);
system("color F0");
Sleep(100);
system("color 30");
Sleep(50);
system("color 07");
}
if(player[p2].hp<=0)
{
dainum++;
cout << player[p2].name << " 没有血了!" << endl;
out << player[p2].name << " 没有血了!" << endl;
haokee += player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++) haokee += ' ';
haokee += "致命一击:" + player[p1].name + '\n';
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p1].name.size(); i++)haokee+=' ';
haokee+="死因:渡劫失败\n";
goto GG;
}
}
else if(chicken==12)
{
cout << player[p1].name << " 使用了地震术!" << endl;
out << player[p1].name << " 使用了地震术!" << endl;
for(int i=0;i<min(5,hasPlayer());i++)
{
int r=(rand()%player[p1].atk+5)/2,p3=rand()%n;
while(player[p3].name == player[p1].name||player[p3].hp<=0)p3 = rand() % n;
cout << player[p1].name << " 地震术!对 " << player[p3].name << " 造成了 " << r << " 的伤害!" << endl;
player[p3].hp-=r;
player[p3].xx=0;
out << player[p1].name << " 地震术!对 " << player[p3].name << " 造成了 " << r << " 的伤害!" << endl;
if(player[p3].tbsj>0)
{
player[p3].tbsj-=0;
cout<<player[p3].name<<"使用了铁壁,伤害减为1!\n";
out<<player[p3].name<<"使用了铁壁,伤害减为1!\n";
player[p3].hp+=(sum-1);
}
if(player[p3].hp<=0) {
dainum++;
cout << player[p3].name << " 没有血了!" << endl;
out << player[p3].name << " 没有血了!" << endl;
haokee += player[p3].name;
for(int i = 0; i <= maxs - player[p3].name.size(); i++) haokee += ' ';
haokee += " 致命一击:" + player[p3].name + '\t'+"死因:地震时没躲\n";
}
else {
cout << player[p3].name << " 还剩下 " << player[p3].hp << " 的血量!" << endl;
out << player[p3].name << " 还剩下 " << player[p3].hp << " 的血量!" << endl;
}
Sleep(50);
Sleep(100);
Sleep(50);
}
goto GG;
}
else if(chicken==13)
{
cout << player[p1].name << " 使用了火球术!" << endl;
out << player[p1].name << " 使用了火球术!" << endl;
int r;
if(player[p1].xx)
{
cout<<"背刺!\n";
out<<"背刺!\n";
player[p1].xx=0;
r=(rand()%player[p2].atk+ceil(double(player[p1].atk)/2.0))*6;
}
else {
r=(rand()%player[p2].atk+ceil(double(player[p1].atk)/2.0))*3;
sum +=r;
player[p2].hp-=r;
player[p2].xx=0;
cout << player[p1].name << " 打出了火球术!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
out << player[p1].name << " 打出了火球术!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
}
if(player[p2].hp<=0)
{
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++)haokee+=' ';
haokee+="死因:被火球烤的酥脆\n";
goto GG;
}
Sleep(50);
Sleep(100);
Sleep(50);
}
else if(chicken==14)
{
cout << player[p1].name << " 使用诅咒了!" << endl;
out << player[p1].name << " 使用诅咒了!" << endl;
int r=min((int)(player[p2].mhp*(double)((rand()%100+30)/100.0)),player[p2].mhp);
sum +=0;
player[p2].xx=0;
player[p2].hp-=r;
cout << player[p1].name << " 打出诅咒了!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
out << player[p1].name << " 打出诅咒了!对 " << player[p2].name << " 造成了 " << r << " 的伤害!" << endl;
Sleep(50);
if(player[p2].hp<=0)
{
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++)haokee+=' ';
haokee+="死因:积怨太深\n";
goto GG;
}
Sleep(100);
Sleep(50);
}
else if(chicken==15&&player[p1].hp<player[p2].hp)
{
cout << player[p1].name << " 使用生命之轮了!" << endl;
out << player[p1].name << " 使用生命之轮了!" << endl;
cout << player[p1].name << "与"<< player[p2].name<<" 生命值互换了!\n"<<"现在"<<player[p1].name<<"血量为"<<player[p2].hp<<" "<<player[p2].name<<"血量为"<<player[p1].hp<<endl;
out << player[p1].name << "与"<< player[p2].name<<" 生命值互换了!\n"<<"现在"<<player[p1].name<<"血量为"<<player[p2].hp<<" "<<player[p2].name<<"血量为"<<player[p1].hp<<endl;
swap(player[p1].hp,player[p2].hp);
Sleep(50);
Sleep(100);
Sleep(50);
goto GG;
}
else if(chicken==16)
{
cout << player[p1].name << " 使用投毒了!" << endl;
out << player[p1].name << " 使用投毒了!" << endl;
player[p2].zdsj=3;
if(player[p1].xx){
cout<<"背刺!\n";
out<<"背刺!\n";
player[p2].hp-=player[p1].atk;
player[p2].xx=0;
cout << player[p1].name << " 打出了投毒!对 " << player[p2].name << " 造成了 " << player[p1].atk << " 的伤害!" << endl<<player[p2].name<<"中毒了\n";
out << player[p1].name << " 打出了投毒!对 " << player[p2].name << " 造成了 " << player[p1].atk << " 的伤害!" << endl<<player[p2].name<<"中毒了\n";
}
else
{
player[p2].hp-=player[p1].atk/2;
player[p2].xx=0;
cout << player[p1].name << " 打出了投毒!对 " << player[p2].name << " 造成了 " << player[p1].atk/2 << " 的伤害!" << endl<<player[p2].name<<"中毒了\n";
out << player[p1].name << " 打出了投毒!对 " << player[p2].name << " 造成了 " << player[p1].atk/2<< " 的伤害!" << endl<<player[p2].name<<"中毒了\n";
}
Sleep(50);
Sleep(100);
Sleep(50);
}
else if(chicken==17&&player[p1].xx==0)
{
cout << player[p1].name << " 使用潜行了!" << endl;
out << player[p1].name << " 使用潜行了!" << endl;
player[p1].xx=1;
Sleep(50);
Sleep(100);
Sleep(50);
goto GG;
}
else if((chicken==18||(chicken>=40&&chicken<44))&&player[p1].name=="幽幽子")
{
cout << player[p1].name << " 感觉肚子饿了!" << endl;
out << player[p1].name << " 感觉肚子饿!" << endl;
cout<<"吃掉了"<<player[p2].name<<endl;
out<<"吃掉了"<<player[p2].name<<endl;
player[p1].hp+=player[p2].hp;
player[p2].hp=0;
player[p1].zdsj=0;
if(player[p2].hp<=0)
{
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++)haokee+=' ';
haokee+="致命一击:Yuyuko Sama\t死因:被幽幽子大人当早餐吃了\n";
}
Sleep(50);
Sleep(100);
Sleep(50);
dainum++;
goto GG;
}
else if(chicken==18||(chicken>=40&&chicken<44))
{
cout << player[p1].name << " 使用吸血攻击了!" << endl;
out << player[p1].name << " 使用吸血攻击了!" << endl;
player[p2].zdsj=3;
if(player[p1].xx){
cout<<"背刺!\n";
out<<"背刺!\n";
player[p1].xx=0;
player[p2].hp-=player[p1].atk*2;
player[p2].xx=0;
sum+=player[p1].atk*2;
cout << player[p1].name << " 打出了吸血攻击!对 " << player[p2].name << " 造成了 " << player[p1].atk*2 << " 的伤害!\n恢复了"<<player[p1].atk<<"滴血\n";
out << player[p1].name << " 打出了吸血攻击!对 " << player[p2].name << " 造成了 " << player[p1].atk*2 << " 的伤害!\n恢复了" << player[p1].atk<<"滴血\n";
}
else
{
player[p2].hp-=ceil(double(player[p1].atk)/2.0);
player[p2].xx=0;
sum+=player[p1].atk;
cout << player[p1].name << " 打出了吸血攻击!对 " << player[p2].name << " 造成了 " << player[p1].atk << " 的伤害!\n回复了" <<ceil(double(player[p1].atk)/2.0)<<"滴血\n";
out << player[p1].name << " 打出了吸血攻击!对 " << player[p2].name << " 造成了 " << player[p1].atk<< " 的伤害!\n回复了"<<ceil(double(player[p1].atk)/2.0)<<"滴血\n";
}
Sleep(50);
Sleep(100);
Sleep(50);
}
else if(chicken==19)
{
cout << player[p1].name << " 使用自毁式攻击了!" << endl;
out << player[p1].name << " 使用自毁式攻击了!" << endl;
player[p2].zdsj=3;
if(player[p1].xx){
cout<<"背刺!\n";
out<<"背刺!\n";
player[p1].xx=0;
player[p2].hp-=player[p1].atk*10;
player[p1].hp-=player[p1].atk*3;
sum+=player[p1].atk*10;
player[p2].xx=0;
cout << player[p1].name << " 打出了自毁式攻击!对 " << player[p2].name << " 造成了 " << player[p1].atk*10 << " 的伤害!\n失去了"<<player[p1].atk*3<<"滴血\n";
out << player[p1].name << " 打出了自毁式攻击!对 " << player[p2].name << " 造成了 " << player[p1].atk*10 << " 的伤害!\n失去了" << player[p1].atk*3<<"滴血\n";
}
else
{
player[p2].hp-=player[p1].atk*5;
player[p1].hp-=player[p1].atk*3;
player[p2].xx=0;
sum+=player[p1].atk*5;
cout << player[p1].name << " 打出了自毁式攻击!对 " << player[p2].name << " 造成了 " <<player[p1].atk*5<< " 的伤害!\n失去了" <<player[p1].atk*3<<"滴血\n";
out << player[p1].name << " 打出了自毁式攻击!对 " << player[p2].name << " 造成了 " <<player[p1].atk*5<< " 的伤害!\n失去了"<<player[p1].atk*3<<"滴血\n";
}
if(player[p1].hp<=0)
{
dainum++;
cout << player[p1].name << " 没有血了!" << endl;
out << player[p1].name << " 没有血了!" << endl;
haokee+=player[p1].name;
for(int i = 0; i <= maxs - player[p1].name.size(); i++)haokee+=' ';
haokee+="死因:自残\n";
}
Sleep(50);
Sleep(100);
Sleep(50);
}
else if(chicken==20&&player[p1].hp<(double(player[p1].mhp*0.4)))
{
cout << player[p1].name << " 使用自爆了!" << endl;
out << player[p1].name << " 使用自爆了!" << endl;
player[p2].zdsj=3;
if(player[p1].xx){
cout<<"背刺!\n";
out<<"背刺!\n";
player[p1].xx=0;
player[p2].hp-=player[p1].atk*30;
player[p1].hp=0;
player[p2].xx=0;
cout << player[p1].name << " 打出了自爆!对 " << player[p2].name << " 造成了 " << player[p1].atk*30 << " 的伤害!\n";
out << player[p1].name << " 打出了自爆!对 " << player[p2].name << " 造成了 " << player[p1].atk*30 << " 的伤害!\n" ;
}
else
{
player[p2].hp-=player[p1].atk*15;
player[p1].hp=0;
player[p2].xx=0;
cout << player[p1].name << " 打出了自爆!对 " << player[p2].name << " 造成了 " <<player[p1].atk*15<< " 的伤害!\n";
out << player[p1].name << " 打出了自爆!对 " << player[p2].name << " 造成了 " <<player[p1].atk*15<< " 的伤害!\n";
}
if(player[p1].hp<=0)
{
dainum++;
cout << player[p1].name << " 没有血了!" << endl;
out << player[p1].name << " 没有血了!" << endl;
haokee+=player[p1].name;
for(int i = 0; i <= maxs - player[p1].name.size(); i++)haokee+=' ';
haokee+="死因:自爆\t炸了个稀巴烂\n";
}
Sleep(50);
Sleep(100);
Sleep(50);
}
else if(chicken==21&&player[p1].tbsj==0)
{
cout << player[p1].name << " 使用铁壁了!" << endl;
out << player[p1].name << " 使用铁壁了!" << endl;
player[p1].tbsj=4;
Sleep(50);
Sleep(100);
Sleep(50);goto GG;
}
else if(chicken==22&&sccz>=30)
{
cout << player[p1].name << " 使用禁忌·四重存在了!" << endl;
out << player[p1].name << " 使用了紧急·四重存在了!" << endl;
for(int i=0;i<4;i++)
{
n++;
player.push_back(make_player(player[p1].name, player[p1].hp, player[p1].atk, player[p1].br));
}
goto GG;
}
else if(chicken==23&&sccz>=30)
{
cout<<"上天给了" << player[p1].name << "一次机会" << endl;
out<<"上天给了" << player[p1].name << "一次机会" << endl;
player[p1].hp=player[p1].mhp;
player[p1].zdsj=0;
player[p1].mhp=player[p1].hp*2;
goto GG;
}
else if(chicken==24&&dainum>0)
{
dainum--;
while(player[p2].hp >0)p2 = rand() % n;
cout << player[p1].name << "吞噬了" << player[p2].name <<"的尸体!大大增强!"<< endl;
out << player[p1].name << "吞噬了" << player[p2].name <<"的尸体!大大增强!"<< endl;
player[p1].hp+=ceil(double(player[p2].mhp)/2.0);
player[p1].atk+=ceil(double(player[p2].atk)/2.0);
player[p1].br+=ceil(double(player[p2].br)/2.0);
goto GG;
}
else if((chicken==25 or chicken>=46)&&player[p1].name=="圣白莲")
{
int r=(rand()%(long long)(ceil(player[p1].atk/2.0))+1)*1000;
cout << player[p1].name << ":你悔改吧!\n魔神复诵!" << endl;
out << player[p1].name << ":你悔改吧!\n魔神复诵!" << endl;
for(int i=0;i<5;i++)
{
cout<<" ";
for(int j=0;j<player[p2].name.size();j++)cout<<"|";
Sleep(100);
cout<<"\n";
}
if(player[p1].xx)
{
r*=2;
player[p1].xx=0;
}
if(player[p2].ss)r*=5;
player[p2].xx=0;
player[p2].hp-=r;
sum+=r;
cout<<"对"<<player[p2].name<<"造成"<<r<<"点伤害\n";
out<<"对"<<player[p2].name<<"造成"<<r<<"点伤害\n";
player[p2].tbsj=0;
player[p1].zdsj=0;
if(player[p2].hp<=0)
{
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++)haokee+=' ';
haokee+="死因:被摩托车撞死\n";
}
goto GG;
}
else if(chicken==25 or chicken>=46)
{
int r=rand()*rand()%(long long)(ceil(player[p1].atk/2.0))+1;
cout << player[p1].name << "净化了" << player[p2].name<< endl;
out << player[p1].name << "净化了" << player[p2].name<< endl;
cout << player[p1].name << ":别浪费我的慈悲" << endl;
out << player[p1].name << ":别浪费我的慈悲" << endl;
if(player[p1].xx)
{
r*=2;
player[p1].xx=0;
}
if(player[p2].ss)r*=5;
player[p2].xx=0;
player[p2].hp-=r;
sum+=r;
cout<<r<<"点伤害\n";
out<<r<<"点伤害\n";
player[p2].tbsj=0;
player[p1].zdsj=0;
if(player[p2].hp<=0)
{
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++)haokee+=' ';
haokee+="自我飞升\n";
}
}
else if(chicken==26&&player[p1].name=="射命丸文")
{
cout<<player[p1].name<<"使用了无双风神!\n";
out<<player[p1].name<<"使用无双风神了!\n";
Sleep(500);
cout<<"灵山之上神风起!\n";
out<<"灵山之上神风起!\n";
for(int i=0;i<8;i++)
{
system("color 27");
Sleep(100);
int r=rand()*rand()%player[p1].atk+minsh;
if(player[p1].xx)
{
r*=2;
}
player[p2].hp-=r;
sum+=r;
cout<<player[p2].name<<"收到了"<<r<<"点伤害\n";
out<<player[p2].name<<"收到了"<<r<<"点伤害\n";
system("color 07");
Sleep(100);
}
player[p1].xx=0;
Sleep(100);
}
else if(chicken==26)
{
cout<<player[p1].name<<"使用了猪哥连弩!\n";
out<<player[p1].name<<"使用了猪哥连弩!\n";
int r=rand()%6+1;
while(r--)
{
cout<<"哒! ";
out<<"哒! ";
Sleep(100);
player[p2].hp-=minsh;
if(player[p1].xx){
player[p2].hp-=minsh;
sum+=minsh;
}
sum+=minsh;
}
player[p1].xx=0;
cout<<"艹,没子弹了!\n";
out<<"艹,没子弹了!\n";
Sleep(100);
}
else if(chicken==27&&player[p1].name=="chen_zhe"&&player[p2].jysj==0)
{
cout<<player[p1].name<<"使用了暴政·禁言!\n"<<player[p2].name<<"被禁言了\n";
out<<player[p1].name<<"使用了暴政·禁言!\n"<<player[p2].name<<"被禁言了\n";
player[p2].jysj=4;
goto GG;
}
else if(chicken==27&&player[p1].name=="魂魄妖梦")
{
cout<<player[p1].name<<":在这把剑面前,就没有什么斩不断的!\n包括你,"<<player[p2].name<<"\n六根清净斩!\n";
out<<player[p1].name<<":在这把剑面前,就没有什么斩不断的!\n包括你,"<<player[p2].name<<"\n六根清净斩!\n";
player[p2].hp-=player[p1].atk*10;
sum+=0;
Sleep(50);
system("color F0");
Sleep(100);
system("color 30");
Sleep(50);
system("color 07");
Sleep(500);
}
else if(chicken <= 2 and dainum >= 1) {
dainum--;
int p3 = rand() % n;
while(player[p3].hp > 0)
p3 = rand() % n;
cout << player[p1].name << " 使用了禁术!复活了 " << player[p3].name << "将TA变为丧尸" << " !" << endl;
out << player[p1].name << " 使用了禁术!复活了 " << player[p3].name << "将TA变为丧尸"<< " !" << endl;
Sleep(50);
Sleep(100);
Sleep(50);
player[p3].name = player[p1].name;
player[p3].hp = player[p3].mhp;
player[p3].ss=1;
goto GG;
}
else if(chicken == 2) { // 真伤
if(player[p1].xx)
{
cout<<"背刺!\n";
out<<"背刺!\n";
player[p1].xx=0;
player[p2].hp -= 6 * player[p1].atk;
cout << player[p1].name << " 打出了真伤!对 " << player[p2].name << " 造成了 " << 6 * player[p1].atk << " 的伤害!" << endl;
out << player[p1].name << " 打出了真伤!对 " << player[p2].name << " 造成了 " << 6 * player[p1].atk << " 的伤害!" << endl;
sum += 6 * player[p1].atk;
Sleep(50);
Sleep(100);
Sleep(50);
}
else
{
player[p2].hp -= 3 * player[p1].atk;
cout << player[p1].name << " 打出了真伤!对 " << player[p2].name << " 造成了 " << 3 * player[p1].atk << " 的伤害!" << endl;
out << player[p1].name << " 打出了真伤!对 " << player[p2].name << " 造成了 " << 3 * player[p1].atk << " 的伤害!" << endl;
sum += 3 * player[p1].atk;
Sleep(50);
Sleep(100);
Sleep(50);
}
}
else if(3 <= chicken and chicken <= 6) { // 暴击
if(player[p1].xx)
{
cout<<"背刺!\n";
out<<"背刺!\n";
player[p1].xx=0;
player[p2].hp -= 4 * player[p1].atk;
cout << player[p1].name << " 打出了暴击!对 " << player[p2].name << " 造成了 " << 4 * player[p1].atk << " 的伤害!" << endl;
out << player[p1].name << " 打出了暴击!对 " << player[p2].name << " 造成了 " << 4 * player[p1].atk << " 的伤害!" << endl;
sum += 2 * player[p1].atk;
Sleep(50);
Sleep(100);
Sleep(50);
}
else
{
player[p2].hp -= 2 * player[p1].atk;
cout << player[p1].name << " 打出了暴击!对 " << player[p2].name << " 造成了 " << 2 * player[p1].atk << " 的伤害!" << endl;
out << player[p1].name << " 打出了暴击!对 " << player[p2].name << " 造成了 " << 2 * player[p1].atk << " 的伤害!" << endl;
sum += 2 * player[p1].atk;
Sleep(50);
Sleep(100);
Sleep(50);
}
}
else if(chicken == 7 or chicken == 8) {// 没打出暴击可能免疫
cout << player[p2].name << " 免疫了 " << player[p1].name << " 的伤害!" << endl;
out << player[p2].name << " 免疫了 " << player[p1].name << " 的伤害!" << endl;
Sleep(50);
Sleep(100);
Sleep(50);
}
else { // 普通伤害
if(player[p1].xx)
{
cout<<"背刺!\n";
out<<"背刺!\n";
player[p2].hp -= player[p1].atk*2;
cout << player[p1].name << " 对 " << player[p2].name << " 造成了 " << player[p1].atk*2 << " 的伤害!" << endl;
out << player[p1].name << " 对 " << player[p2].name << " 造成了 " << player[p1].atk*2 << " 的伤害!" << endl;
sum += player[p1].atk*2;
}
else{
player[p2].hp -= player[p1].atk;
cout << player[p1].name << " 对 " << player[p2].name << " 造成了 " << player[p1].atk << " 的伤害!" << endl;
out << player[p1].name << " 对 " << player[p2].name << " 造成了 " << player[p1].atk<< " 的伤害!" << endl;
sum += player[p1].atk;
}
Sleep(50);
Sleep(100);
Sleep(50);
}
chicken = rand() % 20 + 1;
if(chicken <= 4) { // 反甲
cout << player[p2].name << " 打出了反甲!对 " << player[p1].name << " 造成了 " << sum << " 的伤害!" << endl;
out << player[p2].name << " 打出了反甲!对 " << player[p1].name << " 造成了 " << sum << " 的伤害!" << endl;
Sleep(50);
Sleep(100);
Sleep(50);
player[p1].hp -= sum;
if(player[p2].tbsj>0)
{
player[p2].tbsj--;
cout<<player[p2].name<<"使用了铁壁,伤害减为1!\n";
out<<player[p2].name<<"使用了铁壁,伤害减为1!\n";
player[p2].hp+=(sum-1);
}
player[p1].hp = max(0, player[p1].hp);
if(!player[p1].hp) {
dainum++;
haokee+=player[p1].name;
for(int i = 0; i <= maxs - player[p1].name.size(); i++)haokee+=' ';
haokee+="死因:自作自受\n";
cout << player[p1].name << " 被反死了!" << endl;
out << player[p1].name << " 被反死了!" << endl;
haokee += player[p1].name;
for(int i = 0; i <= maxs - player[p1].name.size(); i++) haokee += ' ';
haokee += " 致命一击:" + player[p2].name + '\n';
}
else {
cout << player[p1].name << " 还剩 " << player[p1].hp << " 的血!" << endl;
out << player[p1].name << " 还剩 " << player[p1].hp << " 的血!" << endl;
}
}
else if(chicken <= 7) {
cout << player[p2].name << " 使用回血术回了 " << min(player[p2].mhp - player[p2].hp, player[p2].br) << " 的血量!" << endl;
out << player[p2].name << " 使用回血术回了 " << min(player[p2].mhp - player[p2].hp, player[p2].br) << " 的血量!" << endl;
Sleep(50);
Sleep(100);
Sleep(50);
player[p2].hp = min(player[p2].mhp, player[p2].hp + player[p2].br);
}
else if(chicken <= 10 and hasPlayer() >= 3) {
int p3 = rand() % n;
while(player[p3].name == player[p2].name||player[p3].hp<=0)
p3 = rand() % n;
cout << player[p2].name << " 使用了伤害转移!把所有伤害转移给了 " << player[p3].name << "!" << endl;
out << player[p2].name << " 使用了伤害转移!把所有伤害转移给了 " << player[p3].name << "!" << endl;
Sleep(50);
Sleep(100);
Sleep(50);
player[p2].hp += sum;
player[p3].hp -= sum;
if(player[p3].tbsj>0)
{
player[p3].tbsj-=0;
cout<<player[p3].name<<"使用了铁壁,伤害减为1!\n";
out<<player[p3].name<<"使用了铁壁,伤害减为1!\n";
player[p3].hp+=(sum-1);
}
player[p3].hp = max(player[p3].hp, 0);
if(player[p3].hp == 0) {
haokee+=player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++)haokee+=' ';
haokee+="死因:该死的替罪羊\n";
cout << player[p3].name << " 被转移的伤害干掉了!" << endl;
out << player[p3].name << " 被转移的伤害干掉了!" << endl;
haokee += player[p3].name;
for(int i = 0; i <= maxs - player[p3].name.size(); i++) haokee += ' ';
haokee += " 致命一击:" + player[p2].name + '\n';
}
else {
cout << player[p3].name << " 还剩 " << player[p3].hp << " 的血!" << endl;
out << player[p3].name << " 还剩 " << player[p3].hp << " 的血!" << endl;
}
}
else if(player[p2].tbsj>0)
{
player[p2].tbsj--;
cout<<player[p2].name<<"使用了铁壁,伤害减为1!\n";
out<<player[p2].name<<"使用了铁壁,伤害减为1!\n";
player[p2].hp+=(sum-1);
if(player[p2].tbsj==0)
{
cout<<player[p2].name<<"铁壁时间结束\n";
out<<player[p2].name<<"铁壁时间结束\n";
}
}
if(player[p1].zdsj>0&&player[p1].hp>0)
{
player[p1].zdsj--;
int r=rand()%minsh+1;
player[p1].hp-=r;
cout<<player[p1].name<<"中毒效果生效扣除"<<r<<"滴血,还剩"<< player[p1].hp<<endl;
out<<player[p1].name<<"中毒效果生效扣除"<<r<<"滴血,还剩"<< player[p1].hp<<endl;
if(player[p1].hp<=0)
{
dainum++;
cout << player[p1].name << " 没有血了!" << endl;
out << player[p1].name << " 没有血了!" << endl;
haokee+=player[p1].name;
for(int i = 0; i <= maxs - player[p1].name.size(); i++)haokee+=' ';
haokee+="死因:毒发身亡\n";
}
}
player[p2].hp = max(0, player[p2].hp);
if(!player[p2].hp) {
dainum++;
cout << player[p2].name << " 没有血了!" << endl;
out << player[p2].name << " 没有血了!" << endl;
haokee += player[p2].name;
for(int i = 0; i <= maxs - player[p2].name.size(); i++) haokee += ' ';
haokee += "致命一击:" + player[p1].name + '\n';
}
else {
cout << player[p2].name << " 还剩下 " << player[p2].hp << " 的血量!" << endl;
out << player[p2].name << " 还剩下 " << player[p2].hp << " 的血量!" << endl;
}
GG:
puts("\n================================\n");
out << "\n================================\n" << endl;
Sleep(800);
}
}
int main() { // 主函数
if(init() == false) {
cout << "选手路径不存在!已为您创建成功,请重新打开本应用!" << endl;
cout << "注:本应用全程使用utf-8编码" << endl;
ofstream out("选手.txt");
out << "接下来若干行,输入选手名字、血量、攻击力、回血量" << endl;
cout << "按任意键继续...";
getch();
return 0;
}
play();
cout << "死亡名单:\n" + haokee << endl;
cout << "已生成txt文件,位于\"游玩结果.txt\"" << endl;
return 0;
}