You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.1 KiB
Python

#This is a script that writes rules and instructions
#First it sets variables
import os
import random
2 years ago
import urllib.request
#games = ["backgammon", "pokemon", "war"]
#Pull the content from games.txt
#Open games.txt file
#Read the game name list from the games.txt file
#Make a game name list
gamenames = open("text/games.txt").read().split("\n")
2 years ago
#print(type(gamenames))
#print(gamenames)
#Read the verbs list from the verbs.txt file
#Make a verbs list
verbs = open("text/verbs.txt").read().split("\n")
2 years ago
#print(type(verbs))
#print(verbs)
#Read the objects list from the objects.txt file
#Make a objects list
objects = open("text/object.txt").read().split("\n")
spaces = open("text/spaces.txt").read().split("\n")
themes = open("text/themes.txt").read().split("\n")
introductions = open("text/introductions.txt").read().split("\n")
2 years ago
#Waiting to be fixed <<<<
#tools = urllib.request.urlopen("http://pad.xpub.nl/p/SI19-prototyping-7-tools/export/txt").read().split("\n")
tools = open("text/tools.txt").read().split("\n")
def spaceremover (defspace):
for object in defspace:
2 years ago
if object == "":
defspace.remove("")
return defspace
2 years ago
objects = spaceremover(objects)
tools = spaceremover(tools)
2 years ago
verbs = spaceremover(verbs)
gamenames = spaceremover(gamenames)
themes = spaceremover(themes)
spaces = spaceremover(spaces)
introductions = spaceremover(introductions)
#new funtion quantifier
2 years ago
def quantifier (words):
2 years ago
amount = random.randint(0,7)
2 years ago
word = random.choice(words)
word = str(amount) + " " + word
if amount == 1 or amount == -1:
return word
2 years ago
if amount == 0:
word = word.replace("0 ","no ")
2 years ago
if word[-1] =="y":
word = word[0:-1]
#word = word.replace("y","")
2 years ago
return word + "ies"
2 years ago
return word + "s"
2 years ago
#print(type(objects))
#print(objects)
def dotprint(text):
printerpath = '/dev/usb/lp0'
if os.path.exists(printerpath):
os.system(f'echo "{text}"> { printerpath }')
print(text)
#object = ["teammate", "card", "turn", "place", "board", "dice", "nice", "backgammon"]
#verb = ["choose", "pick", "give", "burn", "cut"]
#Then it writes a title
dotprint("~*"*60)
dotprint("\n" + " " *10+"How to play " + random.choice(gamenames)+"\n")
dotprint(random.choice(introductions))
dotprint("\n" + "~*"*60 +"\n")
#Then it loops through instructions
for i in range(random.randrange(5,10)):
dotprint("Action " + str(random.randrange(100,1000)) + ": "+ random.choice(verbs) + " " + quantifier (objects) + " with " + random.choice(tools) + " from the " + random.choice(themes) + " section to " + random.choice(spaces))
2 years ago
#f"{a:02}"
dotprint("\n" + "~*"*60 +"\n")
dotprint("After you finish playing the game, please proceed to the pen plotter station to contribute in the collective writing process. (and answer the question How do we library that? or somethin specific) \n")
dotprint("""
wWWWw wWWWw
vVVVv (___) wWWWw (___) vVVVv
(___) ~Y~ (___) vVVVv ~Y~ (___)
~Y~ \| ~Y~ (___) |/ ~Y~
\| \ |/ \| / \~Y~/ \| \ |/
2 years ago
\\|// \\|// \\|/// \\|// \\|// \\\|///
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
""")