A simple Node.js command-line game where you can earn and spend tickets in a fun Carnival Gift Shop simulation!
Buy gifts, add tickets, and manage your collection from the terminal.
The Carnival Gift Shop project is a playful interactive program built with JavaScript. It simulates a small shop where users can:
- View the list of gifts available.
- Add or spend tickets as currency.
- Purchase items from the shopβs inventory.
- Exit the shop after finishing their session.
Itβs mainly designed as a learning project to practice basic I/O, loops, arrays, object-oriented patterns, and control flow in JavaScript using a Node.js environment.
- π Browse a list of collectible gifts.
- πͺ Add and check available tickets.
- π Purchase gifts (with error handling for funds and invalid inputs).
- π§± Modify, remove, or add new items through the
Itemclass. - π₯ Runs entirely in the terminal using the
sync-inputmodule for input handling.
- The player starts with 0 tickets.
- The program displays the available gifts, each with a ticket cost.
- The main menu allows you to:
- Buy a gift
- Add tickets (up to 1000)
- Check ticket balance
- Show the complete gift list
- Exit the shop
Each action updates your sessionβs wallet and the available item inventory.
- Node.js v14 or newer
- The
sync-inputNPM module (npm install sync-input)
-
Clone this repository:
git clone https://github.com/<your-username>/carnival-gift-shop.git cd carnival-gift-shop
-
Install the required dependency:
npm install sync-input
-
Run the program:
node main.js
-
Follow the on-screen menu to interact with the shop!
WELCOME TO THE CARNIVAL GIFT SHOP!
Hello friend! Thank you for visiting the carnival!
Here's the list of gifts:
1- Teddy Bear, Cost: 10 tickets
2- Big Red Ball, Cost: 5 tickets
...
What do you want to do?
1-Buy a gift 2-Add tickets 3-Check tickets 4-Show gifts 5-Exit the shop
The project uses a single Item class to encapsulate object data and CRUD operations for gifts.
All logic for tickets, purchasing, and the main menu loop is handled in simple functions for readability and modularity.
If youβd like to extend it, consider:
- Adding a save/load system using JSON files.
- Introducing random events or ticket rewards.
- Improving input validation logic.
If youβd like to improve or expand this project:
- Fork the repository.
- Create a new branch (
feature/new-idea). - Commit and push your changes.
- Open a pull request with a description of your update.
You have a license to chill πΈ