logigate/app/components/editor/MenuChallenges.vue

42 lines
1.9 KiB
Vue

<script setup lang="ts">
// The challenges page of the title menu: the puzzle of the week and every
// challenge on its own, all open, played in one "Challenges" project.
import { CHALLENGES } from '~/lib/logic/challenges'
import { weekKey } from '~/lib/logic/puzzles'
const ed = useEditor()
const p = ed.projectOf('challenges')
const solved = new Set(p?.solved ?? [])
const week = Number(weekKey().split('-')[1])
</script>
<template>
<div>
<div class="menu-card weekly-card">
<div class="flex items-center gap-3">
<Icon name="lucide:calendar-days" class="size-6 shrink-0 text-(--accent)" />
<div class="grow">
<div class="font-semibold">Puzzle of the week {{ week }}</div>
<p>A new logic puzzle every Monday, the same for everyone. Fewest transistors wins.</p>
</div>
<button class="btn btn-primary" @click="ed.playWeekly()"><Icon name="lucide:play" class="size-4" /> Play</button>
</div>
</div>
<p class="hint mt-4">Each one is a part to build from NAND gates and the parts you made before. Press Check when it works; fewer transistors is better.</p>
<ul class="menu-grid">
<li v-for="c in CHALLENGES" :key="c.id" :class="{ solved: solved.has(c.id) }">
<button class="menu-tile" @click="ed.playChallenge(c)">
<span class="flex items-center gap-2">
<Icon :name="solved.has(c.id) ? 'lucide:circle-check' : 'lucide:circle'" class="size-4 shrink-0" :class="solved.has(c.id) ? 'text-(--on)' : 'text-(--muted)'" />
<span class="grow font-semibold">{{ c.name }}</span>
<span v-if="p?.best?.[c.id] !== undefined" class="tabular-nums text-xs text-(--muted)" title="Your best">{{ p.best[c.id] }} transistors</span>
</span>
<span class="goal">{{ c.goal }}</span>
<span class="pins">{{ c.inputs.join(', ') }} → {{ c.outputs.join(', ') }}</span>
</button>
</li>
</ul>
</div>
</template>