Skip to content

Commit

Permalink
docs: add tsdoc to Caravan
Browse files Browse the repository at this point in the history
  • Loading branch information
AtilioA committed Oct 26, 2023
1 parent c0ceebd commit 87dc34b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/models/Caravan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export class Caravan implements ICaravan {
suit: CardSuit | null = null;
bid: number = 0;

/**
* Creates a new caravan instance.
* @param cards - Initial cards for the caravan.
* @param direction - Initial direction for the caravan.
* @param suit - Initial suit for the caravan.
* @param bid - Initial bid for the caravan.
*/
constructor(cards: ICard[] = [], direction: Direction | null = null, suit: CardSuit | null = null, bid: number = 0) {
this.cards = cards;
this.direction = direction;
Expand Down
40 changes: 39 additions & 1 deletion src/models/interfaces/ICaravan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,59 @@ import { CardSuit } from "../../constants/cardConstants";
import { Direction } from "../../enums/directions";
import { ICard } from "./ICard";

/**
* Defines the structure and functionality of a Caravan.
*/
export interface ICaravan {
/** A list of cards that are in the caravan. */
cards: ICard[];
/** The current direction of the caravan. */
direction: Direction | null;
/** The current suit of the caravan. */
suit: CardSuit | null;
/** The current bid of the caravan. */
bid: number;

/**
* Checks if the caravan is empty.
* @returns true if the caravan is empty, otherwise false.
*/
isEmpty(): boolean;

/**
* Retrieves the last valued card in the caravan.
* @returns the last valued card.
*/
getLastValuedCard(): ICard;

/**
* Adds a card to the caravan.
* @param card - The card to be added.
*/
addCard(card: ICard): void;

/**
* Determines if a card can be added to the caravan.
* @param card - The card to be checked.
* @returns true if the card can be added, otherwise false.
*/
canAddCard(card: ICard): boolean;

// Might not be needed (we'd just change the bid when cards are played)
/**
* Computes the total value of the caravan.
* @returns the total value.
*/
computeValue(): number;

/**
* Checks if the caravan is sold.
* @returns true if the bid is between 21 and 26, otherwise false.
*/
isSold(): boolean;

/**
* Disbands the caravan and returns its cards.
* @returns a list of cards from the disbanded caravan.
*/
disband(): ICard[];
}

0 comments on commit 87dc34b

Please sign in to comment.