fds-vue-core 8.12.2 → 8.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/IconRescue/IconRescueIcon.vue.d.ts +3 -1
- package/dist/components/IconRescue/iconGame.d.ts +55 -5
- package/dist/components/IconRescue/iconTargets.d.ts +1 -12
- package/dist/components/IconRescue/types.d.ts +2 -2
- package/dist/composables/useCancellationRuleText.d.ts +4 -0
- package/dist/fds-vue-core.cjs.js +127 -42
- package/dist/fds-vue-core.cjs.js.map +1 -1
- package/dist/fds-vue-core.css +1 -1
- package/dist/fds-vue-core.es.js +124 -43
- package/dist/fds-vue-core.es.js.map +1 -1
- package/dist/helpers/cancellationRule.d.ts +22 -0
- package/dist/index.d.ts +4 -1
- package/dist/plugin/useFdsI18n.d.ts +2 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/components/IconRescue/IconRescue.stories.ts +175 -22
- package/src/components/IconRescue/IconRescueIcon.vue +623 -176
- package/src/components/IconRescue/iconGame.ts +67 -18
- package/src/components/IconRescue/iconTargets.ts +1 -20
- package/src/components/IconRescue/types.ts +2 -2
- package/src/composables/useCancellationRuleText.ts +14 -0
- package/src/helpers/cancellationRule.spec.ts +70 -0
- package/src/helpers/cancellationRule.ts +77 -0
- package/src/index.ts +13 -0
- package/src/lang/en.json +32 -20
- package/src/lang/sv.json +32 -20
- package/src/plugin/useFdsI18n.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fds-vue-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.13.0",
|
|
4
4
|
"description": "FDS Vue Core Component Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/fds-vue-core.cjs.js",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@chromatic-com/storybook": "5.6.0",
|
|
57
|
-
"@intlify/unplugin-vue-i18n": "11.2.
|
|
58
|
-
"@storybook/addon-a11y": "10.6.
|
|
59
|
-
"@storybook/addon-docs": "10.6.
|
|
60
|
-
"@storybook/addon-vitest": "10.6.
|
|
61
|
-
"@storybook/vue3": "10.6.
|
|
62
|
-
"@storybook/vue3-vite": "10.6.
|
|
57
|
+
"@intlify/unplugin-vue-i18n": "11.2.8",
|
|
58
|
+
"@storybook/addon-a11y": "10.6.5",
|
|
59
|
+
"@storybook/addon-docs": "10.6.5",
|
|
60
|
+
"@storybook/addon-vitest": "10.6.5",
|
|
61
|
+
"@storybook/vue3": "10.6.5",
|
|
62
|
+
"@storybook/vue3-vite": "10.6.5",
|
|
63
63
|
"@tailwindcss/vite": "4.3.3",
|
|
64
64
|
"@types/node": "22.20.4",
|
|
65
65
|
"@vitejs/plugin-vue": "6.0.10",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"fg-devkit": "1.27.2",
|
|
70
70
|
"happy-dom": "21.0.4",
|
|
71
71
|
"playwright": "1.64.1",
|
|
72
|
-
"storybook": "10.6.
|
|
72
|
+
"storybook": "10.6.5",
|
|
73
73
|
"tsx": "4.23.15",
|
|
74
74
|
"vite": "8.3.5",
|
|
75
75
|
"vite-plugin-dts": "5.1.2",
|
|
@@ -6,9 +6,11 @@ import IconRescueIcon from './IconRescueIcon.vue'
|
|
|
6
6
|
import {
|
|
7
7
|
allBossAttacks,
|
|
8
8
|
type BossAttack,
|
|
9
|
+
type EnemyKind,
|
|
9
10
|
defaultPlayerStats,
|
|
10
11
|
gameBalance,
|
|
11
12
|
getActiveSynergies,
|
|
13
|
+
getElectricShockChainCount,
|
|
12
14
|
getWaveStrength,
|
|
13
15
|
iconRescueHosts,
|
|
14
16
|
maxWeaponLevel,
|
|
@@ -48,7 +50,7 @@ const finalWave = 130
|
|
|
48
50
|
const bossWaveInterval = 10
|
|
49
51
|
|
|
50
52
|
const weaponInfo: Record<WeaponId, { name: string; description: string }> = {
|
|
51
|
-
laser: { name: 'Laser', description: 'Your trusty laser does more damage
|
|
53
|
+
laser: { name: 'Laser', description: 'Your trusty laser does more damage and shoots faster' },
|
|
52
54
|
rockets: { name: 'Rockets', description: 'Homing rockets that explode and hit everything nearby' },
|
|
53
55
|
fireballs: { name: 'Fireballs', description: 'Fireballs circle around you and set enemies on fire' },
|
|
54
56
|
iceAsteroids: { name: 'Ice asteroids', description: 'Ice chunks fly out in all directions and freeze enemies' },
|
|
@@ -62,7 +64,7 @@ const synergyInfo: Record<SynergyId, { name: string; description: string }> = {
|
|
|
62
64
|
plasmaLaser: { name: 'Plasma laser', description: 'Every laser hit jumps to a nearby enemy' },
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
type PassiveId = 'power' | 'vitality' | 'agility' | 'overclock' | 'precision' | '
|
|
67
|
+
type PassiveId = 'power' | 'vitality' | 'agility' | 'overclock' | 'precision' | 'piercing'
|
|
66
68
|
|
|
67
69
|
const passiveInfo: Record<
|
|
68
70
|
PassiveId,
|
|
@@ -102,10 +104,13 @@ const passiveInfo: Record<
|
|
|
102
104
|
criticalHitChance: Math.round((stats.criticalHitChance + amount) * 100) / 100,
|
|
103
105
|
}),
|
|
104
106
|
},
|
|
105
|
-
|
|
106
|
-
name: '
|
|
107
|
-
description:
|
|
108
|
-
apply: (stats, amount) => ({
|
|
107
|
+
piercing: {
|
|
108
|
+
name: 'Piercing',
|
|
109
|
+
description: `+${gameBalance.upgrades.piercing.amount * 100}% chance for the laser to go through an enemy`,
|
|
110
|
+
apply: (stats, amount) => ({
|
|
111
|
+
...stats,
|
|
112
|
+
pierceChance: Math.round((stats.pierceChance + amount) * 100) / 100,
|
|
113
|
+
}),
|
|
109
114
|
},
|
|
110
115
|
}
|
|
111
116
|
|
|
@@ -115,7 +120,7 @@ const startingPassiveLevels: Record<PassiveId, number> = {
|
|
|
115
120
|
agility: 0,
|
|
116
121
|
overclock: 0,
|
|
117
122
|
precision: 0,
|
|
118
|
-
|
|
123
|
+
piercing: 0,
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
interface WaveEnemy {
|
|
@@ -125,7 +130,7 @@ interface WaveEnemy {
|
|
|
125
130
|
strength: number
|
|
126
131
|
boss?: boolean
|
|
127
132
|
label?: string
|
|
128
|
-
enemyKind?:
|
|
133
|
+
enemyKind?: EnemyKind
|
|
129
134
|
spawnPoint?: { x: number; y: number }
|
|
130
135
|
bossAttacks?: BossAttack[]
|
|
131
136
|
}
|
|
@@ -172,11 +177,17 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
172
177
|
const experience = ref(0)
|
|
173
178
|
const pendingLevelUps = ref(0)
|
|
174
179
|
const upgradeOptions = ref<UpgradeOption[]>([])
|
|
180
|
+
const isUpgradeChoiceReady = ref(false)
|
|
181
|
+
const playerHealth = ref(defaultPlayerStats.maxHealth)
|
|
182
|
+
const laserBeamCount = ref(1)
|
|
183
|
+
const homingLaserCount = ref(0)
|
|
184
|
+
const playerIconName = ref<FdsIconName>(args?.name ?? (iconNames[0] as FdsIconName))
|
|
175
185
|
let remainingBossNames = shuffle(bossNames)
|
|
176
186
|
let nextEnemyId = 0
|
|
177
187
|
let waveTimeout: ReturnType<typeof setTimeout> | undefined
|
|
178
188
|
let synergyTimeout: ReturnType<typeof setTimeout> | undefined
|
|
179
189
|
let crateTimeout: ReturnType<typeof setTimeout> | undefined
|
|
190
|
+
let upgradeChoiceTimeout: ReturnType<typeof setTimeout> | undefined
|
|
180
191
|
|
|
181
192
|
const isPausedByPlayer = ref(false)
|
|
182
193
|
const isPaused = computed(
|
|
@@ -185,6 +196,47 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
185
196
|
const experienceToNextLevel = computed(
|
|
186
197
|
() => gameBalance.experienceForFirstLevel + gameBalance.experiencePerLevel * level.value,
|
|
187
198
|
)
|
|
199
|
+
const criticalChancePercent = computed(() => Math.round(stats.value.criticalHitChance * 100))
|
|
200
|
+
const weaponDamagePerSecond = computed(() => {
|
|
201
|
+
const levels = weapons.value
|
|
202
|
+
const getCooldownSeconds = (cooldown: number, cooldownPerLevel: number, level: number) =>
|
|
203
|
+
((cooldown - cooldownPerLevel * (level - 1)) * stats.value.cooldownMultiplier) / 1000
|
|
204
|
+
const { laser, homingLasers, rockets, fireballs, iceAsteroids, electricShock } = gameBalance
|
|
205
|
+
const laserLevel = levels.laser ?? 1
|
|
206
|
+
const laserDamage = laser.damage + laser.damagePerLevel * (laserLevel - 1)
|
|
207
|
+
const laserShots = laserBeamCount.value + homingLaserCount.value * homingLasers.damageShare
|
|
208
|
+
let total =
|
|
209
|
+
(laserDamage * laserShots) / getCooldownSeconds(laser.fireCooldown, laser.fireCooldownPerLevel, laserLevel)
|
|
210
|
+
const rocketLevel = levels.rockets ?? 0
|
|
211
|
+
if (rocketLevel) {
|
|
212
|
+
const rocketCount = rocketLevel >= rockets.doubleRocketLevel ? 2 : 1
|
|
213
|
+
const rocketDamage = rockets.damage + rockets.damagePerLevel * (rocketLevel - 1)
|
|
214
|
+
total +=
|
|
215
|
+
(rocketCount * rocketDamage) / getCooldownSeconds(rockets.cooldown, rockets.cooldownPerLevel, rocketLevel)
|
|
216
|
+
}
|
|
217
|
+
const fireballLevel = levels.fireballs ?? 0
|
|
218
|
+
if (fireballLevel) {
|
|
219
|
+
const fireballDamage = fireballs.damage + fireballs.damagePerLevel * (fireballLevel - 1)
|
|
220
|
+
total += (fireballLevel * fireballDamage) / (fireballs.hitCooldown / 1000)
|
|
221
|
+
}
|
|
222
|
+
const iceLevel = levels.iceAsteroids ?? 0
|
|
223
|
+
if (iceLevel) {
|
|
224
|
+
const chunkCount = iceAsteroids.chunks + iceAsteroids.chunksPerLevel * (iceLevel - 1)
|
|
225
|
+
const chunkDamage = iceAsteroids.damage + iceAsteroids.damagePerLevel * (iceLevel - 1)
|
|
226
|
+
total +=
|
|
227
|
+
(chunkCount * chunkDamage) /
|
|
228
|
+
getCooldownSeconds(iceAsteroids.cooldown, iceAsteroids.cooldownPerLevel, iceLevel)
|
|
229
|
+
}
|
|
230
|
+
const shockLevel = levels.electricShock ?? 0
|
|
231
|
+
if (shockLevel) {
|
|
232
|
+
const shockDamage = electricShock.damage + electricShock.damagePerLevel * (shockLevel - 1)
|
|
233
|
+
total +=
|
|
234
|
+
(getElectricShockChainCount(shockLevel) * shockDamage) /
|
|
235
|
+
getCooldownSeconds(electricShock.cooldown, electricShock.cooldownPerLevel, shockLevel)
|
|
236
|
+
}
|
|
237
|
+
const criticalFactor = 1 + stats.value.criticalHitChance * (gameBalance.criticalHitMultiplier - 1)
|
|
238
|
+
return Math.round(total * stats.value.damageMultiplier * criticalFactor * 10) / 10
|
|
239
|
+
})
|
|
188
240
|
const experiencePercent = computed(() => `${(experience.value / experienceToNextLevel.value) * 100}%`)
|
|
189
241
|
const ownedWeapons = computed(() =>
|
|
190
242
|
(Object.keys(weapons.value) as WeaponId[]).map((weapon) => ({
|
|
@@ -206,6 +258,13 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
206
258
|
if (waveNumber >= 2) unlockedKinds.push('kamikaze')
|
|
207
259
|
if (waveNumber >= 3) unlockedKinds.push('splitter')
|
|
208
260
|
if (waveNumber >= 4) unlockedKinds.push('sniper')
|
|
261
|
+
if (waveNumber >= 6) unlockedKinds.push('shotgun')
|
|
262
|
+
if (waveNumber >= 8) unlockedKinds.push('teleporter')
|
|
263
|
+
if (waveNumber >= 12) unlockedKinds.push('bomber')
|
|
264
|
+
if (waveNumber >= 10) unlockedKinds.push('dasher')
|
|
265
|
+
if (waveNumber >= 14) unlockedKinds.push('shielded')
|
|
266
|
+
if (waveNumber >= 16) unlockedKinds.push('healer')
|
|
267
|
+
if (waveNumber >= 18) unlockedKinds.push('hive')
|
|
209
268
|
if (!unlockedKinds.length || Math.random() < 0.5) return undefined
|
|
210
269
|
return unlockedKinds[Math.floor(Math.random() * unlockedKinds.length)]
|
|
211
270
|
}
|
|
@@ -213,18 +272,26 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
213
272
|
function createWaveEnemies(waveNumber: number): WaveEnemy[] {
|
|
214
273
|
const strength = getWaveStrength(waveNumber)
|
|
215
274
|
const isBossWave = waveNumber % bossWaveInterval === 0
|
|
216
|
-
const
|
|
275
|
+
const totalEnemyHealthShare = isBossWave ? 3 : Math.min(3 + waveNumber, 14)
|
|
276
|
+
const enemyCount = Math.min(totalEnemyHealthShare, gameBalance.maxEnemiesPerWave)
|
|
277
|
+
const enemyStrength = (strength * totalEnemyHealthShare) / enemyCount
|
|
217
278
|
const waveEnemies: WaveEnemy[] = Array.from({ length: enemyCount }, () => ({
|
|
218
279
|
id: nextEnemyId++,
|
|
219
280
|
name: randomIconName(),
|
|
220
281
|
size: 40,
|
|
221
|
-
strength,
|
|
282
|
+
strength: enemyStrength,
|
|
222
283
|
enemyKind: randomEnemyKind(waveNumber),
|
|
223
284
|
}))
|
|
224
285
|
|
|
225
286
|
if (!isBossWave && waveNumber >= 3 && Math.random() < 0.4) {
|
|
226
|
-
for (let index = 0; index <
|
|
227
|
-
waveEnemies.push({
|
|
287
|
+
for (let index = 0; index < gameBalance.swarmSize; index++) {
|
|
288
|
+
waveEnemies.push({
|
|
289
|
+
id: nextEnemyId++,
|
|
290
|
+
name: randomIconName(),
|
|
291
|
+
size: 22,
|
|
292
|
+
strength: (strength * 5) / gameBalance.swarmSize,
|
|
293
|
+
enemyKind: 'swarm',
|
|
294
|
+
})
|
|
228
295
|
}
|
|
229
296
|
}
|
|
230
297
|
|
|
@@ -238,7 +305,9 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
238
305
|
strength * (isFinalBoss ? gameBalance.finalBossHealthMultiplier : gameBalance.bossHealthMultiplier),
|
|
239
306
|
boss: true,
|
|
240
307
|
label: isFinalBoss ? finalBossName : (remainingBossNames.shift() ?? finalBossName),
|
|
241
|
-
bossAttacks: isFinalBoss
|
|
308
|
+
bossAttacks: isFinalBoss
|
|
309
|
+
? allBossAttacks
|
|
310
|
+
: shuffle(allBossAttacks).slice(0, gameBalance.bossAttacks.namedBossAttackCount),
|
|
242
311
|
})
|
|
243
312
|
}
|
|
244
313
|
|
|
@@ -297,7 +366,7 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
297
366
|
const options: UpgradeOption[] = []
|
|
298
367
|
for (const weapon of Object.keys(weaponInfo) as WeaponId[]) {
|
|
299
368
|
const currentLevel = weapons.value[weapon] ?? 0
|
|
300
|
-
if (currentLevel >= maxWeaponLevel) continue
|
|
369
|
+
if (currentLevel >= (weapon === 'laser' ? gameBalance.laser.maxLevel : maxWeaponLevel)) continue
|
|
301
370
|
options.push({
|
|
302
371
|
id: weapon,
|
|
303
372
|
kind: 'weapon',
|
|
@@ -339,9 +408,14 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
339
408
|
function offerUpgrades() {
|
|
340
409
|
pendingLevelUps.value--
|
|
341
410
|
const options = createUpgradeOptions()
|
|
342
|
-
const
|
|
343
|
-
const otherOptions = shuffle(options.filter((option) => option !==
|
|
344
|
-
upgradeOptions.value = shuffle(
|
|
411
|
+
const laserOption = options.find((option) => option.id === 'laser')
|
|
412
|
+
const otherOptions = shuffle(options.filter((option) => option !== laserOption)).slice(0, laserOption ? 2 : 3)
|
|
413
|
+
upgradeOptions.value = shuffle(laserOption ? [laserOption, ...otherOptions] : otherOptions)
|
|
414
|
+
isUpgradeChoiceReady.value = false
|
|
415
|
+
clearTimeout(upgradeChoiceTimeout)
|
|
416
|
+
upgradeChoiceTimeout = setTimeout(() => {
|
|
417
|
+
isUpgradeChoiceReady.value = true
|
|
418
|
+
}, 1000)
|
|
345
419
|
}
|
|
346
420
|
|
|
347
421
|
function addKill(points: number) {
|
|
@@ -354,6 +428,7 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
354
428
|
experience.value -= experienceToNextLevel.value
|
|
355
429
|
level.value++
|
|
356
430
|
pendingLevelUps.value++
|
|
431
|
+
playerIconName.value = randomIconName()
|
|
357
432
|
}
|
|
358
433
|
if (!upgradeOptions.value.length && pendingLevelUps.value > 0) offerUpgrades()
|
|
359
434
|
}
|
|
@@ -372,6 +447,7 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
372
447
|
}
|
|
373
448
|
|
|
374
449
|
function chooseUpgrade(option: UpgradeOption) {
|
|
450
|
+
if (!isUpgradeChoiceReady.value) return
|
|
375
451
|
applyUpgrade(option)
|
|
376
452
|
upgradeOptions.value = []
|
|
377
453
|
if (pendingLevelUps.value > 0) offerUpgrades()
|
|
@@ -387,10 +463,12 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
387
463
|
|
|
388
464
|
function openCrate(crateReward: 'laserBeam' | 'homingLaser' | 'weaponUpgrade') {
|
|
389
465
|
if (crateReward === 'laserBeam') {
|
|
466
|
+
laserBeamCount.value++
|
|
390
467
|
showCrateBanner('Crate: extra laser beam!')
|
|
391
468
|
return
|
|
392
469
|
}
|
|
393
470
|
if (crateReward === 'homingLaser') {
|
|
471
|
+
homingLaserCount.value++
|
|
394
472
|
showCrateBanner('Crate: homing laser!')
|
|
395
473
|
return
|
|
396
474
|
}
|
|
@@ -401,12 +479,22 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
401
479
|
const newWeapons = options.filter((option) => option.kind === 'weapon')
|
|
402
480
|
const fallback =
|
|
403
481
|
options.find((option) => option.id === 'power') ?? options.find((option) => option.kind === 'repair')
|
|
404
|
-
const
|
|
482
|
+
const laserUpgrade = options.find((option) => option.id === 'laser')
|
|
483
|
+
const reward = laserUpgrade ?? shuffle(ownedWeaponUpgrades)[0] ?? shuffle(newWeapons)[0] ?? fallback
|
|
405
484
|
if (!reward) return
|
|
406
485
|
applyUpgrade(reward)
|
|
407
486
|
showCrateBanner(`Crate: ${reward.title}!`)
|
|
408
487
|
}
|
|
409
488
|
|
|
489
|
+
function enterFullscreen() {
|
|
490
|
+
if (!document.fullscreenElement) document.documentElement.requestFullscreen().catch(() => {})
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function pauseWhenLeavingFullscreen() {
|
|
494
|
+
if (document.fullscreenElement || !hasStarted.value || hasWon.value || isGameOver.value) return
|
|
495
|
+
isPausedByPlayer.value = true
|
|
496
|
+
}
|
|
497
|
+
|
|
410
498
|
function startGame() {
|
|
411
499
|
hasStarted.value = true
|
|
412
500
|
startNextWave()
|
|
@@ -432,6 +520,10 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
432
520
|
hasWon.value = false
|
|
433
521
|
isPausedByPlayer.value = false
|
|
434
522
|
remainingBossNames = shuffle(bossNames)
|
|
523
|
+
playerIconName.value = args?.name ?? (iconNames[0] as FdsIconName)
|
|
524
|
+
playerHealth.value = defaultPlayerStats.maxHealth
|
|
525
|
+
laserBeamCount.value = 1
|
|
526
|
+
homingLaserCount.value = 0
|
|
435
527
|
gameRound.value++
|
|
436
528
|
startNextWave()
|
|
437
529
|
}
|
|
@@ -442,6 +534,12 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
442
534
|
startGame()
|
|
443
535
|
return
|
|
444
536
|
}
|
|
537
|
+
if (event.key.toLowerCase() === 'f' && hasStarted.value) {
|
|
538
|
+
event.stopPropagation()
|
|
539
|
+
if (document.fullscreenElement) document.exitFullscreen().catch(() => {})
|
|
540
|
+
else enterFullscreen()
|
|
541
|
+
return
|
|
542
|
+
}
|
|
445
543
|
if (event.key === 'Escape' && hasStarted.value && !hasWon.value && !isGameOver.value) {
|
|
446
544
|
event.stopPropagation()
|
|
447
545
|
isPausedByPlayer.value = !isPausedByPlayer.value
|
|
@@ -454,11 +552,19 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
454
552
|
chooseUpgrade(chosenOption)
|
|
455
553
|
}
|
|
456
554
|
|
|
457
|
-
onMounted(() =>
|
|
555
|
+
onMounted(() => {
|
|
556
|
+
document.documentElement.classList.add('select-none')
|
|
557
|
+
window.addEventListener('keydown', handleMenuKeys, true)
|
|
558
|
+
document.addEventListener('fullscreenchange', pauseWhenLeavingFullscreen)
|
|
559
|
+
})
|
|
458
560
|
onUnmounted(() => {
|
|
561
|
+
document.documentElement.classList.remove('select-none')
|
|
459
562
|
window.removeEventListener('keydown', handleMenuKeys, true)
|
|
563
|
+
document.removeEventListener('fullscreenchange', pauseWhenLeavingFullscreen)
|
|
564
|
+
if (document.fullscreenElement) document.exitFullscreen().catch(() => {})
|
|
460
565
|
clearTimeout(waveTimeout)
|
|
461
566
|
clearTimeout(synergyTimeout)
|
|
567
|
+
clearTimeout(upgradeChoiceTimeout)
|
|
462
568
|
})
|
|
463
569
|
|
|
464
570
|
return {
|
|
@@ -486,6 +592,11 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
486
592
|
ownedWeapons,
|
|
487
593
|
activeSynergyNames,
|
|
488
594
|
upgradeOptions,
|
|
595
|
+
isUpgradeChoiceReady,
|
|
596
|
+
playerHealth,
|
|
597
|
+
weaponDamagePerSecond,
|
|
598
|
+
criticalChancePercent,
|
|
599
|
+
playerIconName,
|
|
489
600
|
isPaused,
|
|
490
601
|
isPausedByPlayer,
|
|
491
602
|
finalWave,
|
|
@@ -508,6 +619,9 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
508
619
|
</div>
|
|
509
620
|
</div>
|
|
510
621
|
<div class="fixed top-4 right-4 flex flex-col items-end gap-1 text-sm">
|
|
622
|
+
<p class="m-0 font-bold text-base">Health: {{ playerHealth }} / {{ stats.maxHealth }}</p>
|
|
623
|
+
<p class="m-0 font-bold">Damage: {{ weaponDamagePerSecond }} / s</p>
|
|
624
|
+
<p class="m-0 font-bold">Crit chance: {{ criticalChancePercent }}%</p>
|
|
511
625
|
<p v-for="weapon in ownedWeapons" :key="weapon.id" class="m-0">{{ weapon.name }} {{ weapon.level }}</p>
|
|
512
626
|
<template v-for="(passiveLevel, passive) in passiveLevels" :key="passive">
|
|
513
627
|
<p v-if="passiveLevel" class="m-0 text-gray-600">{{ passiveInfo[passive].name }} {{ passiveLevel }}</p>
|
|
@@ -517,7 +631,7 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
517
631
|
</p>
|
|
518
632
|
</div>
|
|
519
633
|
<p class="fixed bottom-4 left-4 m-0 text-sm text-gray-600">
|
|
520
|
-
Move: WASD / arrows · Dash: space · Shoot: click · Charged shot: hold and release · Pause: Esc
|
|
634
|
+
Move: WASD / arrows · Dash: space · Shoot: click · Charged shot: hold and release · Pause: Esc · Fullscreen: F
|
|
521
635
|
</p>
|
|
522
636
|
<p
|
|
523
637
|
v-if="waveBanner"
|
|
@@ -540,12 +654,14 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
540
654
|
<IconRescueIcon
|
|
541
655
|
ref="playerRef"
|
|
542
656
|
v-bind="args"
|
|
657
|
+
:name="playerIconName"
|
|
543
658
|
:weapons="weapons"
|
|
544
659
|
:stats="stats"
|
|
545
660
|
:paused="isPaused"
|
|
546
661
|
@kill="addKill"
|
|
547
662
|
@experience="addExperience"
|
|
548
663
|
@crate="openCrate"
|
|
664
|
+
@health="playerHealth = $event"
|
|
549
665
|
@game-over="isGameOver = true"
|
|
550
666
|
/>
|
|
551
667
|
<IconRescueIcon
|
|
@@ -561,6 +677,7 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
561
677
|
:spawn-point="enemy.spawnPoint"
|
|
562
678
|
:paused="isPaused"
|
|
563
679
|
@kill="addKill"
|
|
680
|
+
@experience="addExperience"
|
|
564
681
|
@destroyed="removeEnemy(enemy)"
|
|
565
682
|
@split="splitEnemy"
|
|
566
683
|
:boss-attacks="enemy.bossAttacks"
|
|
@@ -585,10 +702,46 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
585
702
|
v-for="(option, index) in upgradeOptions"
|
|
586
703
|
:key="option.id"
|
|
587
704
|
type="button"
|
|
588
|
-
|
|
705
|
+
:disabled="!isUpgradeChoiceReady"
|
|
706
|
+
class="flex flex-col gap-2 w-56 p-4 rounded-lg bg-white text-left hover:bg-blue-100 focus-visible:outline-2 focus-visible:outline-blue-500 disabled:opacity-60 disabled:hover:bg-white"
|
|
589
707
|
@click="chooseUpgrade(option)"
|
|
590
708
|
>
|
|
591
709
|
<span class="text-xs text-gray-500">Press {{ index + 1 }}</span>
|
|
710
|
+
<span v-if="option.kind === 'weapon'" class="flex items-center justify-center w-12 h-12 rounded-md bg-gray-900">
|
|
711
|
+
<svg viewBox="0 0 32 32" class="w-9 h-9" aria-hidden="true">
|
|
712
|
+
<template v-if="option.id === 'laser'">
|
|
713
|
+
<line x1="5" y1="27" x2="27" y2="5" class="stroke-red-400 opacity-40" stroke-width="9" stroke-linecap="round" />
|
|
714
|
+
<line x1="5" y1="27" x2="27" y2="5" class="stroke-white" stroke-width="3" stroke-linecap="round" />
|
|
715
|
+
</template>
|
|
716
|
+
<g v-else-if="option.id === 'rockets'" transform="rotate(45 16 16)">
|
|
717
|
+
<path d="M13 22 L16 30 L19 22 Z" class="fill-yellow-400" />
|
|
718
|
+
<path d="M16 2 C20 6 20 14 19 22 H13 C12 14 12 6 16 2 Z" class="fill-white" />
|
|
719
|
+
</g>
|
|
720
|
+
<template v-else-if="option.id === 'fireballs'">
|
|
721
|
+
<defs>
|
|
722
|
+
<radialGradient id="icon-rescue-fireball">
|
|
723
|
+
<stop offset="0%" style="stop-color: var(--color-yellow-200)" />
|
|
724
|
+
<stop offset="50%" style="stop-color: var(--color-yellow-500)" />
|
|
725
|
+
<stop offset="100%" style="stop-color: var(--color-red-600)" />
|
|
726
|
+
</radialGradient>
|
|
727
|
+
</defs>
|
|
728
|
+
<circle cx="16" cy="16" r="11" fill="url(#icon-rescue-fireball)" />
|
|
729
|
+
</template>
|
|
730
|
+
<polygon
|
|
731
|
+
v-else-if="option.id === 'iceAsteroids'"
|
|
732
|
+
points="16,3 26,9 28,20 19,29 8,26 4,14"
|
|
733
|
+
class="fill-blue-100 stroke-blue-500"
|
|
734
|
+
stroke-width="2"
|
|
735
|
+
/>
|
|
736
|
+
<polyline
|
|
737
|
+
v-else-if="option.id === 'electricShock'"
|
|
738
|
+
points="19,2 9,17 17,17 12,30 25,12 17,12 21,2"
|
|
739
|
+
class="fill-none stroke-blue-200"
|
|
740
|
+
stroke-width="2.5"
|
|
741
|
+
stroke-linejoin="round"
|
|
742
|
+
/>
|
|
743
|
+
</svg>
|
|
744
|
+
</span>
|
|
592
745
|
<span class="text-lg font-bold">{{ option.title }}</span>
|
|
593
746
|
<span class="text-sm">{{ option.description }}</span>
|
|
594
747
|
</button>
|
|
@@ -599,7 +752,7 @@ function createIconRescueGame(args: Story['args']) {
|
|
|
599
752
|
class="fixed inset-0 z-[100004] flex flex-col items-center justify-center gap-4 bg-black/60"
|
|
600
753
|
>
|
|
601
754
|
<p class="m-0 text-6xl font-bold text-white">Paused</p>
|
|
602
|
-
<p class="m-0 text-lg text-white">Press Esc to continue</p>
|
|
755
|
+
<p class="m-0 text-lg text-white">Press Esc to continue · F for fullscreen</p>
|
|
603
756
|
</div>
|
|
604
757
|
<div v-if="hasWon" class="fixed inset-0 z-[100003] flex flex-col items-center justify-center gap-6 bg-black/70">
|
|
605
758
|
<p class="m-0 text-6xl font-bold text-white">You beat {{ finalBossName }}!</p>
|