坤国杀

tctm103 2023-08-26 12:06:00 3
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <bits/stdc++.h>
using namespace std;
struct str{
	int x;
	int y;
}xue,sha,shan,tao,csha;
int main() {
    srand(time(NULL));
    int n;
    
    sha.x = rand()%2;
    shan.x = rand()%2;
    tao.x = 5-sha.x-shan.x;
    
    sha.y = rand()%2;
    shan.y = rand()%2;
    tao.y = 5-sha.y-shan.y;
    
    xue.x=rand()%3+2;
    xue.y=rand()%3+8;
   
    while(xue.x>0&&xue.y>0){
    	if(xue.x==0||xue.y==0)break;
    	int i=rand()%2;
    	int j=rand()%2;
    	if(i==0){
    		sha.y++;
		}
		if(i==1){
    		shan.y++;
		}
		if(i==2){
    		tao.y++;
		}
		if(j==0){
    		sha.y++;
		}
		if(j==1){
    		shan.y++;
		}
		if(j==2){
    		tao.y++;
		}
		int i1=rand()%2;
    	int j1=rand()%2;
    	if(i1==0){
    		sha.x++;
		}
		if(i1==1){
    		shan.x++;
		}
		if(i1==2){
    		tao.x++;
		}
		if(j1==0){
    		sha.x++;
		}
		if(j1==1){
    		shan.x++;
		}
		if(j1==2){
    		tao.x++;
		}
		cout<<"玩家出牌"<<endl;
    	cout<<"玩家剩余牌数:"<<sha.x+shan.x+tao.x<<"    当前血量:"<<xue.x<<"   对方血量:"<<xue.y;
		cout<<endl<<"杀:"<<sha.x<<"  闪:"<<shan.x<<"  桃:"<<tao.x<<endl;
		if(sha.x!=0||tao.x!=0){
			cout<<"请选择: 1.杀;2.桃;"<<endl;
		cin>>n;
		if(n==273561){
			xue.y-=3;
		}
		if(n==666666){
			xue.y-=8;
		}
		if(n==1&&sha.x>0){
			sha.x--;
			if(shan.y>0){
				shan.y--;
				cout<<"对方用闪抵消!"<<endl;
			}
			else if(shan.y<=0){
				xue.y--;
				cout<<"成功造成一点伤害!"<<endl;
			}
			
		}
		
		if(n==2&&tao.x>0){
			xue.x++;
		}
		while(sha.x+shan.x+tao.x>xue.x){
		cout<<"剩余牌数:"<<sha.x+shan.x+tao.x<<"    手牌上限:"<<xue.x<<endl; 
		cout<<"弃杀扣1,弃闪扣2,弃桃扣3"<<endl;
		int h2;
		cin>>h2;
		if(h2==1&&sha.x>0){
			sha.x--;
		}
		if(h2==2&&shan.x>0){
			shan.x--;
		}
		if(h2==3&&tao.x>0){
			tao.x--;
		}
	}
		
		
		if(sha.x==0&&tao.x==0){
			cout<<"无法出牌,已自动跳过!"<<endl<<endl; 
		}cout<<endl<<endl<<"机器人出牌"<<endl;
		if(tao.y>0){
			cout<<"机器人使用了桃"<<endl;
			xue.y++;
			tao.y--;
		}
		else{
			sha.y--;
			cout<<"机器人使用了杀"<<endl;
			if(shan.x==0){
				cout<<"你的闪<=0;自动扣一血;"<<endl;
				xue.x--;
			}
			else{
				int h;cout<<"是否出闪?是扣一,不是扣二"<<endl;
				cin>>h;
				if(h==1){
					shan.x--;
					
				}
				if(h==2){
					xue.x--;
				}
				
			}
		}
	}
	while(sha.y+shan.y+tao.y>xue.y){
		int ko=rand()%2;
		if(ko==0)sha.y--;
		if(ko==1)tao.y--;
		if(ko==2)shan.y--;
		ko=rand()%2;
	}
	cout<<"回合结束,请选择弃牌:"<<endl;
	
	if(xue.x<=0&&tao.x>0){
		cout<<"你的血量小于0,是否用桃?   是扣一,否扣二"<<endl;
		int h1;
		cin>>h1;
		if(h1==1){
			xue.x++;
		} 
		else{
			
		}
	}
	cout<<endl<<endl<<endl;
} 
	if(xue.x==0){
		cout<<"机器人获胜!";
	}
	else{
		cout<<"玩家获胜!";
	}
}
//273561=天雷,可造成3点伤害
//666666=天劫,可造成8点伤害 
{{ vote && vote.total.up }}

共 1 条回复

CPP 刷题王

猪国杀