mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
Optimized Reused Values for Loops
This commit is contained in:
parent
8ec42ca2e5
commit
234fcb09c2
19 changed files with 91 additions and 54 deletions
|
|
@ -13,7 +13,8 @@
|
|||
// turn weighted array into simple array
|
||||
const approaches = [];
|
||||
for (const a in approach) {
|
||||
for (let j=0; j < approach[a]; j++) {
|
||||
let approachA = approach[a];
|
||||
for (let j=0; j < approachA; j++) {
|
||||
approaches.push(a);
|
||||
}
|
||||
}
|
||||
|
|
@ -295,7 +296,8 @@
|
|||
const name = rawName.replace("Old ", ""); // remove Old prefix
|
||||
const words = name.split(" "), letters = words.join("");
|
||||
let code = words.length === 2 ? words[0][0]+words[1][0] : letters.slice(0,2);
|
||||
for (let i=1; i < letters.length-1 && pack.religions.some(r => r.code === code); i++) {
|
||||
let numberOfLetters = letters.length;
|
||||
for (let i=1; i < numberOfLetters-1 && pack.religions.some(r => r.code === code); i++) {
|
||||
code = letters[0] + letters[i].toUpperCase();
|
||||
}
|
||||
return code;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue