diff --git a/site/src/components/GameStatus.vue b/site/src/components/GameStatus.vue
index 918fe55..bc0729c 100644
--- a/site/src/components/GameStatus.vue
+++ b/site/src/components/GameStatus.vue
@@ -1,6 +1,6 @@
-
+
{{ c.text }}
@@ -8,6 +8,11 @@
+
+
+ {{ shellList }}
+
+
@@ -21,30 +26,51 @@ export interface Props {
const props = defineProps();
-// TODO(zeph): simplify this condition, this should just come in the game state
-const gameOn = computed(() => props.game.round < 3 || props.game.players.every((p) => p.hp > 0))
-
const roundChips = computed(() => [
{ text: "I", variant: props.game.round === 1 ? 'elevated' : undefined },
{ text: "II", variant: props.game.round === 2 ? 'elevated' : undefined },
{ text: "III", variant: props.game.round === 3 ? 'elevated' : undefined },
-] as const)
+] as const);
-// TODO(zeph): this probably should just be handled by the server and sent in the dto
-const msg = ref('');
-watch(props.game, (now, was) => {
- if (now.live != null && was?.live == null) {
- msg.value = `THE SHOTGUN CONTAINS ${now.live} LIVE AND ${now.blank} BLANK SHELLS`;
- } else if (was == null) {
- msg.value = 'THE GAME BEGINS';
- } else if (now.damage === 2 && was.damage !== 2) {
- msg.value = 'THE BARREL HAS BEEN SHORTENED';
- } else if (now.shell != null && was.shell == null) {
- msg.value = `THE CURRENT SHELL IS ${now.shell ? 'LIVE' : 'BLANK'}`;
- } else if (now.previous != null && was.previous == null) {
- msg.value = `A ${now.previous ? 'LIVE' : 'BLANK'} SHELL CLATTERS ON THE TABLE`;
- } else {
- msg.value = 'THE GAME CONTINUES';
+const actionMessages: Record string> = {
+ Start: () => "THE MATCH BEGINS",
+ Shoot: (game) => game.previous ? "THE PAIN..." : "A BLANK CLATTERS ON THE TABLE",
+ GameEnd: () => "THE DEALER RELOADS THE SHOTGUN",
+ BeerGameEnd: () => "THE LAST SHELL CLATTERS ON THE TABLE",
+ ChallengerWins: (game) => game.round < 3 ? "THE DEALER FALLS... BRIEFLY" : "THE DEALER FALLS... FOREVER",
+ DealerWins: () => "THE CHALLENGER FALLS",
+ Lens: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} PEERS INTO THE CHAMBER`,
+ Cig: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} TAKES A DRAG`,
+ Beer: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} TAKES A SIP AND A ${game.previous ? "LIVE SHELL" : "BLANK"} CLATTERS ON THE TABLE`,
+ Cuff: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} HANDS CUFFS ACROSS THE TABLE`,
+ Knife: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} CUTS THE BARREL SHORT`,
+ DealerConcedes: () => `THE DEALER SUDDENLY TURNS TO DUST`,
+ ChallengerConcedes: () => `THE CHALLENGER SUDDENLY TURNS TO DUST`,
+}
+
+const msg = computed(() => {
+ const f = actionMessages[props.game.action];
+ if (f == null) {
+ return "THE SERVER MISBEHAVES... WHAT?";
}
-}, { immediate: true })
+ return f(props.game);
+});
+
+const shellList = ref([]);
+watch(props.game, (game) => {
+ if (game.live == null || game.blank == null) {
+ shellList.value = [];
+ return;
+ }
+ const l = [...Array(game.live).fill('🟥'), ...Array(game.blank).fill('🟦')];
+ shuffle(l);
+ shellList.value = [...l, ...Array(8 - game.live - game.blank).fill('⬛')];
+});
+
+function shuffle(l: Elem[]) {
+ for (let i = l.length - 1; i > 0; i--) {
+ const j = Math.floor(Math.random() * i);
+ [l[i], l[j]] = [l[j], l[i]];
+ }
+}