Advertisement
MRtecno98

TechCore V.1.2.0

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