Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time , random
- DICTIONARY = "<class 'dict'>"
- STRING = "<class 'str'>"
- INTEGER = "<class 'int'>"
- LIST = "<class 'list'>"
- def textInput(endtarget) :
- testo = []
- while True:
- riga = input()
- if riga == endtarget :
- break
- testo.append(riga)
- fusedText = ""
- for i in testo :
- fusedText += i + "\n"
- fusedText = fusedText[:-1]
- return fusedText
- def createTable(title , lines , titleChar , lineSepChar , tableLen , delay) :
- titleLine = title.center(tableLen , "=")
- formattedLines = []
- for x in lines :
- y = x.ljust(tableLen - 3)
- y = list(y)
- y.insert(0 , lineSepChar + " ")
- y.append(lineSepChar)
- y = "".join(y)
- formattedLines.append(y)
- endLine = "=" * tableLen
- formattedLines.insert(0 , titleLine)
- formattedLines.append(endLine)
- if delay == 0 :
- table = '\n'.join(formattedLines)
- return table
- for z in formattedLines :
- print(z)
- time.sleep(delay)
- def semplifyText(text) :
- return text \
- .lower() \
- .replace("?" , "") \
- .replace("!" , "") \
- .replace("," , "") \
- .replace("." , "") \
- .replace("'" , "")
- def saveInFile(x , fileName) :
- try :
- file = open(fileName , "w")
- if str(type(x)) == DICTIONARY :
- file.write("%s\n" % DICTIONARY)
- for i in list(x.keys()) :
- file.write( \
- i + \
- "|" + \
- x[i] + \
- "\n" \
- )
- return True
- elif str(type(x)) == STRING :
- file.write("%s\n" % STRING)
- file.write(x)
- return True
- elif str(type(x)) == INTEGER :
- file.write("%s\n" % INTEGER)
- file.write(str(x))
- return True
- elif str(type(x)) == LIST :
- file.write("%s\n" % LIST)
- for i in x :
- file.write(i)
- return True
- else :
- return False
- finally :
- file.close()
- def loadFromFile(fileName) :
- try:
- file = open(fileName , "r")
- text = file.read()
- lines = text.split("\n")
- if lines[-1] == "" :
- del lines[-1]
- if lines[0] == STRING :
- return lines[1]
- elif lines[0] == INTEGER :
- return int(line[1])
- elif lines[0] == LIST :
- List = []
- for i in lines :
- if i == LIST :
- continue
- List.append(i)
- return List
- elif lines[0] == DICTIONARY :
- dic = {}
- for z in lines :
- if z == DICTIONARY :
- continue
- z = z.split("|")
- dic[z[0]] = z[1]
- return dic
- finally :
- file.close()
- def SCF() :
- print("=========================================")
- print("Sasso Carta Forbice remastered for Python")
- print(" by NEGCommand & MRtecno98")
- print("=========================================")
- input(" Enter to start")
- print("\n\n\nInserire il numero di match(-1 per infinito)")
- bo = 1
- puntggutente = 0
- puntggcomput = 0
- while bo == 1:
- try :
- ms = int(input(">>> "))
- except ValueError:
- print("Inserisci un numero, non una lettera")
- else:
- bo = 0
- while ms != 0:
- oggutente = input('\nInserisci un oggetto [Sasso|Carta|Forbice|Esci]: ')
- oggcomp = random.randint(1, 3)
- if "e" in oggutente.lower() or oggutente.lower() == "esci" :
- break
- if oggutente == 'Sasso' or "s" in oggutente or "S" in oggutente or oggutente == "sasso":
- if oggcomp == 1:
- print('[Tu:Sasso ','Pc:'+'Sasso]',' PAREGGIO')
- elif oggcomp == 2:
- print('[Tu:Sasso ','Pc:'+'Carta]',' HAI PERSO')
- puntggcomput = puntggcomput + 1
- elif oggcomp == 3:
- print('[Tu:Sasso ','Pc:'+'Forbice]',' HAI VINTO')
- puntggutente = puntggutente + 1
- ms = ms - 1
- elif oggutente == 'Carta' or "c" in oggutente or "C" in oggutente or oggutente == "carta":
- if oggcomp == 1:
- print('[Tu:Carta ','Pc:'+'Sasso]',' HAI VINTO')
- puntggutente = puntggutente + 1
- elif oggcomp == 2:
- print('[Tu:Carta ','Pc:'+'Carta]',' PAREGGIO')
- elif oggcomp == 3:
- print('[Tu:Carta ','Pc:'+'Forbice]',' HAI PERSO')
- puntggcomput = puntggcomput + 1
- ms = ms - 1
- elif oggutente == 'Forbice' or "f" in oggutente or "F" in oggutente or oggutente == "forbice":
- if oggcomp == 1:
- print('[Tu:Forbice ','Pc:'+'Sasso]',' HAI PERSO')
- puntggcomput = puntggcomput + 1
- elif oggcomp == 2:
- print('[Tu:Forbice ','Pc:'+'Carta]',' HAI VINTO')
- puntggutente = puntggutente + 1
- elif oggcomp == 3:
- print('[Tu:Forbice ','Pc:'+'Forbice]',' PAREGGIO')
- ms = ms - 1
- else:
- print("Inserire un oggetto valido")
- if puntggutente > puntggcomput :
- print("\nTOTALE: [Tu:" + str(puntggutente) + " " + "Pc:" + str(puntggcomput) + "]" , "HAI VINTO!")
- if puntggutente < puntggcomput :
- print("\nTOTALE: [Tu:" + str(puntggutente) + " " + "Pc:" + str(puntggcomput) + "]" , "HAI PERSO!")
- if puntggutente == puntggcomput :
- print("\nTOTALE: [Tu:" + str(puntggutente) + " " + "Pc:" + str(puntggcomput) + "]" , "PAREGGIO")
- def crypt(msg) :
- return msg \
- .replace("a","0") \
- .replace("b","1") \
- .replace("c","2") \
- .replace("d","3") \
- .replace("e","4") \
- .replace("f","5") \
- .replace("g","6") \
- .replace("h","7") \
- .replace("i","8") \
- .replace("j","9") \
- .replace("k","!") \
- .replace("l","\"") \
- .replace("m","£") \
- .replace("n","$") \
- .replace("o","\%") \
- .replace("p","&") \
- .replace("q","/") \
- .replace("r","(") \
- .replace("s",")") \
- .replace("t","=") \
- .replace("u","?") \
- .replace("v","^") \
- .replace("w","|") \
- .replace("x","#") \
- .replace("y","*") \
- .replace("z","§") \
- .replace("_","°")
- def deCrypt(msg) :
- return msg \
- .replace("0","a") \
- .replace("1","b") \
- .replace("2","c") \
- .replace("3","d") \
- .replace("4","e") \
- .replace("5","f") \
- .replace("6","g") \
- .replace("7","h") \
- .replace("8","i") \
- .replace("9","j") \
- .replace("!","k") \
- .replace("\"","l") \
- .replace("£","m") \
- .replace("$","n") \
- .replace("%","o") \
- .replace("&","p") \
- .replace("/","q") \
- .replace("(","r") \
- .replace(")","s") \
- .replace("=","t") \
- .replace("?","u") \
- .replace("^","v") \
- .replace("|","w") \
- .replace("#","x") \
- .replace("*","y") \
- .replace("§","z") \
- .replace("°","_")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement