public static int damageAfterResistance(int amount, DamageType d, float[] resistances) { if (d.isResistable()) { float resist = resistances[(int)Math.Log((uint)d, 2)]; return (int)Math.Round(amount * resist); } return amount; }