mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
refactor - stateForms start
This commit is contained in:
parent
60e69348a9
commit
2be3c68290
15 changed files with 277 additions and 89 deletions
37
src/scripts/generation/pack/burgsAndStates/specifyStates.ts
Normal file
37
src/scripts/generation/pack/burgsAndStates/specifyStates.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import {TIME} from "config/logging";
|
||||
import {getColors} from "utils/colorUtils";
|
||||
import {NEUTRALS} from "./config";
|
||||
import {createAreaTiers, defineStateForm} from "./defineStateForm";
|
||||
import {defineFullStateName} from "./defineStateName";
|
||||
|
||||
import type {TStateStatistics} from "./collectStatistics";
|
||||
import type {TStateData} from "./createStateData";
|
||||
|
||||
export function specifyStates(
|
||||
statesData: TStateData[],
|
||||
statistics: TStateStatistics,
|
||||
stateIds: Uint16Array,
|
||||
burgIds: Uint16Array
|
||||
): TStates {
|
||||
TIME && console.time("specifyState");
|
||||
|
||||
const colors = getColors(statesData.length);
|
||||
const getAreaTier = createAreaTiers(statistics);
|
||||
|
||||
const states: IState[] = statesData.map((stateData, index) => {
|
||||
const {i, type, name} = stateData;
|
||||
const {area, ...stats} = statistics[i];
|
||||
|
||||
const areaTier = getAreaTier(area);
|
||||
const {form, formName} = defineStateForm(type, areaTier);
|
||||
const fullName = defineFullStateName(name, form);
|
||||
|
||||
const color = colors[index];
|
||||
|
||||
const state: IState = {...stateData, form, formName, fullName, color, area, ...stats};
|
||||
return state;
|
||||
});
|
||||
|
||||
TIME && console.timeEnd("specifyState");
|
||||
return [NEUTRALS, ...states];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue