Skip to content

Commit

Permalink
Add base balloon options to increment score #343
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonStnn committed Oct 20, 2024
1 parent add6d05 commit f1e61b3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/balloon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ type StyleSheetProps = {
name?: string;
};

export type PopOptions = {
increaseCount?: boolean;
};

export const basePopOptions: PopOptions = {
increaseCount: true,
};

export default abstract class Balloon {
public abstract readonly name: BalloonName;

Expand Down Expand Up @@ -117,11 +125,14 @@ export default abstract class Balloon {
*
* @param event The mouse event that triggered the pop.
*/
public pop(event?: MouseEvent): void | Promise<void> {
public pop(event?: MouseEvent, options?: PopOptions): void | Promise<void> {
options = { ...basePopOptions, ...options };
// Remove the balloon
this.remove();

// Send message with the new count
sendMessage({ action: 'incrementCount', type: this.name });
if (options?.increaseCount) {
// Send message with the new count
sendMessage({ action: 'incrementCount', type: this.name });
}
}
}

0 comments on commit f1e61b3

Please sign in to comment.