From b973a557fd8558955d7d2af52024c1ec7989f234 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Mon, 7 Apr 2025 23:48:36 +0200 Subject: [PATCH 1/4] f --- content/cards/hyperdrive.json | 6 ++++-- content/cards/pirate.json | 13 ++++++++++++- content/cards/rocket.json | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/content/cards/hyperdrive.json b/content/cards/hyperdrive.json index 40c5f7a..899f4bb 100644 --- a/content/cards/hyperdrive.json +++ b/content/cards/hyperdrive.json @@ -24,7 +24,8 @@ "time": 3, "actions": [ { - "type": "travel" + "type": "travel", + "amount": 10 }, { "type": "destroy" @@ -36,7 +37,8 @@ "time": 3, "actions": [ { - "type": "travel" + "type": "travel", + "amount": 10 }, { "type": "destroy" diff --git a/content/cards/pirate.json b/content/cards/pirate.json index ec37fe2..eb0dd43 100644 --- a/content/cards/pirate.json +++ b/content/cards/pirate.json @@ -105,5 +105,16 @@ } ] } - ] + ], + "timer": { + "time": 12, + "actions": [ + { + "type": "destroy" + }, + { + "type": "destroyRandom" + } + ] + } } diff --git a/content/cards/rocket.json b/content/cards/rocket.json index 9ba93fa..3335767 100644 --- a/content/cards/rocket.json +++ b/content/cards/rocket.json @@ -26,6 +26,26 @@ "amount": 5 } ] + }, + { + "card": "helmsman", + "time": 5, + "actions": [ + { + "type": "travel", + "amount": 7 + } + ] + }, + { + "card": "helmsman-instructor", + "time": 5, + "actions": [ + { + "type": "travel", + "amount": 7 + } + ] } ] } From 34be5239f47efe10375bc5593a3c01f08cbcc5b7 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Mon, 7 Apr 2025 23:55:44 +0200 Subject: [PATCH 2/4] Add helsmman rocket stuff, fix index --- content/cards/rocket.json | 4 ++++ pages/index.vue | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/content/cards/rocket.json b/content/cards/rocket.json index 3335767..e3058e8 100644 --- a/content/cards/rocket.json +++ b/content/cards/rocket.json @@ -30,6 +30,8 @@ { "card": "helmsman", "time": 5, + "infinite": true, + "consumeContainer": true, "actions": [ { "type": "travel", @@ -40,6 +42,8 @@ { "card": "helmsman-instructor", "time": 5, + "infinite": true, + "consumeContainer": true, "actions": [ { "type": "travel", diff --git a/pages/index.vue b/pages/index.vue index 2f37f05..8cc77fe 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -28,15 +28,13 @@ watchOnce(container, () => { addPercentage('soldier', 10, 75) addPercentage('rocket', 50, 50) - addPercentage('trade-link-broken', 90, 75) + addPercentage('trade-link', 90, 50) - addPercentage('fuel', 35, 25, 3) + addPercentage('fuel', 45, 25, 3) addPercentage('money', 50, 25, 400) - addPercentage('metal', 50, 25, 5) + addPercentage('metal', 55, 25, 5) - addPercentage('flux-generator', 55, 80) - addPercentage('radar', 40, 100) - addPercentage('radar', 40, 100) + addPercentage('flux-generator', 50, 80) }) From ecdd3211b1700b7695ac2ef7022dc54ecc6a7001 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Tue, 8 Apr 2025 00:30:46 +0200 Subject: [PATCH 3/4] Reset timer when interacting with pirates --- composables/useCardTimer.ts | 8 ++++++++ composables/useInteraction.ts | 5 +++++ content.config.ts | 1 + content/cards/pirate.json | 1 + stores/BoardStore.ts | 4 ++++ 5 files changed, 19 insertions(+) diff --git a/composables/useCardTimer.ts b/composables/useCardTimer.ts index 25a9d9d..44f2296 100644 --- a/composables/useCardTimer.ts +++ b/composables/useCardTimer.ts @@ -25,7 +25,15 @@ export const useCardTimer = () => { }, 10) } + const reset = (card: BoardCard) => { + if (card.timerTimeoutId) clearTimeout(card.timerTimeoutId) + if (card.timerIntervalId) clearInterval(card.timerIntervalId) + + card.timerStartAt = card.timerFinishAt = card.timerProgress = card.timerTimeoutId = card.timerIntervalId = undefined + } + return { init, + reset, } } diff --git a/composables/useInteraction.ts b/composables/useInteraction.ts index 31a712c..ce97e99 100644 --- a/composables/useInteraction.ts +++ b/composables/useInteraction.ts @@ -6,6 +6,7 @@ export const useInteraction = (draggingCard: BoardCard) => { const boardStore = useBoardStore() const { runActions } = useAction() const { startCooldown } = useCardCooldown() + const { reset } = useCardTimer() const getAvailableInteractions = (boardCard: BoardCard): string[] => { return (boardCard.card.interactions ?? []).map(interaction => interaction.card) @@ -43,6 +44,10 @@ export const useInteraction = (draggingCard: BoardCard) => { } boardCard.currentInteraction = interaction + if (boardCard.card.timer?.resetWhenCardIsStacked) { + reset(boardCard) + } + if ((interaction.time ?? 0) <= 0) { runInteractionActions(boardCard) return diff --git a/content.config.ts b/content.config.ts index 7c7e98d..a5d9bdb 100644 --- a/content.config.ts +++ b/content.config.ts @@ -54,6 +54,7 @@ export default defineContentConfig({ onSpawn: actionsType, timer: z.object({ time: z.number().positive().default(0), + resetWhenCardIsStacked: z.boolean().default(false), actions: actionsType, }).optional(), }), diff --git a/content/cards/pirate.json b/content/cards/pirate.json index eb0dd43..80c2e1e 100644 --- a/content/cards/pirate.json +++ b/content/cards/pirate.json @@ -108,6 +108,7 @@ ], "timer": { "time": 12, + "resetWhenCardIsStacked": true, "actions": [ { "type": "destroy" diff --git a/stores/BoardStore.ts b/stores/BoardStore.ts index df8f120..5ede6e9 100644 --- a/stores/BoardStore.ts +++ b/stores/BoardStore.ts @@ -88,6 +88,10 @@ export const useBoardStore = defineStore('board', () => { card.parentCard.interactionTimeoutId = undefined card.parentCard.interactionFinishAt = undefined card.parentCard.currentInteraction = undefined + + if (card.parentCard.card.timer?.resetWhenCardIsStacked) { + init(card.parentCard) + } } function unstackCard(card: BoardCard, position: { x: number, y: number }) { From c7dff2f1e9d3b6d34f38b95c84883d3179777371 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Tue, 8 Apr 2025 00:43:39 +0200 Subject: [PATCH 4/4] Add win action --- composables/actions/win.ts | 7 +++++++ composables/useAction.ts | 2 ++ content/events/win.json | 6 +++++- pages/win.vue | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 composables/actions/win.ts create mode 100644 pages/win.vue diff --git a/composables/actions/win.ts b/composables/actions/win.ts new file mode 100644 index 0000000..aa70cc7 --- /dev/null +++ b/composables/actions/win.ts @@ -0,0 +1,7 @@ +import type { CardsCollectionItem } from '@nuxt/content' +import type { BoardCard } from '~/types/Board' +import type { Action } from '~/types/Action' + +export const win: Action = (_action: CardsCollectionItem['interactions'][0]['actions'][0], _baseCard: BoardCard, _interactingCard: BoardCard) => { + navigateTo('/win', { external: true }) +} diff --git a/composables/useAction.ts b/composables/useAction.ts index e43f084..5a44ce1 100644 --- a/composables/useAction.ts +++ b/composables/useAction.ts @@ -13,6 +13,7 @@ import { travel } from './actions/travel' import { destroyAll } from './actions/destroyAll' import { destroyRandom } from './actions/destroyRandom' import { random } from './actions/random' +import { win } from './actions/win' import type { BoardCard } from '~/types/Board' import type { Action } from '~/types/Action' import { reveal } from '~/composables/actions/reveal' @@ -33,6 +34,7 @@ const allActions: { [key: string]: Action } = { destroyRandom, random, reveal, + win, } export const useAction = () => { diff --git a/content/events/win.json b/content/events/win.json index c078274..0e575fe 100644 --- a/content/events/win.json +++ b/content/events/win.json @@ -3,5 +3,9 @@ "icon": "material-symbols:flag", "type": "positive", "hidden": true, - "actions": [] + "actions": [ + { + "type": "win" + } + ] } diff --git a/pages/win.vue b/pages/win.vue new file mode 100644 index 0000000..11c3787 --- /dev/null +++ b/pages/win.vue @@ -0,0 +1,19 @@ +