You have a card game where each card has a color and an acquisition cost in gems. The card colors can be: G (Green), B (Blue), R (Red), Y (Yellow), P (Purple). The acquisition cost is represented by pairs of numbers and letters indicating the required quantity of gems of each color.
-
Top right corner: G
-
Bottom left corner: 1R2G3B (1 red gem, 2 green gems, 3 blue gems)
+-------------+ | G | | | | | | | | | | | | 1R2G3B | +-------------+
- The player has a balance of gems and a deck of cards.
- The gem balance and the deck of cards are independent.
-
Function
can_purchase
: Develop a function/methodcan_purchase
that checks if a player can purchase a card based on their available gem balance. -
Function
purchase
: Develop a function/methodpurchase
that deducts the gem balance of the player when purchasing a card and adds the card to the player's deck, provided they have sufficient balance.
- Ensure you have Docker installed on your system.
- Ensure you have Docker Compose installed on your system.
-
Clone the Repository
-
Build the Docker Image: Build the Docker image using Docker Compose:
docker compose build
-
Run the the tests in Docker Container: Run the Docker container using Docker Compose:
docker compose up
All tests:
cargo test
Specific tests:
cargo test --test <test_name>
cargo doc --open