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:{' '} - { + core.mutateWs((ws) => { + ws.appearance.cap = parseInt(e.target.value) + }) + }} + > + {registry + .filter((entry) => entry[1].type == 'cap') + .map((entry) => ( + + ))}

Shirt:{' '} - { + core.mutateWs((ws) => { + ws.appearance.shirt = parseInt(e.target.value) + }) + }} + > + {registry + .filter((entry) => entry[1].type == 'shirt') + .map((entry) => ( + + ))}

Hose:{' '} - { + core.mutateWs((ws) => { + ws.appearance.legs = parseInt(e.target.value) + }) + }} + > + {registry + .filter((entry) => entry[1].type == 'legs') + .map((entry) => ( + + ))}

Hautton:{' '} - { + core.mutateWs((ws) => { + ws.appearance.skin = parseInt(e.target.value) + }) + }} + > + {registry + .filter((entry) => entry[1].type == 'skin') + .map((entry) => ( + + ))}

@@ -89,6 +146,13 @@ export function AppearanceModal() { className="px-2 py-0.5 bg-green-200 hover:bg-green-300 rounded" onClick={() => { closeModal(core) + submit_event(`select_appearance_${core.ws.appearance.cap}`, core) + submit_event(`select_appearance_${core.ws.appearance.skin}`, core) + submit_event( + `select_appearance_${core.ws.appearance.shirt}`, + core + ) + submit_event(`select_appearance_${core.ws.appearance.legs}`, core) }} > Schließen diff --git a/components/pages/Overview.tsx b/components/pages/Overview.tsx index 375634ea..bb415684 100644 --- a/components/pages/Overview.tsx +++ b/components/pages/Overview.tsx @@ -29,6 +29,7 @@ import { resetStorage, } from '../../lib/storage/storage' import { HFullStyles } from '../helper/HFullStyles' +import { appearanceRegistry } from '../../lib/data/appearance' export function Overview() { const core = useCore() @@ -134,6 +135,21 @@ export function Overview() { abgeschlossen

))} +

Aussehen

+

+ {(() => { + 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}) + + )) + })()} +

Legacy

{' '} {Object.entries(core.ws.analyze.legacy).map((entry, i) => (

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 { dimY: number data: T[][] } + +export interface AppearanceData { + type: 'cap' | 'skin' | 'shirt' | 'legs' + title: string + position: number +} diff --git a/public/appearance/4.png b/public/appearance/4.png new file mode 100644 index 00000000..5f18afa2 Binary files /dev/null and b/public/appearance/4.png differ diff --git a/public/appearance/5.png b/public/appearance/5.png new file mode 100644 index 00000000..7f172dd4 Binary files /dev/null and b/public/appearance/5.png differ diff --git a/public/appearance/6.png b/public/appearance/6.png new file mode 100644 index 00000000..b2f36089 Binary files /dev/null and b/public/appearance/6.png differ diff --git a/public/appearance/7.png b/public/appearance/7.png new file mode 100644 index 00000000..092dc615 Binary files /dev/null and b/public/appearance/7.png differ diff --git a/public/appearance/8.png b/public/appearance/8.png new file mode 100644 index 00000000..a297a3e7 Binary files /dev/null and b/public/appearance/8.png differ diff --git a/public/appearance/9.png b/public/appearance/9.png new file mode 100644 index 00000000..cca77424 Binary files /dev/null and b/public/appearance/9.png differ diff --git a/public/robot_outline.png b/public/robot_outline.png index c046f921..3fe7e00c 100644 Binary files a/public/robot_outline.png and b/public/robot_outline.png differ