Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NathanielInman/a3105914df32c5b368521d5bc0842c2b to your computer and use it in GitHub Desktop.
Save NathanielInman/a3105914df32c5b368521d5bc0842c2b to your computer and use it in GitHub Desktop.
How do balance equipment statistics
1.
First, in order to algorithmically change everything you need a weight for each
statistic; otherwise we don't know how they compare across levels.
strength: 1
hitroll: 1.5
damroll: 2
2.
Now you need a baseline score for the first level of the game and the last level of the game.
This is assuming that the intention is to scale the stats linearly while leveling.
3.
Now you simply loop through all items of the game, extrapolating their current score and boosting
their applied stats evenly until they cannot be increased anymore and are less than or equal to
the expected score for the current level.
Example code:
```
const weightPerLevel = 50;
items.forEach(item=>{
const currentLevelWeight = item.level*weightPerLevel;
let failure = 0,
currentItemWeight = calculateItemWeight(item); // simple calc
while(failure<25&&itemWeight<currentLevelWeight){
// don't want to just increase the first stat on the item
// all the time to reach the currentLevelWeight. Either
// randomize the list or weight a random distribution method
// so it's more likely to increase certain stats like hitroll
// or damroll.
randomize(Object.keys(item)).forEach(attribute=>{
item[attribute]++;
calculateItemWeight(item);
});
} //end while
});
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment