Skip to content

Instantly share code, notes, and snippets.

@ryan2clw
Created August 19, 2019 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan2clw/040d428c9ebefb2060711402dbe7e607 to your computer and use it in GitHub Desktop.
Save ryan2clw/040d428c9ebefb2060711402dbe7e607 to your computer and use it in GitHub Desktop.
Models for bingo
"""
We have 4 models that interact with each other to form the game play.
The card and row tables will form the data for the bingo cards.
The match_smiley table is populated from the card/row tables, where each column is a certain number on the card,
so the row would be the group of numbers that make a smiley-face.
We'll decrement the 'left' property of match_smiley as balls are called that match.
"""
from django.db import models
# keep Card and Row models from before
class Ball(models.Model):
"""
The ball in a ball-blower. Represents a random number 1-75.
"""
num_value = models.IntegerField()
updated_at = models.DateTimeField(null=True)
is_played = models.BooleanField(default=False)
def __str__(self):
return self.num_value
class MatchSmiley(models.Model):
""" Derived from card data, each column is a number on a specific card"""
one_value = models.CharField(max_length=3)
two_value = models.CharField(max_length=3)
three_value = models.CharField(max_length=3)
four_value = models.CharField(max_length=3)
five_value = models.CharField(max_length=3)
six_value = models.CharField(max_length=3)
seven_value = models.CharField(max_length=3)
eight_value = models.CharField(max_length=3)
nine_value = models.CharField(max_length=3)
ten_value = models.CharField(max_length=3)
eleven_value = models.CharField(max_length=3)
twelve_value = models.CharField(max_length=3)
thirteen_value = models.CharField(max_length=3)
fourteen_value = models.CharField(max_length=3)
needed_to_win = models.IntegerField()
left = models.IntegerField()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment