Advertisement
MRtecno98

TechCore V. 1.1.0

May 9th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.50 KB | None | 0 0
  1. import time , random
  2.  
  3. DICTIONARY = "<class 'dict'>"
  4. STRING = "<class 'str'>"
  5. INTEGER = "<class 'int'>"
  6. LIST = "<class 'list'>"
  7.  
  8.  
  9. #OBSOLETE!
  10. def textInput(endtarget) :
  11.     WARNMSG = """
  12.  
  13.    WARNING: STAI USANDO UNA VERSIONE OBSOLETA DELLA FUNZIONE!
  14.    USA LA FUNZIONE "editText" PIU' AGGIORNATA
  15.  
  16.  
  17.    """
  18.     print(WARNMSG)
  19.     time.sleep(5)
  20.     print("------------------------------------------------------------")
  21.     testo = []
  22.     while True:
  23.         riga = input()
  24.         if riga == endtarget :
  25.             break
  26.         testo.append(riga)
  27.  
  28.     fusedText = ""
  29.     for i in testo :
  30.         fusedText += i + "\n"
  31.     fusedText = fusedText[:-1]
  32.     return fusedText
  33.  
  34. def editText(baseText , endTarget , backTarget) :
  35.     baseTextSplit = baseText.split("\n")
  36.     newText = ""
  37.     print(baseText)
  38.     while True :
  39.         newLine = input()
  40.         if newLine == endTarget :
  41.             newText = "\n".join(baseTextSplit)
  42.             return newText
  43.         if newLine == backTarget :
  44.             del baseTextSplit[-1]
  45.             print("\n")
  46.             print("Testo Aggiornato:")
  47.             print("\n".join(baseTextSplit))
  48.             continue
  49.         else :
  50.             baseTextSplit.append(newLine)
  51.             continue
  52.  
  53. def createTable(title , lines , titleChar , lineSepChar , tableLen , delay) :
  54.     titleLine = title.center(tableLen , "=")
  55.     formattedLines = []
  56.     for x in lines :
  57.         y = x.ljust(tableLen - 3)
  58.         y = list(y)
  59.         y.insert(0 , lineSepChar + " ")
  60.         y.append(lineSepChar)
  61.         y = "".join(y)
  62.         formattedLines.append(y)
  63.     endLine = "=" * tableLen
  64.     formattedLines.insert(0 , titleLine)
  65.     formattedLines.append(endLine)
  66.  
  67.     if delay == 0 :
  68.         table = '\n'.join(formattedLines)
  69.         return table
  70.  
  71.     for z in formattedLines :
  72.         print(z)
  73.         time.sleep(delay)
  74.  
  75. def semplifyText(text) :
  76.     return text \
  77.     .lower() \
  78.     .replace("?" , "") \
  79.     .replace("!" , "") \
  80.     .replace("," , "") \
  81.     .replace("." , "") \
  82.     .replace("'" , "")
  83.  
  84. def saveInFile(x , fileName) :
  85.     try :
  86.        
  87.         file = open(fileName , "w")
  88.        
  89.         if str(type(x)) == DICTIONARY :
  90.             file.write("%s\n" % DICTIONARY)
  91.             for i in list(x.keys()) :
  92.                 file.write( \
  93.                 i + \
  94.                 "|" + \
  95.                 x[i] + \
  96.                 "\n" \
  97.                 )
  98.             return True
  99.                
  100.         elif str(type(x)) == STRING :
  101.             file.write("%s\n" % STRING)
  102.             file.write(x)
  103.             return True
  104.  
  105.         elif str(type(x)) == INTEGER :
  106.             file.write("%s\n" % INTEGER)
  107.             file.write(str(x))
  108.             return True
  109.  
  110.         elif str(type(x)) == LIST :
  111.             file.write("%s\n" % LIST)
  112.             for i in x :
  113.                 file.write(i)
  114.             return True
  115.        
  116.         else :
  117.             return False
  118.        
  119.     finally :
  120.         file.close()
  121.  
  122. def loadFromFile(fileName) :
  123.     try:
  124.         file = open(fileName , "r")
  125.         text = file.read()
  126.         lines = text.split("\n")
  127.  
  128.         if lines[-1] == "" :
  129.             del lines[-1]
  130.  
  131.         if lines[0] == STRING :
  132.             return lines[1]
  133.         elif lines[0] == INTEGER :
  134.             return int(line[1])
  135.         elif lines[0] == LIST :
  136.             List = []
  137.             for i in lines :
  138.                 if i == LIST :
  139.                     continue
  140.                 List.append(i)
  141.             return List
  142.         elif lines[0] == DICTIONARY :
  143.             dic = {}
  144.             for z in lines :
  145.                 if z == DICTIONARY :
  146.                     continue
  147.                 z = z.split("|")
  148.                 dic[z[0]] = z[1]
  149.             return dic
  150.     finally :
  151.         file.close()
  152.    
  153. def SCF() :
  154.     print("=========================================")
  155.     print("Sasso Carta Forbice remastered for Python")
  156.     print("      by NEGCommand & MRtecno98")
  157.     print("=========================================")
  158.     input("            Enter to start")
  159.  
  160.     print("\n\n\nInserire il numero di match(-1 per infinito)")
  161.     bo = 1
  162.     puntggutente = 0
  163.     puntggcomput = 0
  164.     while bo == 1:
  165.         try :
  166.             ms = int(input(">>> "))
  167.         except ValueError:
  168.             print("Inserisci un numero, non una lettera")
  169.         else:
  170.             bo = 0
  171.  
  172.     while ms != 0:
  173.         oggutente = input('\nInserisci un oggetto [Sasso|Carta|Forbice|Esci]: ')
  174.         oggcomp = random.randint(1, 3)
  175.    
  176.         if "e" in oggutente.lower() or oggutente.lower() == "esci" :
  177.             break
  178.    
  179.         if oggutente == 'Sasso' or "s" in oggutente or "S" in oggutente or oggutente == "sasso":
  180.             if oggcomp == 1:
  181.                 print('[Tu:Sasso ','Pc:'+'Sasso]','  PAREGGIO')
  182.             elif oggcomp == 2:
  183.                 print('[Tu:Sasso ','Pc:'+'Carta]','  HAI PERSO')
  184.                 puntggcomput = puntggcomput + 1
  185.             elif oggcomp == 3:
  186.                 print('[Tu:Sasso ','Pc:'+'Forbice]','  HAI VINTO')
  187.                 puntggutente = puntggutente + 1
  188.             ms = ms - 1
  189.         elif oggutente == 'Carta' or "c" in oggutente or "C" in oggutente or oggutente == "carta":
  190.             if oggcomp == 1:
  191.                 print('[Tu:Carta ','Pc:'+'Sasso]','  HAI VINTO')
  192.                 puntggutente = puntggutente + 1
  193.             elif oggcomp == 2:
  194.                 print('[Tu:Carta ','Pc:'+'Carta]','  PAREGGIO')
  195.             elif oggcomp == 3:
  196.                 print('[Tu:Carta ','Pc:'+'Forbice]','  HAI PERSO')
  197.                 puntggcomput = puntggcomput + 1
  198.             ms = ms - 1
  199.         elif oggutente == 'Forbice' or "f" in oggutente or "F" in oggutente or oggutente == "forbice":
  200.             if oggcomp == 1:
  201.                 print('[Tu:Forbice ','Pc:'+'Sasso]','  HAI PERSO')
  202.                 puntggcomput = puntggcomput + 1
  203.             elif oggcomp == 2:
  204.                 print('[Tu:Forbice ','Pc:'+'Carta]','  HAI VINTO')
  205.                 puntggutente = puntggutente + 1
  206.             elif oggcomp == 3:
  207.                 print('[Tu:Forbice ','Pc:'+'Forbice]','  PAREGGIO')
  208.             ms = ms - 1
  209.         else:
  210.             print("Inserire un oggetto valido")
  211.  
  212.     if puntggutente > puntggcomput :
  213.         print("\nTOTALE: [Tu:" + str(puntggutente) + "  " + "Pc:" + str(puntggcomput) + "]" , "HAI VINTO!")
  214.  
  215.     if puntggutente < puntggcomput :
  216.         print("\nTOTALE: [Tu:" + str(puntggutente) + "  " + "Pc:" + str(puntggcomput) + "]" , "HAI PERSO!")
  217.  
  218.     if puntggutente == puntggcomput :
  219.         print("\nTOTALE: [Tu:" + str(puntggutente) + "  " + "Pc:" + str(puntggcomput) + "]" , "PAREGGIO")
  220.  
  221.  
  222. def crypt(msg) :
  223.     return   msg \
  224.              .replace("a","0") \
  225.              .replace("b","1") \
  226.              .replace("c","2") \
  227.              .replace("d","3") \
  228.              .replace("e","4") \
  229.              .replace("f","5") \
  230.              .replace("g","6") \
  231.              .replace("h","7") \
  232.              .replace("i","8") \
  233.              .replace("j","9") \
  234.              .replace("k","!") \
  235.              .replace("l","\"") \
  236.              .replace("m","£") \
  237.              .replace("n","$") \
  238.              .replace("o","\%") \
  239.              .replace("p","&") \
  240.              .replace("q","/") \
  241.              .replace("r","(") \
  242.              .replace("s",")") \
  243.              .replace("t","=") \
  244.              .replace("u","?") \
  245.              .replace("v","^") \
  246.              .replace("w","|") \
  247.              .replace("x","#") \
  248.              .replace("y","*") \
  249.              .replace("z","§") \
  250.              .replace("_","°")
  251.  
  252. def deCrypt(msg) :
  253.     return   msg \
  254.              .replace("0","a") \
  255.              .replace("1","b") \
  256.              .replace("2","c") \
  257.              .replace("3","d") \
  258.              .replace("4","e") \
  259.              .replace("5","f") \
  260.              .replace("6","g") \
  261.              .replace("7","h") \
  262.              .replace("8","i") \
  263.              .replace("9","j") \
  264.              .replace("!","k") \
  265.              .replace("\"","l") \
  266.              .replace("£","m") \
  267.              .replace("$","n") \
  268.              .replace("%","o") \
  269.              .replace("&","p") \
  270.              .replace("/","q") \
  271.              .replace("(","r") \
  272.              .replace(")","s") \
  273.              .replace("=","t") \
  274.              .replace("?","u") \
  275.              .replace("^","v") \
  276.              .replace("|","w") \
  277.              .replace("#","x") \
  278.              .replace("*","y") \
  279.              .replace("§","z") \
  280.              .replace("°","_")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement