Skip to content

EvaLa94/lotto-game

Repository files navigation

Lottery game 💰

Table of Contents

Italian Lottery Game

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):

Install and Run the Project

First of all, you need to have Node.js installed. To check if it is already installed, run this command in your terminal:

node -v

If 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.git

Once you have opened the folder in your IDE, in order to install the dependencies, run the following command in your terminal:

npm install

In order to start a new game, run the following command in your terminal:

npm start

How To Play

When you launch the game, you will find all the options that the game offers.

Menu Options

1. Add A Ticket

In order to add a (new) ticket, type 1 in the console to select the option "Add a new ticket".

Ticket type

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.

Ticket city

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.

Ticket quantity

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

Ticket bet

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.

Ticket added

After completing the procedure, you will receive a message confirming that the ticked as been added.

2. Print Tickets

In order to print the tickets that have been previously added to the game, select 2 in the menu options.

Ticket printed

All the tickets that have been previously created will be printed in the console in a nice format.

Print Ticket Error

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.

3. Extract Numbers

In order to create a new extraction, select 3 in the menu options.

Extraction

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:

Extraction Error

4. Print The Extraction

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:

Extraction Printed

If you try this option before performing an extraction, you will receive an error message:

Extraction Error Not Performed

5. Check For Winning Tickets And Print Them

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:

Winning Ticket

If none of the tickets are winning, a message will inform you:

No Winning Ticket

Error messages will be printed instead if:

  • The extraction hasn't been performed yet:

Missing Extraction

  • A ticket hasn't been added yet:

Missing Ticket

0. Exit Game

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:

Exit

Be aware that after exiting the game, any performed action will be reset.

Technical documentation

To access the technical documentation, run in the terminal the following command:

npm run build-docs

A new folder called docs will be created. Open the file index.html in the browser in order to access to the complete technical documentation.

About

A project to simulate the creation of lottery tickets and the extraction of lottery numbers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors