This project simulates the Italian lottery game.
The lottery game (or "Lotto") is based on an extraction of numbers with cash prizes in case of winning.
In particular, the Lotto game involves the extraction of 5 numbers (between 1 and 90) for each of 10 italian cities:
- Bari
- Cagliari
- Firenze
- Genova
- Milano
- Napoli
- Palermo
- Roma
- Torino
- Venezia
It is possible to bet until 10 numbers and choose different types of play:
- Ambata: guess one extracted number
- Ambo: guess two extracted numbers
- Terno: guess three extracted numbers
- Quaterna: guess four extracted numbers
- Cinquina: guess five extracted numbers
More about the Italian lottery game (written in Italian):
- https://www.sisal.it/lotto/come-si-gioca
- https://www.servizitelevideo.rai.it/televideo/pub/pagina.jsp?p=786&s=0&r=Nazionale&idmenumain=0
First of all, you need to have Node.js installed. To check if it is already installed, run this command in your terminal:
node -vIf you have it installed, you will see the version, for example v18.14.2. If not, download it here: Download.
After that, download the folder of this project by clicking on the green button "Code" and then select "Download ZIP", extract it then open it with your favorite IDE. Alternatively, clone the repository with the command:
git clone https://github.com/EvaLa94/lotto-game.gitOnce you have opened the folder in your IDE, in order to install the dependencies, run the following command in your terminal:
npm installIn order to start a new game, run the following command in your terminal:
npm startWhen you launch the game, you will find all the options that the game offers.
In order to add a (new) ticket, type 1 in the console to select the option "Add a new ticket".
First of all, you are presented with the option to choose the ticket's type. You can select the type by typing in the console the corresponding number (from 1 to 5). If you wish to cancel the ticket creation, type 0 in order to cancel the operation and come back to the menu options. It will be possible to cancel the operation in every step of the ticket creation, by entering 0 in the console.
After choosing the ticket type, you should choose the city to bet on. You can choose on the cities in the list, or you can choose "Tutte" to select them all.
The next step is to choose how many numbers to generate: the numbers will be automatically generated by the application. There are a few limitations in this step:
- The maximum numbers' quantity is set to 10. If you enter a number greater than 10, you will receive an error message and it will be possiblet to try again.
- The minimum numbers' quantity depends on the ticket's type chosen:
- Ambata: at lest 1
- Ambo: at lest 2
- Terno: at lest 3
- Quaterna: at lest 4
- Cinquina: at lest 5
The last step is to choose how much to bet on the ticket. The only limitation here is that a number greater than zero should be entered.
After completing the procedure, you will receive a message confirming that the ticked as been added.
In order to print the tickets that have been previously added to the game, select 2 in the menu options.
All the tickets that have been previously created will be printed in the console in a nice format.
Please be aware that if you select this option before creating any ticket, you will receive an error message, since there aren't any tickets to be printed.
In order to create a new extraction, select 3 in the menu options.
If the extraction was successfull, a confirmation message will be printed in the console.
It will be possible to perform an extraction:
- Before checking for winning tickets
- Even after checking for winning tickets, but only if none of the tickets were winning.
If you try to perform a new extraction after one of the tickets was winning, you will get a message error:
In order to print the extraction, select 4 in the menu options.
If an extraction has already been performed, the extracted numbers for each city will be printed in the console:
If you try this option before performing an extraction, you will receive an error message:
After adding at least one ticket and performing an extraction, it will be possible to check if the ticket(s) is/are winning.
The winning tickets will be printed in the console, with their corresponding gross and net winning amount:
If none of the tickets are winning, a message will inform you:
Error messages will be printed instead if:
- The extraction hasn't been performed yet:
- A ticket hasn't been added yet:
At any point of the game, select 0 in the menu options if you wish to quit the game.
A message will be printed to confirm that the game has ended:
Be aware that after exiting the game, any performed action will be reset.
To access the technical documentation, run in the terminal the following command:
npm run build-docsA new folder called docs will be created. Open the file index.html in the browser in order to access to the complete technical documentation.
















