resolveCombat
Determines the outcome of a battle between two cards based on their types and levels. The combat system follows a rock-paper-scissors pattern with type advantages, modified by level differences.Combat Rules
- Level Difference ≥ 2: Automatic victory for the higher-level card
- Level Difference = 1: The higher-level card wins unless the lower-level card has type advantage, which neutralizes the combat
- Same Level: Type advantages determine the winner (see ADVANTAGES table)
Type Advantage Cycles
There are two separate advantage cycles:- Elemental Cycle: Fuego → Planta → Agua → Fuego
- Spiritual Cycle: Luz → Sombra → Espíritu → Luz
The attacking card object
The defending card object
Returns
The combat winner:
'attacker', 'defender', or 'none' for a drawThe combat loser:
'attacker', 'defender', or 'none' for a drawExamples
Automatic Victory (Level Difference ≥ 2)
Type Advantage at Same Level
Level +1 Neutralized by Type Advantage
Draw (No Type Advantage)
Combat Logic Flow
- Calculate level difference:
attacker.level - defender.level - If
levelDiff >= 2: Attacker wins automatically - If
levelDiff <= -2: Defender wins automatically - If
levelDiff === 1: Attacker wins unless defender has type advantage (then draw) - If
levelDiff === -1: Defender wins unless attacker has type advantage (then draw) - If
levelDiff === 0: Type advantage determines winner, otherwise draw
Source
Frontend/src/helpers/combat.js:13-56