Fixed name generation
This commit is contained in:
@@ -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
|
|
||||||
@@ -11,7 +11,7 @@ class Kinggotchi:
|
|||||||
name = ''
|
name = ''
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = util.generateName()
|
self.name = Util.generateName()
|
||||||
|
|
||||||
def add_village(self, mayor):
|
def add_village(self, mayor):
|
||||||
self.myvillages.append(mayor)
|
self.myvillages.append(mayor)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
from tamagotchi import Tamagotchi
|
from tamagotchi import Tamagotchi
|
||||||
import random
|
import random
|
||||||
from config import *
|
from config import *
|
||||||
|
from util import Util
|
||||||
|
|
||||||
class Mayorgotchi:
|
class Mayorgotchi:
|
||||||
mygotchis = []
|
mygotchis = []
|
||||||
@@ -12,7 +13,7 @@ class Mayorgotchi:
|
|||||||
|
|
||||||
def __init__(self, list_of_tamagotchis):
|
def __init__(self, list_of_tamagotchis):
|
||||||
self.mygotchis = list_of_tamagotchis
|
self.mygotchis = list_of_tamagotchis
|
||||||
self.name = util.generateName()
|
self.name = Util.generateName()
|
||||||
|
|
||||||
def remove_corpses(self):
|
def remove_corpses(self):
|
||||||
for n in self.mygotchis:
|
for n in self.mygotchis:
|
||||||
|
|||||||
19
util.py
19
util.py
@@ -4,6 +4,7 @@
|
|||||||
from tamagotchi import Tamagotchi
|
from tamagotchi import Tamagotchi
|
||||||
import random
|
import random
|
||||||
from config import *
|
from config import *
|
||||||
|
import os
|
||||||
|
|
||||||
class Util:
|
class Util:
|
||||||
|
|
||||||
@@ -26,23 +27,15 @@ class Util:
|
|||||||
tmp.append(self.make_Tamagotchi())
|
tmp.append(self.make_Tamagotchi())
|
||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
def generateName(self):
|
@staticmethod
|
||||||
|
def generateName():
|
||||||
# Load syllables from file
|
# Load syllables from file
|
||||||
min_syllable_count = 0
|
min_syllable_count = 0
|
||||||
max_syllable_count = 3
|
max_syllable_count = 3
|
||||||
|
|
||||||
firstsyllables = []
|
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
|
||||||
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)
|
|
||||||
|
|
||||||
syllables = []
|
syllables = []
|
||||||
with open("syllables.txt") as syllable_file:
|
with open(os.path.join(__location__, 'syllables.txt')) as syllable_file:
|
||||||
for line in syllable_file:
|
for line in syllable_file:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if len(line) == 0:
|
if len(line) == 0:
|
||||||
@@ -53,7 +46,7 @@ class Util:
|
|||||||
|
|
||||||
# Generate the name
|
# Generate the name
|
||||||
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))):
|
for i in range(0, random.randint(int(min_syllable_count), int(max_syllable_count))):
|
||||||
name += syllables[random.randint(0, len(syllables) - 1)]
|
name += syllables[random.randint(0, len(syllables) - 1)]
|
||||||
return name
|
return name
|
||||||
|
|||||||
Reference in New Issue
Block a user