package uk.org.ulcompsoc.ld32.components;

import java.util.Random;

import com.badlogic.ashley.core.Component;

public class Damage extends Component {
	
	private float damage;
	private final float origDam;
	
	public Damage(float dam) {
		damage = dam;
		origDam = dam;
	}
	
	public void useMultiplier(float multiplier) {
		damage = damage * multiplier;
	}
	
	public float getDamage() {
		return damage;
	}
	
	public float getOriginalDamage() {
		return origDam;
	}
	
	public float getDamageDealt() {
		float min = damage * 0.8f;
		float max = damage * 1.2f;
		Random rand = new Random();
		float random = rand.nextFloat();
		
		float range = max - min;
		float scaled = random * range;
		float shifted = scaled + min;
		return shifted;
	}
}

@@ -147,16 +147,57 @@
 nent %7B%0A%09
+private final Random rand = new Random();
 %0A%09privat
@@ -242,17 +242,16 @@
 rigDam;%0A
-%09
 %0A%09public
@@ -303,25 +303,24 @@
 m = dam;%0A%09%7D%0A
-%09
 %0A%09public voi
@@ -386,25 +386,24 @@
 tiplier;%0A%09%7D%0A
-%09
 %0A%09public flo
@@ -435,25 +435,24 @@
  damage;%0A%09%7D%0A
-%09
 %0A%09public flo
@@ -497,17 +497,16 @@
 Dam;%0A%09%7D%0A
-%09
 %0A%09public
@@ -533,16 +533,22 @@
 t() %7B%0A%09%09
+final 
 float mi
@@ -564,24 +564,30 @@
 e * 0.8f;%0A%09%09
+final 
 float max = 
@@ -605,38 +605,8 @@
 2f;%0A
-%09%09Random rand = new Random();%0A
 %09%09fl
@@ -640,13 +640,17 @@
 ();%0A
-%09%09
 %0A%09%09
+final 
 floa
@@ -668,24 +668,30 @@
 ax - min;%0A%09%09
+final 
 float scaled
@@ -707,24 +707,30 @@
  * range;%0A%09%09
+final 
 float shifte

optimise Damage.java slightly