游戏里暴击概率简单JAVA的YY实现

package test;

public class Test {
	public static void main(String[] args) {
		//初始攻击力
		int x = 1000;
		//发动技能"停滞一击"(定身对方10秒且有30%的几率造成2倍伤害)
		int y = breakSkill(x);
		System.out.println("发动停滞一击后造成的伤害为:"+y);
		//发动技能"幸运一击"(53%的几率使对方立即死亡)
		boolean flag = luckSkill();
		if(flag){
			System.out.println("对方被你秒杀");
		}else{
			System.out.println("秒杀对方失败");
		}
	}

	private static int breakSkill(int x) {
		int number = (int)(Math.random()*10)+1;
		if(number==3||number==6||number==9){
			return 2*x;
		}
		return x;
	}

	private static boolean luckSkill() {
		int number = (int)(Math.random()*100)+1;
		if(number>54){
			return false;
		}else{
			return true;
		}
	}
}

你可能感兴趣的:(java,游戏,笑话)