Advertisement
MRtecno98

TechCore V. 1.0.0

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