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