#include<iostream>
using namespace std;
int main(){
//**********************************************************
int hp1=10,hp2=10,x,hh=1,q1=0,q2=0;
//**********************************************************
cout<<"游戏规则:"<<endl;
cout<<"操作部分:"<<endl;
cout<<"在你的回合,你可以按下三个键:"<<endl;
cout<<" 按键'1':对敌方造成2点伤害;"<<endl;
cout<<" 按键'2':对回复自身1点生命值;"<<endl;
cout<<" 按键'3':对自身造成1点伤害。"<<endl;
cout<<" 其他:跳过回合。"<<endl;
cout<<"机制方面,本游戏目前有两个机制:"<<endl;
cout<<" 1.在你的生命值不大于5时,你的回血值变为2点;"<<endl;
cout<<" 2.在你的生命值不大于5时,你的伤害+1;"<<endl;
cout<<" 在你的生命值不大于3时,你的伤害+2;"<<endl;
cout<<" 在你的生命值不大于1时,你的伤害+3;"<<endl<<endl;
cout<<"P1初始生命值为:"<<hp1<<endl;
cout<<"P2初始生命值为:"<<hp2<<endl<<endl;
//**********************************************************
while(1==1){
cout<<"********************************************************************************";
cout<<"第"<<hh<<"回合:"<<endl;
//******************************************************
cout<<"P1的回合:"<<endl;
cin>>x;
//******************************************************
if(x==1){
cout<<"P1攻击!"<<endl;
if(hp1==1){
cout<<"触发血怒III:"<<endl;
hp2=hp2-5;
cout<<"P2受到5点伤害。"<<endl;
//----------------------------------------------
}else if(hp1<=3){
cout<<"触发血怒II:"<<endl;
hp2=hp2-4;
cout<<"P2受到4点伤害。"<<endl;
//----------------------------------------------
}else if(hp1<=5){
cout<<"触发血怒I:"<<endl;
hp2=hp2-3;
cout<<"P2受到3点伤害。"<<endl;
//----------------------------------------------
}else{
hp2=hp2-2;
cout<<"P2受到2点伤害。"<<endl;
}
}
//******************************************************
else if(x==2){//P1回血
if(hp1<=5){
cout<<"触发急救:"<<endl;
cout<<"P1回复2点生命值"<<endl;
hp1=hp1+2;
//-----------------------------------------------
}else{
cout<<"P1回复1点生命值"<<endl;
hp1=hp1+1;
//-----------------------------------------------
}
//*******************************************************
}else if(x==3){
if(hp1>1){
cout<<"P1对自身造成1点伤害。"<<endl;
hp1=hp1-1;
}else{
cout<<"生命值不够,默认跳过回合"<<endl;
}
//*******************************************************
}else{
cout<<"P1跳过回合。"<<endl;
}
//*******************************************************
cout<<endl;
cout<<"当前P1血量值:"<<hp1<<endl;
cout<<"当前P2血量值:"<<hp2<<endl<<endl;
cout<<"--------------------------------------------------------------------------------";
//---------------------------------------------------
if(hp1<=0 || hp2<=0){
break;
}
//*******************************************************
cout<<"P2的回合:"<<endl;
cin>>x;
//*******************************************************
if(x==1){
cout<<"P2攻击!"<<endl;
//---------------------------------------------------
if(hp2==1){
cout<<"触发血怒III:"<<endl;
hp1=hp1-5;
cout<<"P1受到5点伤害。"<<endl;
}
//---------------------------------------------------
else if(hp2<=3){
cout<<"触发血怒II:"<<endl;
hp1=hp1-4;
cout<<"P1受到4点伤害。"<<endl;
//---------------------------------------------------
}else if(hp2<=5){
cout<<"触发血怒I:"<<endl;
hp1=hp1-3;
cout<<"P1受到3点伤害。"<<endl;
//---------------------------------------------------
}else{
hp1=hp1-2;
cout<<"P1受到2点伤害。"<<endl;
}
}
//*******************************************************
else if(x==2){//P2回血
if(hp2<=5){
cout<<"触发急救:"<<endl;
cout<<"P2回复2点生命值。"<<endl;
hp2=hp2+2;
}
//---------------------------------------------------
else{
cout<<"P2回复1点生命值。"<<endl;
hp2=hp2+1;
}
//*******************************************************
}else if(x==3){
if(hp2>1){
cout<<"P2对自身造成1点伤害。"<<endl;
hp2=hp2-1;
}else{
cout<<"生命值不够,默认跳过回合"<<endl;
}
//*******************************************************
}else{
cout<<"P2跳过回合。"<<endl;
}
cout<<endl;
//*******************************************************
cout<<"当前P1血量值:"<<hp1<<endl;
cout<<"当前P2血量值:"<<hp2<<endl<<endl;
//-----------------------------------------------
if(hp1<=0 || hp2<=0){
break;
}
//*******************************************************
hh++;
//*******************************************************
}
if(hp1<=0){
cout<<endl<<"P2胜利。";
}
}
对战游戏:
最新推荐文章于 2024-09-13 17:43:09 发布