Updated to make script write file to card.txt
This commit is contained in:
parent
8f2018b585
commit
175176be6e
120
generate_card.py
120
generate_card.py
@ -43,38 +43,52 @@ ROWS = 5
|
||||
# We will pull values for the bingo squares from here.
|
||||
# A 'string' is a series of characters enclosed in quotes
|
||||
squares = [
|
||||
"Proposal!",
|
||||
"Secret Revealed!",
|
||||
"Christmas Party",
|
||||
"Santa vists",
|
||||
"Lead is royalty",
|
||||
"Gingerbread",
|
||||
"Empty coffee cups",
|
||||
"Hot chocolate",
|
||||
"Confession of a lie or mistake",
|
||||
"Evil developers",
|
||||
"Mistletoe!",
|
||||
"Unexpected Small Town Visit",
|
||||
"Leads are Trapped Together",
|
||||
"Lead Who Works as Baker or Florist",
|
||||
"Last Minute Rescue",
|
||||
"Amicable Break Up",
|
||||
"Mistaken Identity",
|
||||
"Christmas-Themed Character or Town Name",
|
||||
"Green Sweater",
|
||||
"A Contest",
|
||||
"Surprise Relative",
|
||||
"Sparkling Wine",
|
||||
"Snippy Comment about Lack of Kids",
|
||||
"Someone Gets a Second Chance",
|
||||
"Cute Moppet",
|
||||
"Giant Candy Cane",
|
||||
"Christmas Miracle",
|
||||
"Christmas Tree or Lights Lighting",
|
||||
"LGBTQ Character",
|
||||
"Neglectful OG Love Interest",
|
||||
"Meet Cute!",
|
||||
"Fainting or Feeling Sick",
|
||||
"BIPOC Person has a Lead Role",
|
||||
"Christmas Dance",
|
||||
"Inappropriate High Heels or Outfit",
|
||||
"We Should Have Had Sex but Halmark",
|
||||
"Santa Visit",
|
||||
"Lead Who Works in Marketing or Event Planning",
|
||||
"Love Interest is Uber Wealthy or Royalty"
|
||||
"Saving a landmark",
|
||||
"Interrupted smooch",
|
||||
"Fake relationship",
|
||||
"Lead who works in real estate",
|
||||
"Big romantic gesture",
|
||||
"Secret identity",
|
||||
"Unexpected visitor",
|
||||
"Not a couple mistaken as a couple",
|
||||
"Untrustworthy person in a suit",
|
||||
"US Flag",
|
||||
"Literal fall into someone's arms",
|
||||
"Someone returns to hometown",
|
||||
"Christmas market",
|
||||
"Snowstorm",
|
||||
"Friends to lovers",
|
||||
"Christmas wedding",
|
||||
"Pregnant!",
|
||||
"Family heirloom",
|
||||
"Living in home you can't afford",
|
||||
"Charity event",
|
||||
"Homemade decorations",
|
||||
"Someone gets a promotion",
|
||||
"Unreasonable deadline",
|
||||
"Flirty outdoor winter activity",
|
||||
"Prevented from attending or staying at event",
|
||||
"Breakup",
|
||||
"Failed romantic gesture",
|
||||
"Lead who owns a business",
|
||||
"Real snow",
|
||||
"Contract or business deal",
|
||||
"Red coat",
|
||||
"A misunderstanding",
|
||||
"Giant, shiny big city offices",
|
||||
"Change of heart",
|
||||
"Empty gift boxes or bags",
|
||||
"Snow falling",
|
||||
"Empty coffee cups",
|
||||
"Precocious child",
|
||||
]
|
||||
|
||||
|
||||
@ -83,52 +97,57 @@ squares = [
|
||||
# If there are no parameters, use an empty ()
|
||||
# functions make it easier to do the same thing over again.
|
||||
|
||||
def print_dash_line (): # Python uses indentation to organize code
|
||||
print("+", end='')
|
||||
def make_dash_line (): # Python uses indentation to organize code
|
||||
output = "+"
|
||||
for i in range(SQUARES_PER_ROW):
|
||||
for j in range(SQUARE_LENGTH):
|
||||
print("-", end='')
|
||||
output += "="
|
||||
|
||||
print("+", end='')
|
||||
output += "+"
|
||||
|
||||
print("\n",end='') # Here we are still inside the function, but outside
|
||||
# the loop
|
||||
output += "\n" # Here we are still inside the function, but outside
|
||||
return output # the loop
|
||||
|
||||
|
||||
# This function will take the row of the square, and the string and
|
||||
# print out the padded section of the string for this line
|
||||
def get_square_text(row, s):
|
||||
wrapped_strings = textwrap.wrap(str(s),width=SQUARE_LENGTH)
|
||||
output = ""
|
||||
|
||||
print("|", end='')
|
||||
string_section = "test string".center(SQUARE_LENGTH)
|
||||
if row < len(wrapped_strings):
|
||||
string_section = wrapped_strings[row]
|
||||
else:
|
||||
string_section = " "
|
||||
return string_section.center(SQUARE_LENGTH)
|
||||
|
||||
return output + string_section.center(SQUARE_LENGTH)
|
||||
|
||||
|
||||
|
||||
|
||||
# The function print_row will take 5 strings and print a bingo row
|
||||
def print_row (row_strings):
|
||||
def make_row (row_strings):
|
||||
# each square will be 5 rows high and 12 chars across. We can adjust
|
||||
# this to make the layout better
|
||||
|
||||
output = ""
|
||||
for i in range(SQUARE_HEIGHT):
|
||||
#For each line in the row, get the part of the string
|
||||
#Which will be printed on this line
|
||||
for j in range(SQUARES_PER_ROW):
|
||||
print( get_square_text(i, row_strings[j]), end='')
|
||||
output += "|"
|
||||
output += get_square_text(i, row_strings[j])
|
||||
|
||||
print("|")
|
||||
output += "|\n"
|
||||
|
||||
return output
|
||||
|
||||
def print_card():
|
||||
# At random, pull values from "squares" and print out 5 rows of bingo card
|
||||
selected = [-1]
|
||||
output = ""
|
||||
for i in range(ROWS):
|
||||
print_dash_line()
|
||||
output += make_dash_line()
|
||||
|
||||
# get 5 new picks
|
||||
picks = []
|
||||
@ -148,7 +167,16 @@ for i in range(ROWS):
|
||||
picks.append(squares[pick])
|
||||
|
||||
# Now print the row with those picks
|
||||
print_row(picks)
|
||||
output += make_row(picks)
|
||||
|
||||
# Print last bottom line
|
||||
print_dash_line()
|
||||
output += make_dash_line()
|
||||
return output
|
||||
|
||||
card = print_card()
|
||||
|
||||
with open("card.txt", "w") as f:
|
||||
f.write(card)
|
||||
|
||||
print("Bingo card has been created as card.txt")
|
||||
input("Enter to exit...")
|
Loading…
Reference in New Issue
Block a user