/**
* Crab Image module
* @module crab
*/
/** @type {HTMLElement} Crab image element. */
const crab = document.getElementById("crab");
/** @type {HTMLElement} Crab chat bubble element. */
const crabChat = document.getElementById("crab-chat");
/** @type {HTMLAudioElement} Boop audio play. */
const boop = new Audio('sounds/boop.mp3');
/** @type {HTMLAudioElement} Stomp audio play. */
const stomp = new Audio('sounds/stomp.mp3');
/** @type {HTMLAudioElement} Audio played when the crab is happy. */
const happyAudio = new Audio('sounds/happy.mp3');
/** @type {HTMLAudioElement} Audio played when the crab is angry. */
const angryAudio = new Audio('sounds/angry.mp3');
/**
* Handles the "boop" action for the crab.
*
* @description
* Changes the crab's image to a happy state, hides the chat bubble,
* and plays the "boop" sound.
*/
export function boopCrab() {
crab.src = "img/logo-colored-outline.png";
crabChat.style.display = "none";
boop.play();
}
/**
* Handles the "stomp" action for the crab.
*
* @param {string} text - The message to display in the crab's chat bubble.
*
* @description
* Changes the crab's image to a neutral state, displays the chat bubble with
* the given text, and plays the "stomp" sound.
*/
export function stompCrab(text) {
crab.src = "img/logo-colored-outline.png";
crabChat.style.display = "block";
crabChat.textContent = text;
stomp.play();
}
/**
* Handles the happy state for the crab.
*
* @param {string} text - The message to display in the crab's chat bubble.
*
* @description
* Changes the crab's image to a happy state, displays the chat bubble with
* the given text, and plays the "happy" sound.
*/
export function happyCrab(text) {
crab.src = "img/logo-colored-outline.png";
crabChat.style.display = "block";
crabChat.textContent = text;
happyAudio.play();
}
/**
* Handles the angry state for the crab.
*
* @param {string} text - The message to display in the crab's chat bubble.
*
* @description
* Changes the crab's image to an angry state, displays the chat bubble with
* the given text, and plays the "angry" sound.
*/
export function angryCrab(text) {
crab.src = "img/angry-logo.png";
crabChat.style.display = "block";
crabChat.textContent = text;
angryAudio.play();
}