CardGame
Rogue-like card videogame
Loading...
Searching...
No Matches
CardMatch Class Reference

Orchestrates a single combat encounter between one player and one enemy. More...

#include <cardmatch.h>

Collaboration diagram for CardMatch:

Public Member Functions

 CardMatch (IMatchView &matchView, Player &player, Enemy &enemy)
 Constructs a match for the given player and enemy.
 
void drawMultipleCardsNoEffect (int amount)
 Draws multiple cards into the player's hand.
 
void writeDrawnCardMessage (std::string &drawMessage, const DrawData &drawData)
 
void playCard (int handIndex, CombatContext &currentContext)
 Plays a card from the hand and resolves all of its effects.
 
void gainArmor (int defense)
 Legacy helper that directly increases the player's armor.
 
void spendAction (TurnData &turnData)
 
void reduceAction (TurnData &turnData, int amount)
 
bool updateMatchState ()
 
void turnLoop ()
 
void playerTurnSetup (const TurnData &currentTurnData)
 
void playerTurn (TurnData &currentTurnData)
 
bool canPlayerAct (TurnData &currentTurnData)
 
void enemyTurn (TurnData &currentTurnData)
 Executes the enemy's next move and resolves its effects.
 
void damagePhase ()
 
void resetPhase ()
 

Detailed Description

Orchestrates a single combat encounter between one player and one enemy.

CardMatch coordinates encounter-level flow:

  • builds a combat deck from the player's persistent deck (DeckCombat + CardFactory)
  • draws cards into the player's hand
  • resolves a played card by executing its ordered Effect list
  • runs the enemy turn by resolving the next EnemyMove

CardMatch owns the runtime combat deck (DeckCombat) and the rules engine (CombatSystem). Player and Enemy objects are referenced and must outlive the CardMatch.

Effect resolution is performed using CombatContext, which routes effect requests to CombatSystem. See Combat Effect Resolution Pipeline for the full resolution flow.

Constructor & Destructor Documentation

◆ CardMatch()

CardMatch::CardMatch ( IMatchView matchView,
Player player,
Enemy enemy 
)

Constructs a match for the given player and enemy.

Builds a fresh DeckCombat from the player's persistent deck.

Parameters
playerPlayer participating in the encounter (must outlive the CardMatch).
enemyEnemy participating in the encounter (must outlive the CardMatch).

Member Function Documentation

◆ canPlayerAct()

bool CardMatch::canPlayerAct ( TurnData currentTurnData)

◆ damagePhase()

void CardMatch::damagePhase ( )

◆ drawMultipleCardsNoEffect()

void CardMatch::drawMultipleCardsNoEffect ( int  amount)

Draws multiple cards into the player's hand.

Delegates empty-deck behavior to DeckCombat.

Parameters
amountNumber of cards to draw. If amount <= 0, no action is taken.

◆ enemyTurn()

void CardMatch::enemyTurn ( TurnData currentTurnData)

Executes the enemy's next move and resolves its effects.

The enemy provides an EnemyMove via Enemy::nextMove(). Effects are resolved in order using a CombatContext where the enemy is the actor and the player is the opponent.

◆ gainArmor()

void CardMatch::gainArmor ( int  defense)

Legacy helper that directly increases the player's armor.

Warning
This bypasses CombatSystem and exists only for older code paths. Current effects should grant armor via CombatContext/CombatSystem.

◆ playCard()

void CardMatch::playCard ( int  handIndex,
CombatContext currentContext 
)

Plays a card from the hand and resolves all of its effects.

The selected card is removed from the hand immediately via DeckCombat::takeFromHand() Effects are then resolved in the order defined by the card's CardDefinition. After resolution, the card is moved to the discard pile.

If the hand index is invalid, no action is taken.

Parameters
handIndexZero-based index of the card in the hand.

◆ playerTurn()

void CardMatch::playerTurn ( TurnData currentTurnData)

◆ playerTurnSetup()

void CardMatch::playerTurnSetup ( const TurnData currentTurnData)

◆ reduceAction()

void CardMatch::reduceAction ( TurnData turnData,
int  amount 
)

◆ resetPhase()

void CardMatch::resetPhase ( )

◆ spendAction()

void CardMatch::spendAction ( TurnData turnData)

◆ turnLoop()

void CardMatch::turnLoop ( )

◆ updateMatchState()

bool CardMatch::updateMatchState ( )

◆ writeDrawnCardMessage()

void CardMatch::writeDrawnCardMessage ( std::string &  drawMessage,
const DrawData drawData 
)

The documentation for this class was generated from the following files: