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