Fix capitalization when more than one character in a room
This commit is contained in:
parent
0dd66a4c12
commit
ae4d3b69ef
1 changed files with 29 additions and 1 deletions
|
|
@ -22,6 +22,32 @@ from .objects import ObjectParent
|
||||||
_SEARCH_AT_RESULT = utils.object_from_module(settings.SEARCH_AT_RESULT)
|
_SEARCH_AT_RESULT = utils.object_from_module(settings.SEARCH_AT_RESULT)
|
||||||
|
|
||||||
|
|
||||||
|
def articlize_character(character, capitalize=False):
|
||||||
|
"""
|
||||||
|
Return a simple character with article prefix.
|
||||||
|
"""
|
||||||
|
if capitalize:
|
||||||
|
article = "A"
|
||||||
|
else:
|
||||||
|
article = "a"
|
||||||
|
|
||||||
|
if character == "" or match(r"^\|b[A-Z]", character):
|
||||||
|
return character
|
||||||
|
elif match(r"^\|b*[aeiou]", character):
|
||||||
|
return f"{article}n " + character
|
||||||
|
else:
|
||||||
|
return f"{article} " + character
|
||||||
|
|
||||||
|
def captialize_characters(characters):
|
||||||
|
"""
|
||||||
|
Capitalizes and prefixes an article on string of characters.
|
||||||
|
Assuming one per line.
|
||||||
|
"""
|
||||||
|
char_list = characters.split("\n")
|
||||||
|
updated = [articlize_character(ch, True) for ch in char_list]
|
||||||
|
return "\n".join(updated)
|
||||||
|
|
||||||
|
|
||||||
class Room(ObjectParent, ExtendedRoom, ContribRPRoom):
|
class Room(ObjectParent, ExtendedRoom, ContribRPRoom):
|
||||||
"""
|
"""
|
||||||
Rooms are like any Object, except their location is None
|
Rooms are like any Object, except their location is None
|
||||||
|
|
@ -70,7 +96,9 @@ class Room(ObjectParent, ExtendedRoom, ContribRPRoom):
|
||||||
also = ''
|
also = ''
|
||||||
|
|
||||||
if num_chars > 2:
|
if num_chars > 2:
|
||||||
return f"You {also}see the following characters:\n" + char_list
|
return f"You {also}see the following characters:" + \
|
||||||
|
captialize_characters(char_list)
|
||||||
|
|
||||||
if num_chars > 1:
|
if num_chars > 1:
|
||||||
character = char_list.strip()
|
character = char_list.strip()
|
||||||
if character.startswith('|'):
|
if character.startswith('|'):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue