package qysx;

public class sx10 {
	static int yxhp=500;
	static int gshp=300;
	public static void yxdx(int sh) {
		yxhp=yxhp-sh;
		if(yxhp<0) {
			yxhp=0;
		
		}
		System.out.println("怪兽攻击英雄，英雄掉血"+sh+"当前剩余"+yxhp);
	}
	public static void gsdx(int sh) {
		gshp=gshp-sh;
		if(gshp<0) {
			gshp=0;
		
		}
		System.out.println("英雄攻击怪兽，怪兽掉血"+sh+"当前剩余"+gshp);
	}
	public static void yxgj() {
		int sh=(int)(Math.random()*101);
		yxdx(sh);
	}
	public static void gsgj() {
		int sh=(int)(Math.random()*151);
		gsdx(sh);
	}
	public static void main(String[] args) {
		System.out.println("打怪游戏");
		System.out.println("-----------------");
		while(yxhp>0&&gshp>0) {
			gsgj();
			if(yxhp<=0||gshp<=0) {
				break;
				
			}
			yxgj();
			if(gshp<=0||yxhp<=0) {
				break;
			}
			
		}
		System.out.println("-----------------");
		if(gshp<=0) {
			System.out.println("英雄获胜");
		}
		else {
			System.out.println("怪兽获胜");
		}
	
//		int yxhp = 500;
//		int gshp = 300;
//		System.out.println("打怪游戏");
//
//		while (yxhp > 0 && gshp > 0) {
//			int gsgj = (int) (Math.random() * 151);
//			yxhp = yxhp - gsgj;
//			System.out.println("怪兽攻击英雄，英雄掉血" + gsgj + "当前剩余" + yxhp + "血");
//
//			if (yxhp <= 0) {
//				break;
//			}
//
//			int yxgj = (int) (Math.random() * 101);
//			gshp = gshp - yxgj;
//			System.out.println("英雄攻击怪兽，怪兽掉血" + yxgj + "当前剩余" + gshp + "血");
//
//			if (gshp <= 0) {
//				break;
//			}
//
//			System.out.println("-------");
//		}
//
//		System.out.println("-------");
//		if (gshp <= 0) {
//			System.out.println("英雄胜利");
//		} else {
//			System.out.println("怪兽胜利");
//		}
	}
}