mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 02:21:24 +01:00
refactor: generate relations
This commit is contained in:
parent
907e916b45
commit
73431ec743
10 changed files with 204 additions and 14 deletions
|
|
@ -1,28 +1,31 @@
|
|||
import {TIME} from "config/logging";
|
||||
import {getColors} from "utils/colorUtils";
|
||||
import {NEUTRALS} from "./config";
|
||||
import {createAreaTiers, defineStateForm} from "./defineStateForm";
|
||||
import {defineFullStateName, defineStateName} from "./defineStateName";
|
||||
import {defineStateColors} from "./defineStateColors";
|
||||
import {isBurg} from "utils/typeUtils";
|
||||
|
||||
import type {TStateStatistics} from "./collectStatistics";
|
||||
import type {TStateData} from "./createStateData";
|
||||
import type {TDiplomacy} from "./generateDiplomacy";
|
||||
|
||||
export function specifyStates(
|
||||
statesData: TStateData[],
|
||||
statistics: TStateStatistics,
|
||||
diplomacy: TDiplomacy,
|
||||
cultures: TCultures,
|
||||
burgs: TBurgs
|
||||
): TStates {
|
||||
TIME && console.time("specifyStates");
|
||||
|
||||
const colors = getColors(statesData.length);
|
||||
const colors = defineStateColors(statistics);
|
||||
const getAreaTier = createAreaTiers(statistics);
|
||||
const getNameBase = (cultureId: number) => cultures[cultureId].base;
|
||||
|
||||
const states: IState[] = statesData.map((stateData, index) => {
|
||||
const states: IState[] = statesData.map(stateData => {
|
||||
const {i, center, type, culture, capital} = stateData;
|
||||
const {area, burgs: burgsNumber, ...stats} = statistics[i];
|
||||
const color = colors[i];
|
||||
|
||||
const capitalBurg = burgs[capital];
|
||||
const capitalName = isBurg(capitalBurg) ? capitalBurg.name : null;
|
||||
|
|
@ -34,9 +37,18 @@ export function specifyStates(
|
|||
const name = defineStateName(center, capitalName, nameBase, formName);
|
||||
const fullName = defineFullStateName(name, formName);
|
||||
|
||||
const color = colors[index];
|
||||
|
||||
const state: IState = {name, ...stateData, form, formName, fullName, color, area, burgs: burgsNumber, ...stats};
|
||||
const state: IState = {
|
||||
name,
|
||||
...stateData,
|
||||
form,
|
||||
formName,
|
||||
fullName,
|
||||
color,
|
||||
area,
|
||||
burgs: burgsNumber,
|
||||
...stats,
|
||||
diplomacy: diplomacy[i]
|
||||
};
|
||||
return state;
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue