MCPcopy Create free account
hub / github.com/HashLips/generative-art-opensource / getRandomRarity

Function getRandomRarity

index.js:113–125  ·  view source on GitHub ↗
(_rarityOptions)

Source from the content-addressed store, hash-verified

111};
112
113const getRandomRarity = (_rarityOptions) => {
114 let randomPercent = Math.random() * 100;
115 let percentCount = 0;
116
117 for (let i = 0; i <= _rarityOptions.length; i++) {
118 percentCount += _rarityOptions[i].percent;
119 if (percentCount >= randomPercent) {
120 console.log(`use random rarity ${_rarityOptions[i].id}`)
121 return _rarityOptions[i].id;
122 }
123 }
124 return _rarityOptions[0].id;
125}
126
127// create a dna based on the available layers for the given rarity
128// use a random part for each layer

Callers 1

createDnaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected