In a web game I'm creating with JS, I need to randomly generate attack damage. This calculation is based on the enemy's level:
var lvl = Math.floor(Math.random() * 10) + 1; // Determine level of enemy [1, 10]
function attack() {
...
var player_dmg = Math.floor(Math.random() * 25) + 1 + (lvl - 1); // Determine attack damage [1*lvl, (1*lvl)+25]
health_pts -= player_dmg;
...
}
However, what I want to achieve is the range [10 * lvl, (10 * lvl) + 25].
What could I do to get the range I want? I feel like the answer is right in front of my face but I can't for the life of me figure this out.