From 25cf8a55e909782c9c1499ea09ced5dfad408bd3 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Wed, 3 Jul 2024 23:27:10 +0200 Subject: [PATCH] Feat : various fixes, sounds and multiplayer additions --- components/AnimatedBackground.vue | 35 +-- .../{CardOverlay.vue => CardOverlay.disabled} | 0 components/CardPreview.vue | 267 ++++++++++-------- components/CardsGrouped.vue | 25 +- components/MarketCards.vue | 7 +- components/PlayerIcon.vue | 43 +-- components/PlayerListElement.vue | 169 +++++------ components/PlayerSlot.vue | 9 +- components/PlayerStats.vue | 18 +- netcode/index.ts | 24 +- netcode/interfaces.ts | 7 + pages/game/[id].vue | 78 +++-- pages/lobby.vue | 14 +- public/sounds/distribute.mp3 | 3 + public/sounds/lock.mp3 | 3 + public/sounds/shuffle.mp3 | 3 + 16 files changed, 433 insertions(+), 272 deletions(-) rename components/{CardOverlay.vue => CardOverlay.disabled} (100%) create mode 100644 public/sounds/distribute.mp3 create mode 100644 public/sounds/lock.mp3 create mode 100644 public/sounds/shuffle.mp3 diff --git a/components/AnimatedBackground.vue b/components/AnimatedBackground.vue index f7df75f..10462b8 100644 --- a/components/AnimatedBackground.vue +++ b/components/AnimatedBackground.vue @@ -15,17 +15,15 @@ const canvas = ref(null); const canvas_resize_temp = ref(null); export interface Props { - colorStart?: [number, number, number]; - colorEnd?: [number, number, number]; + isTurn?: boolean; } const props = withDefaults(defineProps(), { - colorStart: () => [0, 0.3, 0], - colorEnd: () => [0, 1, 0], + isTurn: () => false, }); -const _colorStart = reactive(props.colorStart); -const _colorEnd = reactive(props.colorEnd); +const _colorStart = reactive([0, 0.3, 0]); +const _colorEnd = reactive([0, 1, 0]); function initShader() { return new Promise((resolve, reject) => { @@ -119,15 +117,19 @@ watch( } ); -// watch(() => [props.game.currentTurn], () => { -// if (props.game.teams.find() != goStore.self?.team) { -// gsap.to(_colorStart, { duration: 0.5, 0: 0, 1: .2, 2: .3 }) -// gsap.to(_colorEnd, { duration: 0.5, 0: 0, 1: 1, 2: 1 }) -// } else { -// gsap.to(_colorStart, { duration: 0.5, 0: 0, 1: .3, 2: 0 }) -// gsap.to(_colorEnd, { duration: 0.5, 0: 0, 1: 1, 2: 0 }) -// } -// }, { immediate: true }) +watch( + () => [props.isTurn], + () => { + if (props.isTurn) { + gsap.to(_colorStart, { duration: 0.5, 0: 0, 1: 0.3, 2: 0 }); + gsap.to(_colorEnd, { duration: 0.5, 0: 0, 1: 1, 2: 0 }); + } else { + gsap.to(_colorStart, { duration: 0.5, 0: 0, 1: 0.2, 2: 0.3 }); + gsap.to(_colorEnd, { duration: 0.5, 0: 0, 1: 1, 2: 1 }); + } + }, + { immediate: true } +); watch([_colorEnd, _colorStart], () => { recolorShader(); @@ -153,8 +155,7 @@ onUnmounted(() => { :class="{ pixelated: settingsStore.shaderPixelated }" width="480" height="270" - >test + > \ No newline at end of file + diff --git a/components/CardsGrouped.vue b/components/CardsGrouped.vue index c6039cb..b6a3a33 100644 --- a/components/CardsGrouped.vue +++ b/components/CardsGrouped.vue @@ -55,13 +55,24 @@ function endAnimation() { animationCallbacks.value.forEach((p) => p()); } -containerEvents.set(props.container._id, { - populateContainer, - shuffleContainer, - getCardsPosition, - startAnimation, - endAnimation, -}); +watch( + props.container, + (newValue, oldValue) => { + if (oldValue) { + containerEvents.delete(oldValue._id); + } + if (newValue) { + containerEvents.set(newValue._id, { + populateContainer, + shuffleContainer, + getCardsPosition, + startAnimation, + endAnimation, + }); + } + }, + { immediate: true } +); async function onEnter(_el: any, done: () => void) { animationCallbacks.value.push(done); diff --git a/components/MarketCards.vue b/components/MarketCards.vue index c6ebe88..90a757f 100644 --- a/components/MarketCards.vue +++ b/components/MarketCards.vue @@ -3,6 +3,7 @@ import type { Container } from "~/netcode/interfaces"; export interface Props { market: Container; + marketStack: Container; fire_gems: Container; } @@ -28,7 +29,11 @@ function fireGemCardClick(e: string) {