Add the ability to regenerate cultures (#495)

* Add the ability to regenerate cultures

- Added a button to the tools menu for regeneration.
- Regeneration button will handle initial generation of cultures and expansion afterwards.
- Pressing regenerate will warn the user.
- Small cleanup of trailing whitespace.

* Refreshing cultures editor updates culture centers

* Regenerating cultures refreshes the culture editor

* Added a function to refresh all open editors

* Reset burg and state cultures after regeneration

* Address the problem of potential data loss

Any errors while iterating the states or burgs could potentially lose the index 0 metadata stored in the arrays. This will instead track the index and ignore the 0th result.

* Religions update cultures on culture regeneration

Updated function names to be more similar and more descriptive
This commit is contained in:
mdirienzo 2020-07-18 04:31:09 -04:00 committed by GitHub
parent 0e5388c7f5
commit 43b3c8b807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 7 deletions

View file

@ -279,6 +279,17 @@
});
}
function updateCultures() {
console.time('updateCulturesForReligions');
pack.religions = pack.religions.map( (religion, index) => {
if(index === 0) {
return religion;
}
return {...religion, culture: pack.cells.culture[religion.center]};
});
console.timeEnd('updateCulturesForReligions');
}
// assign a unique two-letters code (abbreviation)
function getCode(rawName) {
const name = rawName.replace("Old ", ""); // remove Old prefix
@ -350,6 +361,6 @@
return type() + " of the " + generateMeaning();
};
return {generate, add, getDeityName, expandReligions};
return {generate, add, getDeityName, expandReligions, updateCultures};
})));