Advertisement
PXYC

Name Generator

Aug 18th, 2012
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.21 KB | None | 0 0
  1. """
  2. Random name generator by PXYC
  3.  
  4. To add syllables:
  5. Add to the list of syllables (namelist)
  6. Make sure it is in quotes and has a comma after it.
  7. ---
  8. To change the syllables, just change it in the list
  9.  
  10. Enjoy! Don't post anywhere else without giving me credit! Thanks!
  11. """
  12.  
  13. import shutil # Import module to move the file if it isn't in the AoSDir
  14. import os # Import module to check if it's in the AoSDir
  15. import sys # Import module to check current directory
  16. import time # Sleep
  17. import ConfigParser # Import the module to parse dat config
  18. from random import choice, randint # Import the function to pick a syllable
  19.  
  20. clantag1 = [
  21.     "A",
  22.     "B",
  23.     "C",
  24.     "D",
  25.     "E",
  26.     "F",
  27.     "G",
  28.     "H",
  29.     "I",
  30.     "J",
  31.     "K",
  32.     "L",
  33.     "M",
  34.     "N",
  35.     "O",
  36.     "P",
  37.     "H",
  38.     "I",
  39.     "J",
  40.     "K",
  41.     "L",
  42.     "M",
  43.     "N",
  44.     "O",
  45.     "P",
  46.     "Q",
  47.     "R",
  48.     "S",
  49.     "T",
  50.     "U", #This is getting annoying to type
  51.     "V",
  52.     "W",
  53.     "X",
  54.     "Y",
  55.     "Z"
  56.     ]
  57.  
  58. syl1 = [
  59.     "Da",
  60.     "Di",
  61.     "Do",
  62.     "Er",
  63.     "Et",
  64.     "En",
  65.     "Ev",
  66.     "Da",
  67.     "Mi",
  68.     "Est",
  69.     "Os",
  70.     "Ta",
  71.     "Mos",
  72.     "Ye",
  73.     "Yi",
  74.     "Za",
  75.     "Zo",
  76.     "Te",
  77.     "Yap",
  78.     "Moz",
  79.     "Yot",
  80.     "Yit",
  81.     "Stu",
  82.     "Mor",
  83.     "Dan",
  84.     "Fas",
  85.     "Dul",
  86.     "Fan",
  87.     "Ho",
  88.     "Doy",
  89.     "Far",
  90.     "Kor",
  91.     "Fad",
  92.     "Dat",
  93.     "Fis",
  94.     "Art",
  95.     "Ant",
  96.     "Ara",
  97.     "Aft",
  98.     "Ana",
  99.     "Asa"
  100.     ]
  101. syl2 = [
  102.     "st",
  103.     "ne",
  104.     "re",
  105.     "ta",
  106.     "fa",
  107.     "de",
  108.     "ta",
  109.     "do",
  110.     "in",
  111.     "ta",
  112.     "ny",
  113.     "st",
  114.     "yo",
  115.     "ak",
  116.     "ey",
  117.     "eh",
  118.     "en",
  119.     "et",
  120.     "un",
  121.     "ud",
  122.     "us"
  123.     ]
  124. syl3 = [
  125.     "a",
  126.     "b",
  127.     "c",
  128.     "d",
  129.     "e",
  130.     "f",
  131.     "g",
  132.     "h",
  133.     "i",
  134.     "j",
  135.     "k",
  136.     "l",
  137.     "m",
  138.     "n",
  139.     "o",
  140.     "p",
  141.     "r",
  142.     "s",
  143.     "t",
  144.     "u",
  145.     "v",
  146.     "w",
  147.     "x",
  148.     "y",
  149.     "z",
  150.     "an",
  151.     "ra",
  152.     "ts",
  153.     "fs",
  154.     "ad",
  155.     "st",
  156.     "ra"
  157.     ]
  158.  
  159. def generate():
  160.     syll1 = choice(syl1)
  161.     syll2 = choice(syl2)
  162.     syll3 = choice(syl3)
  163.     syllist1 = list(syll1)
  164.     syllist2 = list(syll2)
  165.     syllist3 = list(syll3)
  166.     if syllist1[len(syllist1) - 1] == syllist2[0] or syllist2[len(syllist2) - 1] == syllist3[0]: # Check if awkward looking name like Esttat
  167.         generate() # redo
  168.     else:
  169.         global name
  170.         numclan = randint(1, 4)
  171.         if numclan == 4:
  172.             clantag = choice(clantag1) + choice(clantag1) + choice(clantag1)
  173.             name = "[" + clantag + "]" + syll1 + syll2 + syll3
  174.         else:
  175.             name = syll1 + syll2 + syll3
  176. def checkaosdir():
  177.     if not os.path.isfile('config.ini'): # Checks if a config.ini exists where the file is.
  178.         return False
  179.     else:
  180.         return True
  181. def setname():
  182.     generate()
  183.     parser = ConfigParser.SafeConfigParser() # blahblah
  184.     parser.read('config.ini') # Read config.ini
  185.     parser.set('client', 'name', '%s' % (name)) # Set the name
  186.     parser.write(open('config.ini', 'w')) # Then save the INI file to config.ini
  187.     newname = parser.get('client', 'name') + "." # Get the new name
  188.     print "Success! New name is " + newname # Confirm new name
  189.     time.sleep(1) # Close the window in 1 second
  190.  
  191. if checkaosdir() is False:
  192.     print "Put it in your Ace of Spades directory!" # Alert
  193.     pathtoaos = raw_input('Enter path to AoS: ') # Prompts the user for path to Ace of Spades directory
  194.     curpath = sys.argv[0] # Gets current path of the program
  195.     if os.path.isfile('%s\\namegenerator.exe' % (pathtoaos)): # If a namegenerator.exe already exists:
  196.             os.remove('%s\\namegenerator.exe' % (pathtoaos)) # Delete it, making room for a new one
  197.     elif os.path.isfile('%s\\namegenerator.py' % (pathtoaos)): # If a namegenerator.py already exists:
  198.             os.remove('%s\\namegenerator.py' % (pathtoaos)) # Delete it, making room for a new one
  199.     shutil.move(curpath, pathtoaos) # Moves the program to your Ace of Spades directory
  200.     print "Done. Copied to Ace of Spades directory. Run from there to generate a name." # Confirmation
  201.     time.sleep(1) # Close in 1 second
  202. else:
  203.     setname()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement