diff --git a/components/modals/AppearanceModal.tsx b/components/modals/AppearanceModal.tsx index cf648496..80b918e7 100644 --- a/components/modals/AppearanceModal.tsx +++ b/components/modals/AppearanceModal.tsx @@ -3,6 +3,8 @@ import { closeModal } from '../../lib/commands/modal' import { useCore } from '../../lib/state/core' import { View } from '../helper/View' import { Heading } from '../../lib/state/types' +import { appearanceRegistry } from '../../lib/data/appearance' +import { submit_event } from '../../lib/helper/submit' export function AppearanceModal() { // const [selected, setSelected] = useState(-1) @@ -20,6 +22,9 @@ export function AppearanceModal() { } }, []) + const registry = Object.entries(appearanceRegistry) + registry.sort((a, b) => a[1].position - b[1].position) + const core = useCore() return (
Kappe:{' '} -
Shirt:{' '}
-
Hose:{' '}
-
Hautton:{' '}
-
+ {(() => { + const appearance = Object.entries(core.ws.analyze.appearance) + appearance.sort((a, b) => b[1].count - a[1].count) + + return appearance.map((entry) => ( + + {entry[0]}:{appearanceRegistry[parseInt(entry[0])].type}- + {appearanceRegistry[parseInt(entry[0])].type} (x + {entry[1].count}) + + )) + })()} +
diff --git a/lib/commands/init.ts b/lib/commands/init.ts
index a7691c15..8f09e548 100644
--- a/lib/commands/init.ts
+++ b/lib/commands/init.ts
@@ -168,6 +168,17 @@ export async function initClient(core: Core) {
}
userRawData[entry.userId].nameSetAt = ts
}
+
+ const appearance = /^select_appearance_(.+)/.exec(entry.event)
+
+ if (appearance) {
+ const id = appearance[1]
+ if (!ws.analyze.appearance[id]) {
+ ws.analyze.appearance[id] = { count: 0 }
+ }
+ ws.analyze.appearance[id].count++
+ continue
+ }
}
}
})
diff --git a/lib/data/appearance.ts b/lib/data/appearance.ts
new file mode 100644
index 00000000..55a6db7b
--- /dev/null
+++ b/lib/data/appearance.ts
@@ -0,0 +1,14 @@
+import { AppearanceData } from '../state/types'
+
+export const appearanceRegistry: { [key: number]: AppearanceData } = {
+ 0: { type: 'cap', title: 'schwarz', position: 0 },
+ 1: { type: 'skin', title: 'gelb', position: 0 },
+ 2: { type: 'shirt', title: 'rot', position: 0 },
+ 3: { type: 'legs', title: 'blau', position: 0 },
+ 4: { type: 'skin', title: 'hell', position: 2 },
+ 5: { type: 'skin', title: 'dunkel', position: -1 },
+ 6: { type: 'shirt', title: 'orange', position: 1 },
+ 7: { type: 'legs', title: 'grün', position: 1 },
+ 8: { type: 'cap', title: 'weiß', position: 1 },
+ 9: { type: 'shirt', title: 'Regenbogen', position: 0.5 },
+}
diff --git a/lib/state/create.ts b/lib/state/create.ts
index 6c59ac5a..a41d2fe8 100644
--- a/lib/state/create.ts
+++ b/lib/state/create.ts
@@ -84,6 +84,7 @@ export function createWorkspaceState(): WorkspaceState {
customQuests: {},
quests: {},
legacy: {},
+ appearance: {},
userTimes: [],
solutions: {},
},
diff --git a/lib/state/types.ts b/lib/state/types.ts
index dac473dd..308a132c 100644
--- a/lib/state/types.ts
+++ b/lib/state/types.ts
@@ -164,6 +164,7 @@ export interface Analyze {
useAudio: number
customQuests: { [key: string]: { start: number; complete: number } }
legacy: { [key: string]: { count: number } }
+ appearance: { [key: string]: { count: number } }
quests: { [key: string]: { reachable: number; complete: number } }
userTimes: number[]
solutions: {
@@ -276,3 +277,9 @@ export interface Compressed2D