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";
const SelectedGameStore: Writable<string> = writable("");
const SelectedGameStore: Writable<number> = writable("");
export default SelectedGameStore;

View file

@ -1,5 +1,5 @@
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;

View file

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

View file

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

View file

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