From 3f0b57f87de0c25fb9e88dc57f932db5798e0fc3 Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Tue, 30 Jan 2024 22:39:24 -0600 Subject: [PATCH] display a message indicating game state changes --- site/src/App.vue | 12 ++++++---- site/src/components/GameStatus.vue | 37 ++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/site/src/App.vue b/site/src/App.vue index 3879758..5b26e31 100644 --- a/site/src/App.vue +++ b/site/src/App.vue @@ -25,14 +25,16 @@ const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi- const playing = ref(false); -const testGame: Game = { +const testGame = ref({ players: [ - { hp: 4, items: ['🔍', '', '', '', '', '', '', ''] }, - { hp: 3, items: ['🔍', '🔍', '', '', '', '', '', ''] }, + { hp: 4, items: ['🔍', '🔪', '', '', '', '', '', ''] }, + { hp: 3, items: ['👮', '🚬', '', '', '', '', '', ''] }, ], round: 1, dealer: true, damage: 1, - previous: true, -}; + previous: null, + live: 3, + blank: 4, +}); diff --git a/site/src/components/GameStatus.vue b/site/src/components/GameStatus.vue index d3d6d9f..918fe55 100644 --- a/site/src/components/GameStatus.vue +++ b/site/src/components/GameStatus.vue @@ -1,14 +1,19 @@ \ No newline at end of file + +// 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'; + } +}, { immediate: true }) +