From 640c076b1633c00817303bc1269c2e5ebd98e41d Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 29 Jan 2025 23:29:41 -0500 Subject: [PATCH] feat(helpers): add reward bubble stun --- src/events/states.ts | 10 +++++++--- src/helpers/gameState.ts | 3 ++- src/helpers/rewards.ts | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/events/states.ts b/src/events/states.ts index fdaf8b3..49d9362 100644 --- a/src/events/states.ts +++ b/src/events/states.ts @@ -1,11 +1,13 @@ import { Animation, Sprite, State } from '../constants' import { addBadBubble, addProjectile, getPlayer } from '../gameobjects' +import { gameState } from '../helpers' import type { Enemy } from '../types' export function addEnemyState(enemy: Enemy) { enemy.onStateEnter(State.Idle, () => { enemy.play(Animation.Idle) - wait(rand(0.3, 1), () => enemy.enterState(State.Move)) + const seconds = rand(0.3, 1) + wait(seconds, () => enemy.enterState(State.Move)) }) enemy.onStateEnter(State.Move, () => { @@ -36,12 +38,14 @@ export function addEnemyState(enemy: Enemy) { enemy.onStateEnter(State.Cooldown, () => { enemy.play(Animation.Cooldown) - wait(rand(1, 3), () => enemy.enterState(State.Move)) + const seconds = rand(1, 3) + wait(seconds, () => enemy.enterState(State.Move)) }) enemy.onStateEnter(State.Stunned, () => { enemy.play(Animation.Stunned) - wait(rand(0.3, 1), () => enemy.enterState(State.Move)) + const seconds = rand(0.3, 1) * gameState.player.bubble.stun + wait(seconds, () => enemy.enterState(State.Move)) }) enemy.onStateUpdate(State.Move, () => { diff --git a/src/helpers/gameState.ts b/src/helpers/gameState.ts index cdc290c..98496a8 100644 --- a/src/helpers/gameState.ts +++ b/src/helpers/gameState.ts @@ -13,8 +13,9 @@ class GameState { player = { bubble: { damage: 20, - speed: 200, size: 1, + speed: 200, + stun: 1, }, } diff --git a/src/helpers/rewards.ts b/src/helpers/rewards.ts index efcb197..4bb1001 100644 --- a/src/helpers/rewards.ts +++ b/src/helpers/rewards.ts @@ -93,6 +93,20 @@ const rewards = [ gameState.player.bubble.size *= (100 + this.percentage) / 100 }, }, + + // bubble stun + { + percentage: 0, + setPercentage(percentage = randi(10, 25)) { + this.percentage = percentage + }, + get text() { + return `Bubble Stun +${this.percentage}%` + }, + action() { + gameState.player.bubble.stun *= (100 + this.percentage) / 100 + }, + }, ] export function getRewards(total = 2) {