-
-
- {#if loadingGameData}
-
- {:else}
- {#each Object.values(empireList) as empire}
-
diff --git a/src/routes/admin/+page.ts b/src/routes/admin/+page.ts
index b3ece1a..c074a8a 100644
--- a/src/routes/admin/+page.ts
+++ b/src/routes/admin/+page.ts
@@ -1,29 +1,10 @@
import { apiBaseUrl } from "$lib/components/consts";
import AdminSelectedEmpireStore from "$lib/stores/admin-page/EmpireStore";
import AdminSelectedGameStore from "$lib/stores/admin-page/GameStore";
-import AuthTokenStore from "$lib/stores/AuthTokenStore";
import type { ChellarisGameInfo } from "$lib/types/chellaris";
-import { redirect } from "@sveltejs/kit";
import AdminSelectedGroupStore from '../../lib/stores/admin-page/GroupStore';
export async function load ({ fetch }) {
- let authToken = "";
-
- AuthTokenStore.subscribe(token => {
- authToken = token;
- });
-
- const auth = await (await fetch(apiBaseUrl + "/v3/auth",{
- headers: {
- 'Content-Type': 'application/json',
- 'x-api-key': authToken
- }
- })).json();
-
- if (!auth.admin && !auth.moderator) {
- throw redirect(303, '/401');
- }
-
const gameList: { [key: number]: ChellarisGameInfo } = await (await fetch(apiBaseUrl + "/v3/games")).json();
let store: string | null;
@@ -56,5 +37,7 @@ export async function load ({ fetch }) {
}
}
- return { games: gameList };
+ return {
+ games: gameList
+ };
}
\ No newline at end of file
diff --git a/src/routes/admin/EmpireDetails.svelte b/src/routes/admin/EmpireDetails.svelte
index 52fcd88..b5f1ad1 100644
--- a/src/routes/admin/EmpireDetails.svelte
+++ b/src/routes/admin/EmpireDetails.svelte
@@ -1,49 +1,329 @@
-
- {#if empire}
-
- ID: {empire.id}
-
-
- Group ID: {empire.group}
-
-
- Game ID: {empire.game}
-
-
- Gestalt: {empire.gestalt}
-
-
- Machine: {empire.machine}
-
-
- Portrait ID: {empire.portrait_id}
-
-
- Portrait Group ID: {empire.portrait_group_id}
-
-
- Name: {empire.name}
-
-
- Discord User: {empire.discord_user}
-
-
- {#if empire.ethics}
- {#each Object.values(empire.ethics) as ethic}
- {ethic.ethic_id},
- {/each}
+{#if newEmpire && newEmpirePrepared}
+
+ ID: {empire.id}
+
+
+ Game ID: {empire.game}
+
+
+ {#each Object.values(groups) as group}
+ {#if group}
+
+
+
+
{/if}
-
- {:else}
- No Empire Selected
- {/if}
-
+ {/each}
+
+
+
+
+
+
+
+
+
+
+ {#each Object.values($LeanChellarisDataStore.phenotypes[empire.portrait_group_id].species) as species}
+ {#if species}
+
+
+
+
+ {/if}
+ {/each}
+
+
+
+
+ {#each Object.values(Object.values($LeanChellarisDataStore.phenotypes)) as phenotype}
+ {#if phenotype}
+
+
+
+
+ {/if}
+ {/each}
+
+
+
+
+
+
+
+
+
$LeanChellarisDataStore.ethics[selection.ethic_id].display).join(", ")} dropdownId={ethicsDropdownId}>
+ {#each Object.values($LeanChellarisDataStore.ethics) as ethic}
+ {#if ethic}
+
+
+
+
+ {/if}
+ {/each}
+
+
+ {#if empire.ethics}
+ Ethics*:
+ {#each Object.values(empire.ethics) as ethic}
+ {ethic.fanatic ? ' Fanatic' : ''} {$LeanChellarisDataStore.ethics[ethic.ethic_id].display},
+ {/each}
+ {/if}
+
+
Save
+{:else if !newEmpire}
+
+ {#if empire}
+
+ ID: {empire.id}
+
+
+ Game ID: {empire.game}
+
+
+ {#each Object.values(groups) as group}
+ {#if group}
+
+
+
+
+ {/if}
+ {/each}
+
+
+
+
+
+
+
+
+
+
+ {#each Object.values($LeanChellarisDataStore.phenotypes[empire.portrait_group_id].species) as species}
+ {#if species}
+
+
+
+
+ {/if}
+ {/each}
+
+
+
+
+ {#each Object.values(Object.values($LeanChellarisDataStore.phenotypes)) as phenotype}
+ {#if phenotype}
+
+
+
+
+ {/if}
+ {/each}
+
+
+
+
+
+
+
+
(selection.fanatic ? "Fanatic " : "") + $LeanChellarisDataStore.ethics[selection.ethic_id].display).join(", ")} dropdownId={ethicsDropdownId}>
+ {#each Object.values($LeanChellarisDataStore.ethics) as ethic}
+ {#if ethic}
+
+
+
+
+ {/if}
+ {/each}
+
+
+ {#if empire.ethics}
+ Ethics:
+ {#each Object.values(empire.ethics) as ethic}
+ {ethic.fanatic ? ' Fanatic' : ''} {$LeanChellarisDataStore.ethics[ethic.ethic_id].display},
+ {/each}
+ {/if}
+
+ {:else}
+ No Empire Selected
+ {/if}
+
+
+
Save
+{/if}
diff --git a/src/routes/graphs/excel-style/+page.svelte b/src/routes/graphs/excel-style/+page.svelte
index 14b11be..51226a1 100644
--- a/src/routes/graphs/excel-style/+page.svelte
+++ b/src/routes/graphs/excel-style/+page.svelte
@@ -31,7 +31,7 @@
ethicsData: {
[key: number]: {
id: number;
- machine: boolean;
+ gestalt: boolean;
display: string;
regular: number;
fanatic: number;
@@ -47,7 +47,7 @@
ethicsData: {
[key: number]: {
id: number;
- machine: boolean;
+ gestalt: boolean;
display: string;
regular: number;
fanatic: number;
@@ -67,13 +67,13 @@
Object.values($ChellarisDataStore.ethics).forEach((ethic) => {
const newEthicsData: {
id: number;
- machine: boolean;
+ gestalt: boolean;
display: string;
regular: number;
fanatic: number;
} = {
id: ethic.id,
- machine: ethic.machine,
+ gestalt: ethic.gestalt,
display: ethic.display,
regular: 0,
fanatic: 0
@@ -84,60 +84,6 @@
Object.values(selectedGame.empires).forEach((empire) => {
console.log(empire); //DEBUG
if (empire.group in selectedGameGroupData.selectedGroups) {
- newPageData.empireCount = newPageData.empireCount + 1;
-
- if (empire.gestalt) {
- newPageData.gestaltCount.total = newPageData.gestaltCount.total + 1;
-
- let machine = false;
- Object.values(empire.ethics).forEach((ethic) => {
- if (ethic.machine) {
- machine = true;
- }
- });
-
- if (machine) {
- newPageData.gestaltCount.machines = newPageData.gestaltCount.machines + 1;
- }
- }
-
- Object.values(empire.ethics).forEach((ethic) => {
- const tmpEthicPageData = newPageData.ethicsData[ethic.ethic_id];
-
- if (typeof tmpEthicPageData !== 'undefined') {
- tmpEthicPageData.display = ethic.display;
- if (!ethic.fanatic) {
- tmpEthicPageData.regular = tmpEthicPageData.regular + 1;
- } else {
- tmpEthicPageData.fanatic = tmpEthicPageData.fanatic + 1;
- }
-
- newPageData.ethicsData[ethic.ethic_id] = tmpEthicPageData;
- } else {
- let newEthicsData: {
- id: number;
- machine: boolean;
- display: string;
- regular: number;
- fanatic: number;
- } = {
- id: ethic.ethic_id,
- machine: ethic.machine,
- display: ethic.display,
- regular: 0,
- fanatic: 0
- };
-
- if (!ethic.fanatic) {
- newEthicsData.regular = 1;
- } else {
- newEthicsData.fanatic = 1;
- }
-
- newPageData.ethicsData[ethic.ethic_id] = newEthicsData;
- }
- });
-
if (typeof newPageData.takenPortraits[empire.portrait_group_id] === 'undefined') {
newPageData.takenPortraits[empire.portrait_group_id] = [];
}
@@ -157,16 +103,63 @@
newPageData.takenPortraits[empire.portrait_group_id] = portraitGroupData;
}
}
+
+ newPageData.empireCount = newPageData.empireCount + 1;
+
+ if (empire.gestalt) {
+ newPageData.gestaltCount.total = newPageData.gestaltCount.total + 1;
+ }
+
+ if (empire.machine) {
+ newPageData.gestaltCount.machines = newPageData.gestaltCount.machines + 1;
+ }
+
+ Object.values(empire.ethics).forEach((ethic) => {
+ const tmpEthicPageData = newPageData.ethicsData[ethic.ethic_id];
+
+ if (typeof tmpEthicPageData !== 'undefined') {
+ tmpEthicPageData.display = ethic.display;
+ if (!ethic.fanatic) {
+ tmpEthicPageData.regular = tmpEthicPageData.regular + 1;
+ } else {
+ tmpEthicPageData.fanatic = tmpEthicPageData.fanatic + 1;
+ }
+
+ newPageData.ethicsData[ethic.ethic_id] = tmpEthicPageData;
+ } else {
+ let newEthicsData: {
+ id: number;
+ gestalt: boolean;
+ display: string;
+ regular: number;
+ fanatic: number;
+ } = {
+ id: ethic.ethic_id,
+ gestalt: ethic.gestalt,
+ display: ethic.display,
+ regular: 0,
+ fanatic: 0
+ };
+
+ if (!ethic.fanatic) {
+ newEthicsData.regular = 1;
+ } else {
+ newEthicsData.fanatic = 1;
+ }
+
+ newPageData.ethicsData[ethic.ethic_id] = newEthicsData;
+ }
+ });
}
});
// Fill undefined Portrait Info with default information.
- for (let i = 0; i < Object.values($ChellarisDataStore.species).length; i++) {
+ for (let i = 0; i < Object.values($ChellarisDataStore.phenotypes).length; i++) {
if (typeof newPageData.takenPortraits[i] === 'undefined') {
newPageData.takenPortraits[i] = [];
}
- for (let ii = 0; ii < Object.values($ChellarisDataStore.species[i].portraits).length; ii++) {
+ for (let ii = 0; ii < Object.values($ChellarisDataStore.phenotypes[i].species).length; ii++) {
if (typeof newPageData.takenPortraits[i][ii] === 'undefined') {
newPageData.takenPortraits[i][ii] = [0, []];
}
@@ -210,7 +203,7 @@
# Fanatic |
{#each Object.values(pageData.ethicsData) as ethicData}
- {#if ethicData && !ethicData.machine}
+ {#if ethicData && !ethicData.gestalt}
{ethicData.display} |
{ethicData.regular} |
@@ -226,11 +219,11 @@
> Machines: {pageData.gestaltCount.machines}
- Machine Ethic |
+ Gestalt Ethic |
# |
{#each Object.values(pageData.ethicsData) as ethicData}
- {#if ethicData && ethicData.machine}
+ {#if ethicData && ethicData.gestalt}
{ethicData.display} |
{ethicData.regular} |
@@ -249,11 +242,11 @@
{index + 1} |
{/each}
- {#each Object.values($ChellarisDataStore.species) ?? false as portraitGroup}
+ {#each Object.values($ChellarisDataStore.phenotypes) ?? false as portraitGroup}
{#if portraitGroup}
{portraitGroup.display} |
- {#each Object.values(portraitGroup.portraits) ?? false as portrait}
+ {#each Object.values(portraitGroup.species) ?? false as portrait}
{#if portrait}
|