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.

71 lines
2.2 KiB
Python

#This is a script that writes rules and instructions
#First it sets variables
import random
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")
#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")
#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")
#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:
if object == "":
defspace.remove("")
return defspace
objects = spaceremover(objects)
verbs = spaceremover(verbs)
gamenames = spaceremover(gamenames)
#new funtion quantifier
def quantifier (words):
amount = random.randint(0,7)
word = random.choice(words)
word = str(amount) + " " + word
if amount == 1 or amount == -1:
return word
if amount == 0:
word = word.replace("0 ","no ")
if word[-1] =="y":
word = word[0:-1]
#word = word.replace("y","")
return word + "ies"
return word + "s"
#print(type(objects))
#print(objects)
#object = ["teammate", "card", "turn", "place", "board", "dice", "nice", "backgammon"]
#verb = ["choose", "pick", "give", "burn", "cut"]
#Then it writes a title
print(" " *10+"How to play " + random.choice(gamenames))
print("~*"*30)
#Then it loops through instructions
for i in range(random.randrange(1,24)):
print(" " *10+"Rule " + str(i+1) + ": "+ random.choice(verbs) + " " + quantifier (objects) + " with " + random.choice(tools))
print("""
wWWWw wWWWw
vVVVv (___) wWWWw (___) vVVVv
(___) ~Y~ (___) vVVVv ~Y~ (___)
~Y~ \| ~Y~ (___) |/ ~Y~
\| \ |/ \| / \~Y~/ \| \ |/
\\|// \\|// \\|/// \\|// \\|// \\\|///
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
""")