Skip to content

Allows a simple, proven and non-falsifiable lottery draw

License

Notifications You must be signed in to change notification settings

crypt-online/lotery-drawer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lotery-drawer

Lotery-drawer is a simple, proven and non-falsifiable lottery draw tool.

This tool can be used to draw a lotery in a provable way. The draw is random but will always return the same result when given the same lotery datas.

Documentation

Installation

  • Python >=3.6 is required to run this program
  • Install the package by running : pip install lotery-drawer --user

Usage

You can simply print on the console the result of the lotery :

  • Create your own lotery data json, and place it into the config directory for exemple.
  • Call the main file with your json path : python3 main.py "config/dataLotery.json"
  • Then the console will output the result

You can also directly interface your program with the library :

from lotery_drawer import Drawer

drawer = Drawer()
result = drawer.draw(dataLotery)

Here an example of the lotery data json :

{
  "endTimestamp": 1589289392,
  "prizes": [
    {"name":  "1000 HXRO", "nb":  1},
    {"name":  "500 HXRO", "nb":  1},
    {"name":  "200 HXRO", "nb":  5},
    {"name":  "100 HXRO", "nb":  10}
  ],
  "tickets": {
    "player_a": 10,
    "player_b": 20,
    "player_c": 30,
    "player_d": 40,
    "player_e": 150
  }
}
  • endTimestamp: The end date of the lotery. It is only used to generate a seed for random functions
  • prizes: A list of the prizes of the lotery. Each prize can have one or more winning tickets (nb) and have a name (name)
  • tickets: A dict of the tickets at the end of the lotery. Each element of the dict is a player, the number associated is the number of tickets in his possession.

The tool will draw as winning tickets as there is prizes, and return an array containing the usernames and the prizes won. Note that if a ticket is won, it is removed from the tickets list for the next prizes.

Here an exemple of the result when using the file config/dataLotery.json in the repository :

[
  {"prizeName": "1000 HXRO", "username": "player_e"}, 
  {"prizeName": "500 HXRO", "username": "player_a"}, 
  {"prizeName": "200 HXRO", "username": "player_e"}, 
  {"prizeName": "200 HXRO", "username": "player_e"}, 
  {"prizeName": "200 HXRO", "username": "player_e"}, 
  {"prizeName": "200 HXRO", "username": "player_e"}, 
  {"prizeName": "200 HXRO", "username": "player_d"}, 
  {"prizeName": "100 HXRO", "username": "player_d"}, 
  {"prizeName": "100 HXRO", "username": "player_e"}, 
  {"prizeName": "100 HXRO", "username": "player_d"}, 
  {"prizeName": "100 HXRO", "username": "player_d"}, 
  {"prizeName": "100 HXRO", "username": "player_b"}, 
  {"prizeName": "100 HXRO", "username": "player_e"}, 
  {"prizeName": "100 HXRO", "username": "player_e"}, 
  {"prizeName": "100 HXRO", "username": "player_c"}, 
  {"prizeName": "100 HXRO", "username": "player_c"}, 
  {"prizeName": "100 HXRO", "username": "player_d"}
 ]

About

Allows a simple, proven and non-falsifiable lottery draw

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published