Methods
add_or_update_card(card, quantityopt) → {Object|null}
Adds a new card or updates the quantity if it already exists.
If the quantity is positive, it increments or sets the card's quantity.
If the quantity is negative, it decrements the quantity and removes the card if the total falls to 0 or below.
If the card doesn't exist and quantity is 0 or negative, it does nothing.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
card |
Object | The card object to add or update. Must include `name` and `rarity` properties. | ||
quantity |
number |
<optional> |
1 | The number of cards to add (positive) or remove (negative). |
Returns:
The updated card object, or `null` if the card was removed or not added.
- Type
- Object | null
clicker_buttons(frenzy_testopt)
Initializes click event listeners for the clicker component.
When the clicker component is pressed, increments the user's points,
updates the points display, and applies a scaling effect for visual feedback.
On mouse release, restores the original scale.
Assumes the existence of `update_points` and `fetch_user_info` functions,
and elements with IDs "clicker-comp" and "points_display" in the DOM.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
frenzy_test |
boolean |
<optional> |
false | If true, enables frenzy mode for testing purposes. |
- Source:
createCard(data) → {HTMLElement}
Creates a new frog-card element and appends it inside the .
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The data to set on the frog-card element. Matches card-data.json format. |
Returns:
The created frog-card element.
- Type
- HTMLElement
createCard(data)
Creates a new frog-card element and appends it inside the element.
Also sets up the crafting UI for the displayed card.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The card data object containing name, rarity, course, bio, and quantity properties. |
- Source:
create_light_rays(rarity) → {void}
Creates light ray effects for card reveal.
Parameters:
| Name | Type | Description |
|---|---|---|
rarity |
string | The rarity of the card. |
- Source:
Returns:
- Type
- void
display_card(card) → {void}
Displays a card and overlays a pack-cover.
Parameters:
| Name | Type | Description |
|---|---|---|
card |
Object | The card object to display. |
- Source:
Returns:
- Type
- void
display_placeholder(is_first_purchase) → {void}
Displays a placeholder card.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
is_first_purchase |
boolean | true | If this is user's first purchase. |
- Source:
Returns:
- Type
- void
fetch_data(path) → {Promise}
Fetches data from the JSON file and returns it as a Promise.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The path to the JSON file relative to index.html. |
Throws:
-
If the fetch operation fails.
- Type
- Error
Returns:
A promise that resolves to the data from the JSON file.
- Type
- Promise
fetch_unlocked_cards() → {Array}
Fetches unlocked cards from local storage.
Returns:
An array of unlocked cards from local storage.
- Type
- Array
fetch_user_info() → {UserInfo}
Returns:
returns the user_Data saved to local storage
- Type
- UserInfo
generate_random_card() → {Object}
Generates a random card object with a name, rarity, and metadata.
- Source:
Returns:
A card object.
- Type
- Object
get_random_element(arr) → {*}
Returns a random element from an array.
Parameters:
| Name | Type | Description |
|---|---|---|
arr |
Array | The array to choose from. |
- Source:
Returns:
A randomly selected element from the array.
- Type
- *
get_random_rarity(rarities) → {string}
Randomly selects a rarity, checking guarantees first.
Parameters:
| Name | Type | Description |
|---|---|---|
rarities |
Array | Array of rarity objects. |
- Source:
Returns:
Selected rarity type.
- Type
- string
get_rarity_display_color(rarity) → {string}
Gets the display color for a rarity (brighter for dark background).
Parameters:
| Name | Type | Description |
|---|---|---|
rarity |
string | The rarity type. |
- Source:
Returns:
The color code.
- Type
- string
(async) init()
Initializes the card deck on DOM load.
init()
Initializes the shop page.
- Source:
load_cards_from_local() → {Array}
Loads the user's saved cards from local storage.
Returns:
An array of saved card objects.
- Type
- Array
load_pity_counters() → {Object}
Loads pity counters from local storage.
- Source:
Returns:
Pity counters object.
- Type
- Object
renderCards(filter) → {Array}
Renders the card grid based on the provided filter. It retrieves card data from local storage,
Parameters:
| Name | Type | Description |
|---|---|---|
filter |
string | The search filter string to apply to the card names. |
- Source:
Returns:
An array of card objects that match the filter criteria.
- Type
- Array
save_cards_to_local(cards) → {void}
Saves an array of cards to local storage.
Parameters:
| Name | Type | Description |
|---|---|---|
cards |
Array | Array of card objects to save. |
Returns:
- Type
- void
save_pity_counters(counters) → {void}
Saves pity counters to local storage.
Parameters:
| Name | Type | Description |
|---|---|---|
counters |
Object | Counters to save. |
- Source:
Returns:
- Type
- void
save_to_local(data, key) → {void}
Saves data to local storage.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The data to save to local storage. |
key |
string | The key under which to save the data. |
Returns:
- Type
- void
setupCraftingUI(data)
Sets up the crafting UI for a given card, including the slider, summary text,
and craft button. Handles the logic for determining if crafting is possible based on rarity
and available quantity. Sets up event listeners for the slider and craft button.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The card data object containing name, rarity, course, bio, and quantity properties. |
- Source:
show_congrats_animation(rarity) → {void}
Shows congratulations animation with particles.
Parameters:
| Name | Type | Description |
|---|---|---|
rarity |
string | The rarity of the card. |
- Source:
Returns:
- Type
- void
updateCardGrid(cardData) → {void}
Updates the card grid display by loading cards from local storage and creating
card-thumbnail elements for each card. Sets up click event listeners for each card to open
the card modal when clicked.
Parameters:
| Name | Type | Description |
|---|---|---|
cardData |
Array | An array of card data objects to display in the grid. |
- Source:
Returns:
- Type
- void
update_container_rarity(rarity) → {void}
Updates the container background based on rarity.
Parameters:
| Name | Type | Description |
|---|---|---|
rarity |
string | The rarity to apply. |
- Source:
Returns:
- Type
- void
update_cost() → {void}
Updates the card generation cost displayed on the page.
- Source:
Returns:
- Type
- void
update_guarantee_display() → {void}
Updates the guarantee progress bar.
- Source:
Returns:
- Type
- void
update_pity_counters(obtained_rarity) → {Object}
Updates pity counters based on obtained rarity.
Parameters:
| Name | Type | Description |
|---|---|---|
obtained_rarity |
string | The rarity that was obtained. |
- Source:
Returns:
Updated counters.
- Type
- Object
update_points(points) → {boolean}
update user points by the point value. Can be negative or positive
Parameters:
| Name | Type | Description |
|---|---|---|
points |
number | number to increase or decrease user points by |
Returns:
returns true if successful else false. If user has too few points its false
- Type
- boolean
update_points_display() → {void}
Updates the points display on the page using user data.
- Source:
Returns:
- Type
- void
update_tooltip() → {void}
Updates tooltip with drop rates and guarantees.
- Source:
Returns:
- Type
- void