diff --git a/firstsyllable.txt b/firstsyllable.txt deleted file mode 100644 index ce677c2..0000000 --- a/firstsyllable.txt +++ /dev/null @@ -1,22 +0,0 @@ -Da -Ka -Ta -Ra -Cus -Iss -Aba -Ton -Ar -At -Cu -Da -Ta -Ab -Ba -Meno -Tor -Wir -Wen -Ein -Dev -Ken \ No newline at end of file diff --git a/kinggotchi.py b/kinggotchi.py index 0557d0f..2bf138c 100644 --- a/kinggotchi.py +++ b/kinggotchi.py @@ -11,7 +11,7 @@ class Kinggotchi: name = '' def __init__(self): - self.name = util.generateName() + self.name = Util.generateName() def add_village(self, mayor): self.myvillages.append(mayor) diff --git a/mayorgotchi.py b/mayorgotchi.py index 1fe5661..49b2876 100644 --- a/mayorgotchi.py +++ b/mayorgotchi.py @@ -4,6 +4,7 @@ from tamagotchi import Tamagotchi import random from config import * +from util import Util class Mayorgotchi: mygotchis = [] @@ -12,7 +13,7 @@ class Mayorgotchi: def __init__(self, list_of_tamagotchis): self.mygotchis = list_of_tamagotchis - self.name = util.generateName() + self.name = Util.generateName() def remove_corpses(self): for n in self.mygotchis: diff --git a/util.py b/util.py index 830fa60..f8e74b2 100644 --- a/util.py +++ b/util.py @@ -4,6 +4,7 @@ from tamagotchi import Tamagotchi import random from config import * +import os class Util: @@ -26,23 +27,15 @@ class Util: tmp.append(self.make_Tamagotchi()) return tmp - def generateName(self): + @staticmethod + def generateName(): # Load syllables from file min_syllable_count = 0 max_syllable_count = 3 - firstsyllables = [] - with open("firstsyllable.txt") as firstsyllable_file: - for line in firstsyllable_file: - line = line.strip() - if len(line) == 0: - continue - if line[0] == "#": - continue - firstsyllables.append(line) - + __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) syllables = [] - with open("syllables.txt") as syllable_file: + with open(os.path.join(__location__, 'syllables.txt')) as syllable_file: for line in syllable_file: line = line.strip() if len(line) == 0: @@ -53,7 +46,7 @@ class Util: # Generate the name name = "" - name += firstsyllables[random.randint(0, len(firstsyllables) - 1)] + name += syllables[random.randint(0, len(syllables) - 1)].capitalize() for i in range(0, random.randint(int(min_syllable_count), int(max_syllable_count))): name += syllables[random.randint(0, len(syllables) - 1)] return name