Like this article? You must log in first!

The Raffle Game

Categories: Tech | Pubby Cash Received:  10 | Click to Award

It would be fun to find ways for pubbies to spend and earn Pubby Cash. Purchasing a raffle ticket is one of the ways the admin team has developed. Let me explain how this is realized. 1. Create a table in the database with sufficient columns to record all relevant raffle related information. The columns are: raffle id, date raffle opened, date raffle closed, current raffle pool, max raffle pool, transaction activities (a list with player id), winner id, and raffle status. The table should be declared as a model and linked to the code. 2. When a player trying to buy a raffle ticket, the database will be queried for the most recent game. If the most recent game is closed, a new game will be created. When the max raffle pool has reached (100 Pubby Cash) in this case, the status of the game will be changed to a closed state. Random number will be generated to determine who is the winner. 3. Update the database with relevant info. The tables that will be affected are the cash table, message table, user table, and of course the raffle game table. For the cash table, record the purchase transaction details. If a player wins, insert an additional transaction on the amount that he/she won. For the message table, update the table with a new message sent to the winner. For the user table, all players' Pubby Cash balance should be updated. For the raffle game table, the game record should be updated. 4. Generate a plot visualizing the dynamic purchasing activities of pubbies involved in the raffle game. This would require a data visualization module "matplotlib", which will generate a bar chart plotting the number of tickets each pubby purchased on the x axis, and the name of each pubby who purchased ticket(s). Then, a raffle game is all set to go!


Published from: Pennsylvania US
Liked by: Evan Tang, Andy Tang, fnfOzvSR 

Daily Deals


MECHANICSBURG WEATHER