Taking Damage

Any suggestions on fair ways to calculate damage that isn’t too complicated? At the moment I’m using:


public void damaged(int amount) {
	Random random = new Random();
	double damage;
	int maxDef = defense + getDefBonus();
	double percMinus = random.nextInt(maxDef - (maxDef / 2)) + (maxDef / 2);
	damage = amount - Math.ceil(amount * (percMinus / 100));
	hp -= (int)damage;
	alive = hp > 0;
}

Well, if that’s how your game’s damage calculation then nothing is wrong.

Don’t create a Random object each time, store it and reuse it. :slight_smile: