From b973a557fd8558955d7d2af52024c1ec7989f234 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Mon, 7 Apr 2025 23:48:36 +0200 Subject: [PATCH 1/7] 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/7] 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/7] 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/7] 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 @@ + From ecb6f47702617c7f1cf4553d9a6529490d481ed4 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Tue, 8 Apr 2025 01:13:29 +0200 Subject: [PATCH 5/7] Add tooltips and descriptions for each card --- components/Object/Card/ObjectCard.vue | 53 +++++++++++++++++--- content.config.ts | 1 + content/cards/asteroid.json | 1 + content/cards/asteroidField.json | 1 + content/cards/baby.json | 1 + content/cards/brainrot.json | 1 + content/cards/distressSignal.json | 1 + content/cards/duck.json | 1 + content/cards/fire-extinguisher.json | 1 + content/cards/fire.json | 1 + content/cards/fluxGenerator.json | 1 + content/cards/fuel.json | 1 + content/cards/helmsman.json | 1 + content/cards/helmsmanInstructor.json | 1 + content/cards/hyperdrive.json | 1 + content/cards/medic.json | 1 + content/cards/medicInstructor.json | 1 + content/cards/merchant.json | 1 + content/cards/metal.json | 1 + content/cards/miner.json | 1 + content/cards/minerInstructor.json | 1 + content/cards/money.json | 1 + content/cards/pirate.json | 71 ++------------------------- content/cards/radar.json | 1 + content/cards/radarBroken.json | 1 + content/cards/rocket.json | 1 + content/cards/shipwreck.json | 1 + content/cards/soldier.json | 1 + content/cards/soldierInstructor.json | 1 + content/cards/trade.json | 1 + content/cards/tradeLink.json | 1 + content/cards/tradeLinkBroken.json | 1 + content/cards/worker.json | 1 + 33 files changed, 79 insertions(+), 76 deletions(-) diff --git a/components/Object/Card/ObjectCard.vue b/components/Object/Card/ObjectCard.vue index b094d98..d87b24a 100644 --- a/components/Object/Card/ObjectCard.vue +++ b/components/Object/Card/ObjectCard.vue @@ -1,18 +1,55 @@ diff --git a/content.config.ts b/content.config.ts index a5d9bdb..8cb7ec5 100644 --- a/content.config.ts +++ b/content.config.ts @@ -28,6 +28,7 @@ export default defineContentConfig({ identifier: z.string(), extend: z.string().optional(), label: z.string(), + description: z.string(), icon: z.string().default('material-symbols:man-rounded'), iconColor: z.string().optional().default('#000000'), health: z.number().gte(0).lte(20).optional(), diff --git a/content/cards/asteroid.json b/content/cards/asteroid.json index 0266edf..a1ae7cc 100644 --- a/content/cards/asteroid.json +++ b/content/cards/asteroid.json @@ -1,6 +1,7 @@ { "identifier": "asteroid", "label": "Asteroid", + "description": "A small asteroid. Destroys a random card on impact and can be mined to get metal", "icon": "tabler:meteor", "health": 10, "type": "enemy", diff --git a/content/cards/asteroidField.json b/content/cards/asteroidField.json index 2025802..85c8597 100644 --- a/content/cards/asteroidField.json +++ b/content/cards/asteroidField.json @@ -1,5 +1,6 @@ { "identifier": "asteroid-field", + "description": "Can be mined to get a bunch of metal. Disappears after some time", "label": "Asteroid Field", "icon": "mdi:focus-field", "type": "event", diff --git a/content/cards/baby.json b/content/cards/baby.json index 0552f7d..a086999 100644 --- a/content/cards/baby.json +++ b/content/cards/baby.json @@ -1,6 +1,7 @@ { "identifier": "baby", "label": "Baby", + "description": "Small human. Will grow to be a large human.", "icon": "hugeicons:baby-02", "health": 2, "type": "person", diff --git a/content/cards/brainrot.json b/content/cards/brainrot.json index a6aef66..a8c4183 100644 --- a/content/cards/brainrot.json +++ b/content/cards/brainrot.json @@ -1,6 +1,7 @@ { "identifier": "brainrot", "label": "Brainrot", + "description": "What the sigma? Bruh, this will uneducate anyone! No cap.", "icon": "mdi:brain", "type": "limitedUsage", "buyable": true, diff --git a/content/cards/distressSignal.json b/content/cards/distressSignal.json index f94f91b..2647fd8 100644 --- a/content/cards/distressSignal.json +++ b/content/cards/distressSignal.json @@ -1,6 +1,7 @@ { "identifier": "distress-signal", "label": "Distress Signal", + "description": "Someone needs our help! Or is it a trap?", "icon": "oui:security-signal-detected", "type": "event", "interactions": [ diff --git a/content/cards/duck.json b/content/cards/duck.json index 51c90bc..550822e 100644 --- a/content/cards/duck.json +++ b/content/cards/duck.json @@ -1,6 +1,7 @@ { "identifier": "duck", "label": "Duck", + "description": "Quack.", "icon": "icon-park-outline:duck", "type": "person", "buyable": true, diff --git a/content/cards/fire-extinguisher.json b/content/cards/fire-extinguisher.json index 0df7598..545ad87 100644 --- a/content/cards/fire-extinguisher.json +++ b/content/cards/fire-extinguisher.json @@ -1,6 +1,7 @@ { "identifier": "fire-extinguisher", "label": "Fire Extinguisher", + "description": "This can safely extinguish fires. It's a bit expensive though.", "icon": "material-symbols:fire-extinguisher-outline", "type": "limitedUsage", "health": 3, diff --git a/content/cards/fire.json b/content/cards/fire.json index af98bd4..2b01664 100644 --- a/content/cards/fire.json +++ b/content/cards/fire.json @@ -1,6 +1,7 @@ { "identifier": "fire", "label": "Fire", + "description": "It's a fire! Don't throw fuel at it!", "icon": "noto-v1:fire", "health": 10, "type": "enemy", diff --git a/content/cards/fluxGenerator.json b/content/cards/fluxGenerator.json index 5519a8f..e485fb9 100644 --- a/content/cards/fluxGenerator.json +++ b/content/cards/fluxGenerator.json @@ -1,6 +1,7 @@ { "identifier": "flux-generator", "label": "Flux Generator", + "description": "An endless, if slow, source of fuel. Can be used to power the ship.", "icon": "file-icons:flux", "type": "static", "interactions": [ diff --git a/content/cards/fuel.json b/content/cards/fuel.json index 3846d5f..fd3be2d 100644 --- a/content/cards/fuel.json +++ b/content/cards/fuel.json @@ -1,6 +1,7 @@ { "identifier": "fuel", "label": "Fuel", + "description": "Can be used to power the rocket. Can be stacked and sold for money!", "icon": "solar:battery-charge-minimalistic-outline", "type": "resource", "amount": 1, diff --git a/content/cards/helmsman.json b/content/cards/helmsman.json index 7ae68a7..450edbb 100644 --- a/content/cards/helmsman.json +++ b/content/cards/helmsman.json @@ -2,6 +2,7 @@ "identifier": "helmsman", "extend": "worker", "label": "Helmsman", + "description": "A specialized worker. Is more efficent when controlling the ship than a worker.", "icon": "custom:helmsman", "strength": 4, "health": 20, diff --git a/content/cards/helmsmanInstructor.json b/content/cards/helmsmanInstructor.json index 9f40053..371af91 100644 --- a/content/cards/helmsmanInstructor.json +++ b/content/cards/helmsmanInstructor.json @@ -2,6 +2,7 @@ "identifier": "helmsman-instructor", "extend": "worker", "label": "Helmsman Instr.", + "description": "Can be used to teach workers how to be helmsmans", "icon": "custom:helmsman-instructor", "strength": 4, "health": 20, diff --git a/content/cards/hyperdrive.json b/content/cards/hyperdrive.json index 899f4bb..a522fe4 100644 --- a/content/cards/hyperdrive.json +++ b/content/cards/hyperdrive.json @@ -1,6 +1,7 @@ { "identifier": "hyperdrive", "label": "Hyperdrive", + "description": "Fast-Travel in space! Moves the ship a great deal forward to reach the goal!", "icon": "game-icons:hypersonic-bolt", "type": "limitedUsage", "buyable": true, diff --git a/content/cards/medic.json b/content/cards/medic.json index 7822697..506b74e 100644 --- a/content/cards/medic.json +++ b/content/cards/medic.json @@ -1,6 +1,7 @@ { "identifier": "medic", "extend": "worker", + "description": "A specialized worker. Can be used to heal other workers.", "label": "Medic", "icon": "custom:medic", "health": 15, diff --git a/content/cards/medicInstructor.json b/content/cards/medicInstructor.json index 98d7444..67b3668 100644 --- a/content/cards/medicInstructor.json +++ b/content/cards/medicInstructor.json @@ -2,6 +2,7 @@ "identifier": "medic-instructor", "extend": "worker", "label": "Medic Instr.", + "description": "Can be used to teach workers how to be medics", "icon": "custom:medic-instructor", "health": 15, "strength": 2, diff --git a/content/cards/merchant.json b/content/cards/merchant.json index bd3bf08..71e478e 100644 --- a/content/cards/merchant.json +++ b/content/cards/merchant.json @@ -1,6 +1,7 @@ { "identifier": "merchant", "label": "Merchant", + "description": "Brings a lot of goods. Disappers after a while. Drop stuff at him to get money!", "icon": "arcticons:family-space", "type": "merchant", "interactions": [ diff --git a/content/cards/metal.json b/content/cards/metal.json index 5c178c4..4f72606 100644 --- a/content/cards/metal.json +++ b/content/cards/metal.json @@ -1,6 +1,7 @@ { "identifier": "metal", "label": "Metal", + "description": "Requires to repair broken parts. Can be stacked and sold for money!", "icon": "icon-park-outline:heavy-metal", "type": "resource", "amount": 1, diff --git a/content/cards/miner.json b/content/cards/miner.json index d7b28c7..e3d8da1 100644 --- a/content/cards/miner.json +++ b/content/cards/miner.json @@ -2,6 +2,7 @@ "identifier": "miner", "extend": "worker", "label": "Miner", + "description": "A specialized worker. Is more efficent when mining than a worker.", "icon": "custom:miner", "health": 22, "strength": 6, diff --git a/content/cards/minerInstructor.json b/content/cards/minerInstructor.json index fbb6889..cc3b8d1 100644 --- a/content/cards/minerInstructor.json +++ b/content/cards/minerInstructor.json @@ -2,6 +2,7 @@ "identifier": "miner-instructor", "extend": "worker", "label": "Miner Instr.", + "description": "Can be used to teach workers how to be miners", "icon": "custom:miner-instructor", "health": 22, "strength": 6, diff --git a/content/cards/money.json b/content/cards/money.json index b794fd1..1042673 100644 --- a/content/cards/money.json +++ b/content/cards/money.json @@ -2,6 +2,7 @@ "identifier": "money", "label": "Money", "icon": "material-symbols:money-bag-outline", + "description": "'I love money!!' - Mr Crabs", "type": "resource", "amount": 1, "interactions": [ diff --git a/content/cards/pirate.json b/content/cards/pirate.json index 80c2e1e..4fbd5f5 100644 --- a/content/cards/pirate.json +++ b/content/cards/pirate.json @@ -1,6 +1,7 @@ { "identifier": "pirate", "label": "Space-Pirate", + "description": "Can be attacked! If ignored for too long, will run away and destroying a random card on its way!", "icon": "game-icons:pirate-skull", "health": 25, "type": "enemy", @@ -20,7 +21,7 @@ { "card": "soldier", "infinite": true, - "time": 3, + "time": 2, "showHealthInsteadOfTime": true, "actions": [ { @@ -31,73 +32,7 @@ { "card": "soldier-instructor", "infinite": true, - "time": 3, - "showHealthInsteadOfTime": true, - "actions": [ - { - "type": "fight" - } - ] - }, - { - "card": "helmsman", - "infinite": true, - "time": 3, - "showHealthInsteadOfTime": true, - "actions": [ - { - "type": "fight" - } - ] - }, - { - "card": "helmsman-instructor", - "infinite": true, - "time": 3, - "showHealthInsteadOfTime": true, - "actions": [ - { - "type": "fight" - } - ] - }, - { - "card": "miner", - "infinite": true, - "time": 3, - "showHealthInsteadOfTime": true, - "actions": [ - { - "type": "fight" - } - ] - }, - { - "card": "miner-instructor", - "infinite": true, - "time": 3, - "showHealthInsteadOfTime": true, - "actions": [ - { - "type": "fight" - } - ] - }, - { - "card": "medic", - "infinite": true, - "time": 3, - "showHealthInsteadOfTime": true, - "actions": [ - { - "type": "fight" - } - ] - }, - { - "card": "medic-instructor", - "infinite": true, - "time": 3, + "time": 2, "showHealthInsteadOfTime": true, "actions": [ { diff --git a/content/cards/radar.json b/content/cards/radar.json index aee2496..7c5c7d4 100644 --- a/content/cards/radar.json +++ b/content/cards/radar.json @@ -1,6 +1,7 @@ { "identifier": "radar", "label": "Radar", + "description": "Reveals the next event that is on jour journey! Has a cooldown", "icon": "mingcute:radar-2-line", "type": "building", "buyable": true, diff --git a/content/cards/radarBroken.json b/content/cards/radarBroken.json index 76401d2..d3082d7 100644 --- a/content/cards/radarBroken.json +++ b/content/cards/radarBroken.json @@ -1,6 +1,7 @@ { "identifier": "radar-broken", "label": "Broken Radar", + "description": "Requires 5 metal to be repaired", "icon": "mingcute:radar-2-line", "iconColor": "red", "type": "building", diff --git a/content/cards/rocket.json b/content/cards/rocket.json index e3058e8..58e3018 100644 --- a/content/cards/rocket.json +++ b/content/cards/rocket.json @@ -1,6 +1,7 @@ { "identifier": "rocket", "label": "Rocket", + "description": "Your glourious rocket! Can be used to travel the ship forward. Requires fuel.", "icon": "material-symbols:rocket-launch", "type": "static", "container": "fuel", diff --git a/content/cards/shipwreck.json b/content/cards/shipwreck.json index 8174367..de1b39d 100644 --- a/content/cards/shipwreck.json +++ b/content/cards/shipwreck.json @@ -1,6 +1,7 @@ { "identifier": "shipwreck", "label": "Shipwreck", + "description": "A shipwreck. We can loot it to get resources!", "icon": "custom:shipwreck", "type": "event", "interactions": [ diff --git a/content/cards/soldier.json b/content/cards/soldier.json index a9033f1..51b6c68 100644 --- a/content/cards/soldier.json +++ b/content/cards/soldier.json @@ -2,6 +2,7 @@ "identifier": "soldier", "extend": "worker", "label": "Soldier", + "description": "A specialized worker. Is more efficent when fighting than a worker.", "icon": "custom:soldier", "health": 30, "strength": 10, diff --git a/content/cards/soldierInstructor.json b/content/cards/soldierInstructor.json index 7e7dec0..0628ef5 100644 --- a/content/cards/soldierInstructor.json +++ b/content/cards/soldierInstructor.json @@ -2,6 +2,7 @@ "identifier": "soldier-instructor", "extend": "worker", "label": "Soldier Instr.", + "description": "Can be used to teach workers how to be soldiers", "icon": "custom:soldier-instructor", "health": 32, "strength": 11, diff --git a/content/cards/trade.json b/content/cards/trade.json index a1455fb..75153b5 100644 --- a/content/cards/trade.json +++ b/content/cards/trade.json @@ -2,6 +2,7 @@ "identifier": "trade", "label": "Trade", "icon": "material-symbols:storefront-outline", + "description": "Trades money for goods. Will disappear when the merchant goes away", "type": "merchant", "interactions": [ { diff --git a/content/cards/tradeLink.json b/content/cards/tradeLink.json index 3c1be07..2e0bb26 100644 --- a/content/cards/tradeLink.json +++ b/content/cards/tradeLink.json @@ -1,6 +1,7 @@ { "identifier": "trade-link", "label": "Trade Link", + "description": "Calls a merchant to trade with. Has a cooldown", "icon": "carbon:connection-signal", "type": "building", "health": 1, diff --git a/content/cards/tradeLinkBroken.json b/content/cards/tradeLinkBroken.json index 2eec523..c4a57c9 100644 --- a/content/cards/tradeLinkBroken.json +++ b/content/cards/tradeLinkBroken.json @@ -1,6 +1,7 @@ { "identifier": "trade-link-broken", "label": "Broken Trade Link", + "description": "Requires 5 metal to be repaired", "icon": "carbon:connection-signal-off", "iconColor": "red", "type": "building", diff --git a/content/cards/worker.json b/content/cards/worker.json index ccde3b8..8831721 100644 --- a/content/cards/worker.json +++ b/content/cards/worker.json @@ -1,6 +1,7 @@ { "identifier": "worker", "label": "Worker", + "description": "Can do nearly anything. Can be specialized using instructors", "icon": "material-symbols:man-rounded", "health": 20, "type": "person", From 3044987b5e13e2a50682830a17bceed0703667b2 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Tue, 8 Apr 2025 02:05:56 +0200 Subject: [PATCH 6/7] Fix some issues --- components/Object/Card/ObjectCard.vue | 53 +++------------ components/Object/Card/ObjectCardDeck.vue | 54 ++++++++++++--- .../Object/Card/ObjectCardDeckStacked.vue | 60 +++++++++++++---- components/Object/Card/ObjectCardSingle.vue | 66 ++++++++++++++----- composables/useCardTimer.ts | 1 + composables/useInteraction.ts | 6 +- stores/BoardStore.ts | 1 + types/Board.d.ts | 1 + 8 files changed, 160 insertions(+), 82 deletions(-) diff --git a/components/Object/Card/ObjectCard.vue b/components/Object/Card/ObjectCard.vue index d87b24a..b094d98 100644 --- a/components/Object/Card/ObjectCard.vue +++ b/components/Object/Card/ObjectCard.vue @@ -1,55 +1,18 @@ diff --git a/components/Object/Card/ObjectCardDeck.vue b/components/Object/Card/ObjectCardDeck.vue index 466847a..20917ff 100644 --- a/components/Object/Card/ObjectCardDeck.vue +++ b/components/Object/Card/ObjectCardDeck.vue @@ -8,6 +8,7 @@ const props = defineProps<{ // Stores const boardStore = useBoardStore() const levelStore = useLevelStore() +const cardStore = useCardStore() // Handle dragging card decks const hoveringOverBottomCard = ref(false) @@ -57,16 +58,51 @@ const { getVisualComponentName } = useCardVisual() :model-value="boardCard.currentHealth" :max="boardCard.card.health" /> -
- -
+
+ +
+ + + { diff --git a/components/Object/Card/ObjectCardSingle.vue b/components/Object/Card/ObjectCardSingle.vue index f56d7f6..5343e61 100644 --- a/components/Object/Card/ObjectCardSingle.vue +++ b/components/Object/Card/ObjectCardSingle.vue @@ -8,6 +8,7 @@ const props = defineProps<{ // Use stores & composables const boardStore = useBoardStore() const levelStore = useLevelStore() +const cardStore = useCardStore() const { activeCard } = storeToRefs(boardStore) // This is the card, the user is currently hovering above const { hasInteractionWith, interact } = useInteraction(props.boardCard) @@ -96,20 +97,55 @@ watch(playState, (state) => { diff --git a/composables/useCardTimer.ts b/composables/useCardTimer.ts index 44f2296..be0e420 100644 --- a/composables/useCardTimer.ts +++ b/composables/useCardTimer.ts @@ -12,6 +12,7 @@ export const useCardTimer = () => { card.timerTimeoutId = setTimeout(() => { assert(card.card.timer?.actions !== undefined, `Card '${card.card.label}' with timer needs actions`) + if (card.isDead) return runActions(card.card.timer.actions, card, card) }, (card.card.timer.time ?? 0) * 1000) diff --git a/composables/useInteraction.ts b/composables/useInteraction.ts index ce97e99..fbc58ee 100644 --- a/composables/useInteraction.ts +++ b/composables/useInteraction.ts @@ -78,7 +78,7 @@ export const useInteraction = (draggingCard: BoardCard) => { runActions(boardCard.currentInteraction.actions, boardCard, draggingCard) - if (boardCard.currentInteraction.consumeContainer && boardCard.amount !== null) { + if (boardCard.currentInteraction?.consumeContainer && boardCard.amount !== null) { boardCard.amount = clamp(boardCard.amount - 1, 0, boardCard.card.containerMax ?? 0) } @@ -89,6 +89,8 @@ export const useInteraction = (draggingCard: BoardCard) => { if (boardCard.currentHealth !== null && boardCard.currentHealth <= 0) { runActions(boardCard.card.onDeath ?? [], boardCard, draggingCard) boardStore.removeCard(boardCard) + boardCard.isDead = true + reset(boardCard) someoneDied = true } @@ -96,6 +98,8 @@ export const useInteraction = (draggingCard: BoardCard) => { if (draggingCard.currentHealth !== null && draggingCard.currentHealth <= 0) { runActions(draggingCard.card.onDeath ?? [], boardCard, draggingCard) boardStore.removeCard(draggingCard) + draggingCard.isDead = true + reset(draggingCard) someoneDied = true } diff --git a/stores/BoardStore.ts b/stores/BoardStore.ts index 5ede6e9..cbce71f 100644 --- a/stores/BoardStore.ts +++ b/stores/BoardStore.ts @@ -21,6 +21,7 @@ export const useBoardStore = defineStore('board', () => { x: cX, z: cY, isNew, + isDead: false, currentHealth: card.health ?? null, amount: card.amount ? (amount ?? card.amount) diff --git a/types/Board.d.ts b/types/Board.d.ts index 33406ca..239aba4 100644 --- a/types/Board.d.ts +++ b/types/Board.d.ts @@ -21,6 +21,7 @@ export type BoardCard = { // Mark this card as a new card isNew: boolean + isDead: boolean // Handle timed interactions interactionTimeoutId?: ReturnType From 90cd672c5384954baf8a6c2750dcdd2279891249 Mon Sep 17 00:00:00 2001 From: Jordan Kniest Date: Tue, 8 Apr 2025 02:16:31 +0200 Subject: [PATCH 7/7] Allow to sell in stacks --- composables/actions/buy.ts | 17 +++++++++++++++++ composables/actions/destroyInteracting.ts | 14 ++++++++++++++ composables/useAction.ts | 4 ++++ content/cards/merchant.json | 12 ++++++++---- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 composables/actions/buy.ts create mode 100644 composables/actions/destroyInteracting.ts diff --git a/composables/actions/buy.ts b/composables/actions/buy.ts new file mode 100644 index 0000000..ba5e37a --- /dev/null +++ b/composables/actions/buy.ts @@ -0,0 +1,17 @@ +import type { CardsCollectionItem } from '@nuxt/content' +import type { BoardCard } from '~/types/Board' +import type { Action } from '~/types/Action' + +export const buy: Action = (action: CardsCollectionItem['interactions'][0]['actions'][0], baseCard: BoardCard, interactingCard: BoardCard) => { + const boardStore = useBoardStore() + const cardStore = useCardStore() + + assert(action.card !== undefined, 'Action `buy` requires the `card` property to be set!') + + const card = cardStore.getCardByIdentifier(action.card) + assert(card !== undefined, 'Card not found!') + assert(typeof action.amount === 'number', 'Action `buy` requires the `amount` property to be set to an number!') + + const { x, y } = getDropCoordinates(baseCard.x, baseCard.z) + boardStore.addCard(card, x, y, true, action.amount * (interactingCard.amount ?? 1)) +} diff --git a/composables/actions/destroyInteracting.ts b/composables/actions/destroyInteracting.ts new file mode 100644 index 0000000..5d90d11 --- /dev/null +++ b/composables/actions/destroyInteracting.ts @@ -0,0 +1,14 @@ +import type { CardsCollectionItem } from '@nuxt/content' +import type { BoardCard } from '~/types/Board' +import type { Action } from '~/types/Action' + +export const destroyInteracting: Action = (_action: CardsCollectionItem['interactions'][0]['actions'][0], baseCard: BoardCard, interactingCard: BoardCard) => { + const boardStore = useBoardStore() + + if (baseCard.stackedCard) { + const { x, y } = getDropCoordinates(baseCard.x, baseCard.z) + boardStore.unstackCard(baseCard.stackedCard, { x, y }) + } + + boardStore.removeCard(interactingCard) +} diff --git a/composables/useAction.ts b/composables/useAction.ts index 5a44ce1..7ba2010 100644 --- a/composables/useAction.ts +++ b/composables/useAction.ts @@ -14,6 +14,8 @@ import { destroyAll } from './actions/destroyAll' import { destroyRandom } from './actions/destroyRandom' import { random } from './actions/random' import { win } from './actions/win' +import { buy } from './actions/buy' +import { destroyInteracting } from './actions/destroyInteracting' import type { BoardCard } from '~/types/Board' import type { Action } from '~/types/Action' import { reveal } from '~/composables/actions/reveal' @@ -35,6 +37,8 @@ const allActions: { [key: string]: Action } = { random, reveal, win, + buy, + destroyInteracting, } export const useAction = () => { diff --git a/content/cards/merchant.json b/content/cards/merchant.json index 71e478e..44eecdd 100644 --- a/content/cards/merchant.json +++ b/content/cards/merchant.json @@ -7,23 +7,27 @@ "interactions": [ { "card": "metal", - "consume": true, "actions": [ { - "type": "spawn", + "type": "buy", "card": "money", "amount": 6 + }, + { + "type": "destroyInteracting" } ] }, { "card": "fuel", - "consume": true, "actions": [ { - "type": "spawn", + "type": "buy", "card": "money", "amount": 25 + }, + { + "type": "destroyInteracting" } ] }