diff --git a/src/lib/types/chellaris.ts b/src/lib/types/chellaris.ts
index 969beea..3d54968 100644
--- a/src/lib/types/chellaris.ts
+++ b/src/lib/types/chellaris.ts
@@ -101,7 +101,7 @@ export const createBlankEmpire = (
machine: false,
portrait_id: 0,
portrait_group_id: 0,
- ethics: [],
+ ethics: {},
discord_user: undefined,
name: ""
};
diff --git a/src/lib/types/stellaris.ts b/src/lib/types/stellaris.ts
index ef3e8f9..4889b60 100644
--- a/src/lib/types/stellaris.ts
+++ b/src/lib/types/stellaris.ts
@@ -68,14 +68,11 @@ export type Ethic = {
id: number,
display: string,
gestalt: boolean,
- fanatic?: boolean,
}
export type EmpireEthic = {
ethic_id: number,
- display: string,
- gestalt: boolean,
- fanatic?: boolean,
+ fanatic: boolean,
}
export type Phenotype = {
diff --git a/src/routes/admin/+page.svelte b/src/routes/admin/+page.svelte
index 9c98802..c3ec156 100644
--- a/src/routes/admin/+page.svelte
+++ b/src/routes/admin/+page.svelte
@@ -39,7 +39,6 @@
let empireList: { [key: number]: ChellarisEmpire } = {};
let empireData: ChellarisEmpire;
let addingNewEmpire = false;
- $: console.log("adding:", addingNewEmpire);
let loadingEmpireData = true;
const updateGameData = () => {
@@ -54,17 +53,19 @@
groupList = data.groups;
empireList = {};
Object.values(data.empires).forEach((empire: ChellarisEmpire) => {
- if ($AdminSelectedGroupStore[$AdminSelectedGameStore] === undefined) {
+ if (typeof $AdminSelectedGroupStore[$AdminSelectedGameStore] === 'undefined') {
$AdminSelectedGroupStore[$AdminSelectedGameStore] = {};
}
- if ($AdminSelectedGroupStore[$AdminSelectedGameStore][empire.group]) {
+ if (typeof $AdminSelectedGroupStore[$AdminSelectedGameStore][empire.group] !== 'undefined') {
empireList[empire.id] = empire;
}
});
delay(200).then(() => (loadingGameData = false));
delay(200).then(() => (loaded = true));
- loadEmpireData();
+ if (typeof $AdminSelectedEmpireStore[$AdminSelectedGameStore] !== 'undefined') {
+ loadEmpireData();
+ }
});
});
}
@@ -94,7 +95,10 @@
}
}
- AdminSelectedGameStore.subscribe(() => {
+ AdminSelectedGameStore.subscribe((game) => {
+ if (typeof game === 'undefined') {
+ game = Object.values(gameList)[0].id;
+ }
updateGameData();
loadingGameData = true;
});
@@ -217,7 +221,9 @@
const setActiveEmpire = (empireId: number) => {
loadingEmpireData = true;
$AdminSelectedEmpireStore[$AdminSelectedGameStore] = empireId;
- loadEmpireData();
+ if (typeof $AdminSelectedEmpireStore[$AdminSelectedGameStore] !== 'undefined') {
+ loadEmpireData();
+ }
};
const addEmpire = () => {
@@ -228,13 +234,13 @@
list2.push(list2.length); */
};
- const finishAddNewEmpire = (event: { detail: { new_id: number; }; }) => {
+ const finishAddNewEmpire = (event: { detail: { new_id: number } }) => {
$AdminSelectedEmpireStore[$AdminSelectedGameStore] = event.detail.new_id;
updateGameData();
};
const deleteEmpire = (empire: ChellarisEmpire) => {
- fetch(apiBaseUrl + '/v3/empire?game_id=' + empire.game + '&group_id=' + empire.group + '&empire_id=' + empire.id, {
+ fetch(apiBaseUrl + '/v3/empire?game_id=' + empire.game + '&empire_id=' + empire.id, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
@@ -358,7 +364,7 @@
>
{empire.name}
- {empire.discord_user || "N/A"}
+ {empire.discord_user || 'N/A'}