Religions update cultures on culture regeneration

Updated function names to be more similar and more descriptive
This commit is contained in:
Michael DiRienzo 2020-07-09 18:28:59 -04:00
parent ce3a37a421
commit f5261d09af
3 changed files with 18 additions and 6 deletions

View file

@ -355,8 +355,8 @@
// Resets the cultures of all burgs and states to their
// cell or center cell's (respectively) culture.
const resetCultures = function () {
console.time('resetCulturesForBurgsAndStates');
const updateCultures = function () {
console.time('updateCulturesForBurgsAndStates');
// Assign the culture associated with the burgs cell.
pack.burgs = pack.burgs.map( (burg, index) => {
@ -376,7 +376,7 @@
return {...state, culture: pack.cells.culture[state.center]};
});
console.timeEnd('resetCulturesForBurgsAndStates');
console.timeEnd('updateCulturesForBurgsAndStates');
}
// calculate and draw curved state labels for a list of states
@ -1055,6 +1055,6 @@
return {generate, expandStates, normalizeStates, assignColors,
drawBurgs, specifyBurgs, defineBurgFeatures, drawStateLabels, collectStatistics,
generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces, resetCultures};
generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces, updateCultures};
})));

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};
})));

View file

@ -248,7 +248,8 @@ function regenerateReligions() {
function regenerateCultures() {
Cultures.generate();
Cultures.expand();
BurgsAndStates.resetCultures();
BurgsAndStates.updateCultures();
Religions.updateCultures();
if (!layerIsOn("toggleCultures")) toggleCultures(); else drawCultures();
refreshAllEditors();
}