This commit is contained in:
Auric Vente 2024-07-25 05:55:43 -06:00
parent c97c6d0a70
commit d692d8f440
2 changed files with 23 additions and 14 deletions

View File

@ -235,7 +235,14 @@ class Ants:
words = remove(words, ["of", "de", "da", "the"]) words = remove(words, ["of", "de", "da", "the"])
if len(words) < 2: if len(words) < 2:
words.extend(Utils.random_word(2 - len(words))) n = random.randint(1, 2)
if n == 1:
words = Utils.random_words(2 - len(words))
else:
words = Utils.make_words(2 - len(words))
words.extend(words)
return [Utils.capitalize(word) for word in words] return [Utils.capitalize(word) for word in words]

View File

@ -160,17 +160,16 @@ class Utils:
return random.choice(filtered) return random.choice(filtered)
@staticmethod @staticmethod
def random_word(num: int = 1) -> list[str]: def random_word() -> str:
words = [] word = Utils.rand_word.word(
include_parts_of_speech=["nouns", "adjectives"], word_max_length=8
)
for _ in range(num): return str(word)
word = Utils.rand_word.word(
include_parts_of_speech=["nouns", "adjectives"], word_max_length=8
)
words.append(word) @staticmethod
def random_words(num: int = 1) -> list[str]:
return words return [Utils.random_word() for _ in range(num)]
@staticmethod @staticmethod
def capitalize(word: str) -> str: def capitalize(word: str) -> str:
@ -202,8 +201,11 @@ class Utils:
return name return name
@staticmethod @staticmethod
def make_name() -> str: def make_words(num: int = 1) -> list[str]:
word_1 = Utils.make_word() return [Utils.make_word() for _ in range(num)]
word_2 = Utils.make_word()
return f"{Utils.capitalize(word_1)} {Utils.capitalize(word_2)}" @staticmethod
def make_name() -> str:
words = Utils.make_words(2)
words = [word.capitalize() for word in words]
return " ".join(words)