Switch from string to number indexes

This commit is contained in:
Neshura 2023-08-14 20:17:59 +02:00
parent c11279d68e
commit 704133a460
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
5 changed files with 12 additions and 13 deletions

View file

@ -1,5 +1,5 @@
import { writable, type Writable } from "svelte/store"; import { writable, type Writable } from "svelte/store";
const SelectedGameStore: Writable<string> = writable(""); const SelectedGameStore: Writable<number> = writable("");
export default SelectedGameStore; export default SelectedGameStore;

View file

@ -1,5 +1,5 @@
import { writable, type Writable } from "svelte/store"; import { writable, type Writable } from "svelte/store";
const SelectedGameGroupsStore: Writable<Map<string, Array<string>>> = writable(new Map()); const SelectedGameGroupsStore: Writable<Map<number, Array<number>>> = writable(new Map());
export default SelectedGameGroupsStore; export default SelectedGameGroupsStore;

View file

@ -1,12 +1,12 @@
export type ChellarisInfo = { export interface ChellarisInfo {
games: Map<string, ChellarisGame>, games: Map<number, ChellarisGame>,
ethics: Array<null>, // TODO implement ethics: Array<null>, // TODO implement
portraits: Array<null>, // TODO implement portraits: Array<null>, // TODO implement
} }
export type ChellarisGame = { export type ChellarisGame = {
name: string, name: string,
groups: Map<string, ChellarisGameGroup>, groups: Map<number, ChellarisGameGroup>,
empires: Array<null>, // TODO implement empires: Array<null>, // TODO implement
} }

View file

@ -6,11 +6,11 @@
import ChellarisDataStore from '$lib/stores/ChellarisData'; import ChellarisDataStore from '$lib/stores/ChellarisData';
import type { ChellarisGame, ChellarisGameGroup, ChellarisInfo } from '$lib/types/chellaris'; import type { ChellarisGame, ChellarisGameGroup, ChellarisInfo } from '$lib/types/chellaris';
let selectedGame: string = ''; let selectedGame: number;
let selectedGameGroups: Array<string> = []; let selectedGameGroups: Array<number> = [];
let selectedGameGroupsMap: Map<string, Array<string>> = new Map(); let selectedGameGroupsMap: Map<number, Array<number>> = new Map();
let gameGroups: Map<string, ChellarisGameGroup> = new Map(); let gameGroups: Map<number, ChellarisGameGroup> = new Map();
let chellarisData: ChellarisInfo = { let chellarisData: ChellarisInfo = {
games: new Map(), games: new Map(),
ethics: [], ethics: [],
@ -20,7 +20,7 @@
// Chellaris Data Code // Chellaris Data Code
const updateGameGroups = () => { const updateGameGroups = () => {
let tmpData; let tmpData;
if (selectedGame == "") { if (!selectedGame) {
tmpData = chellarisData.games.get(chellarisData.games.keys().next().value); tmpData = chellarisData.games.get(chellarisData.games.keys().next().value);
} }
else { else {
@ -28,7 +28,6 @@
} }
if (typeof tmpData !== 'undefined') { if (typeof tmpData !== 'undefined') {
console.log(tmpData.groups);
gameGroups = tmpData.groups; gameGroups = tmpData.groups;
} }
} }

View file

@ -5,8 +5,8 @@
import ChellarisDataStore from '$lib/stores/ChellarisData'; import ChellarisDataStore from '$lib/stores/ChellarisData';
import type { ChellarisGame } from '$lib/types/chellaris'; import type { ChellarisGame } from '$lib/types/chellaris';
let selectedGame = ''; let selectedGame: number;
let gameList: Map<string, ChellarisGame> = new Map(); let gameList: Map<number, ChellarisGame> = new Map();
// Chellaris Data Code // Chellaris Data Code
ChellarisDataStore.subscribe((data) => { ChellarisDataStore.subscribe((data) => {