Skip to main content

CARD_TYPES

Defines all available card types in the game. There are six types organized into two cycles: elemental (Fuego, Agua, Planta) and spiritual (Luz, Sombra, Espíritu).

Values

ConstantValueDescription
FUEGO'fuego'Fire element
AGUA'agua'Water element
PLANTA'planta'Plant element
LUZ'luz'Light spiritual type
SOMBRA'sombra'Shadow spiritual type
ESPIRITU'espiritu'Spirit type

Example

import { CARD_TYPES } from './helpers/constants';

const fireCard = {
  type: CARD_TYPES.FUEGO,
  level: 2
};

const waterCard = {
  type: CARD_TYPES.AGUA,
  level: 1
};

ADVANTAGES

Defines the type advantage map for combat resolution. Each card type has an advantage over exactly one other type, forming two separate rock-paper-scissors cycles.

Type Advantage Cycles

Elemental Cycle:
  • Fuego beats Planta
  • Planta beats Agua
  • Agua beats Fuego
Spiritual Cycle:
  • Luz beats Sombra
  • Sombra beats Espíritu
  • Espíritu beats Luz
Cards from different cycles (elemental vs spiritual) have no advantage over each other.

Structure

Attacker TypeAdvantage Against
fuegoplanta
plantaagua
aguafuego
luzsombra
sombraespiritu
espirituluz

Example

import { ADVANTAGES, CARD_TYPES } from './helpers/constants';

// Check if attacker has type advantage
const attacker = { type: CARD_TYPES.FUEGO };
const defender = { type: CARD_TYPES.PLANTA };

if (ADVANTAGES[attacker.type] === defender.type) {
  console.log('Attacker has type advantage!');
  // This will execute: Fuego beats Planta
}

// Check the full advantage map
console.log(ADVANTAGES);
// {
//   fuego: 'planta',
//   planta: 'agua',
//   agua: 'fuego',
//   luz: 'sombra',
//   sombra: 'espiritu',
//   espiritu: 'luz'
// }

GAME_CONFIG

Contains all game configuration constants that define core gameplay mechanics and limits.

Configuration Values

MAX_HAND_SIZE
number
default:4
Maximum number of cards a player can hold in their hand
MAX_FIELD_SIZE
number
default:6
Maximum number of cards that can be on the battlefield at once
INITIAL_DECK_SIZE
number
default:48
Total number of cards in a player’s deck at game start
TURN_TIME_LIMIT_MS
number
default:12000
Time limit per turn in milliseconds (12 seconds)
MANDATORY_ATTACK_TURN
number
default:3
Turn number when players must start attacking (turn 3)
UNIQUE_TYPES_TO_WIN
number
default:6
Number of unique card types needed in essence collection to win
ESSENCES_TO_WIN
number
default:6
Total number of essences needed to win the game

Summary Table

ConstantValueDescription
MAX_HAND_SIZE4Maximum cards in hand
MAX_FIELD_SIZE6Maximum cards on field
INITIAL_DECK_SIZE48Cards in starting deck
TURN_TIME_LIMIT_MS12000Turn timer (12 seconds)
MANDATORY_ATTACK_TURN3Turn when attacks become mandatory
UNIQUE_TYPES_TO_WIN6Unique types needed to win
ESSENCES_TO_WIN6Total essences needed to win

Example

import { GAME_CONFIG } from './helpers/constants';

// Check if hand is full
function canDrawCard(hand) {
  return hand.length < GAME_CONFIG.MAX_HAND_SIZE;
}

// Check if field is full
function canPlayCard(field) {
  return field.length < GAME_CONFIG.MAX_FIELD_SIZE;
}

// Set turn timer
function startTurnTimer() {
  return setTimeout(() => {
    endTurn();
  }, GAME_CONFIG.TURN_TIME_LIMIT_MS);
}

// Check win condition
function checkWinCondition(essences) {
  const uniqueTypes = new Set(essences.map(e => e.type)).size;
  return uniqueTypes >= GAME_CONFIG.UNIQUE_TYPES_TO_WIN &&
         essences.length >= GAME_CONFIG.ESSENCES_TO_WIN;
}

Source

Frontend/src/helpers/constants.js:1-27

Build docs developers (and LLMs) love