fix: Equalise the chances when picking a random backdrop

This commit is contained in:
Joke Book 2019-02-20 21:11:27 +00:00
parent a86dc5bb58
commit b29f07636d
No known key found for this signature in database
GPG key ID: FE1A37AA1630F6EF

View file

@ -408,7 +408,7 @@ class Scratch3LooksBlocks {
const numCostumes = stage.getCostumes().length;
if (numCostumes > 1) {
let selectedIndex = Math.floor(Math.random() * (numCostumes - 1));
if (selectedIndex === stage.currentCostume) selectedIndex += 1;
if (selectedIndex === stage.currentCostume) selectedIndex = numCostumes - 1;
stage.setCostume(selectedIndex);
}
// Try to cast the string to a number (and treat it as a costume index)