Skip to content

Commit

Permalink
updated veriage on orcish to fine-tune language. Created function tha…
Browse files Browse the repository at this point in the history
…t capitalizes first word of each sentence.
  • Loading branch information
duysqubix committed Dec 5, 2020
1 parent 5272631 commit 249088a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion commands/informative.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from evennia.utils import evmore
from evennia.utils.utils import inherits_from
from commands.command import Command
from world.utils.utils import can_see_obj, is_book, is_container, is_equipped, is_invis, is_obj, is_pc_npc, is_wielded, is_worn, match_name, parse_dot_notation, rplanguage_parse_string
from world.utils.utils import can_see_obj, capitalize_sentence, is_book, is_container, is_equipped, is_invis, is_obj, is_pc_npc, is_wielded, is_worn, match_name, parse_dot_notation, rplanguage_parse_string
from evennia.utils.ansi import raw as raw_ansi


Expand Down Expand Up @@ -154,6 +154,7 @@ def show_book(book):
level=1.0 -
lang_skill.level,
language=book_lang)
contents_translated = capitalize_sentence(contents_translated)
BookEvMore(ch, book_contents + contents_translated)

if not self.args:
Expand Down
6 changes: 3 additions & 3 deletions world/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ class Orcish(_Language):
__lang_name__ = "orcish"

def define_language(self):
self.phonemes = "a u o g kh rz k r z th t m y ush am oo d ug zz gg eg ag oz uu us uth zu rul ol ru hz ri au ai kr"
self.phonemes = "a g kh rz k r z th t m ush am oo d ug zz gg eg ag oz uu us uth zu rul ol ru hz ri au ai kr gog rzn lag"
self.vowels = "auo"
self.grammar = "ccvcc vccv cvccv cvccvcc"
self.word_length_variance = 1
self.grammar = "ccvvcc ccvcc vccv vccvccvcc ccvvcvcc cvcccvcc cvcc vccccvc vcvcc cvccccv ccvcvccc cvccvcc cvcvcvcc cvcccvc ccccvc vcvvc vccvcvc ccvcv cvccvc cvccccvc cvccc cvccvcvc cvvcvc ccvccvccvc vcccvc vcvcvc ccvccvc cvccv cvcvccvcc cvcvcvc cvcvcv cvcccv cvcvcc cvcvcccc vcvccvc vccvc ccvcvc cvccccc cvcccccc"
self.word_length_variance = 2


VALID_LANGUAGES = {
Expand Down
16 changes: 13 additions & 3 deletions world/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from evennia.utils.utils import inherits_from, string_partial_matching
from world.conditions import DetectHidden, DetectInvis, Hidden, HolyLight, Invisible, Sleeping, get_condition

_CAP_PATTERN = re.compile(r'((?<=[\.\?!\n]\s)(\w+)|(^\w+))')
_LANG_TAGS = re.compile('\>(.*?)\<', re.I)


def highlight_words(block, key_targets, color_codes):
key_targets = make_iter(key_targets)
Expand All @@ -23,6 +26,11 @@ def highlight_words(block, key_targets, color_codes):
return block


def capitalize_sentence(string):
global _CAP_PATTERN
return _CAP_PATTERN.sub(lambda x: x.group().capitalize(), string)


def rplanguage_parse_string(ch, string):
"""
Obfuscates string based on keys that set the type of language
Expand All @@ -41,8 +49,9 @@ def rplanguage_parse_string(ch, string):
If you plan on using this function, it is import that string supplied
must have >[language]< first then contents in order for this function to parse correctly.
"""
pattern = re.compile('\>(.*?)\<', re.I)
chunks = re.split(pattern, string)[1:]
global _LANG_TAGS

chunks = re.split(_LANG_TAGS, string)[1:]
if not chunks:
# no tags found for a language
return string
Expand Down Expand Up @@ -70,7 +79,8 @@ def rplanguage_parse_string(ch, string):
language=lang)
new_string.append(obfuscated_string)

return "".join(new_string)
translated_string = "".join(new_string)
return capitalize_sentence(translated_string)


def apply_obj_effects(ch, obj):
Expand Down

0 comments on commit 249088a

Please sign in to comment.