Skip to content

Commit

Permalink
Merge pull request #36 from duysqubix/feature/#1-implement-language
Browse files Browse the repository at this point in the history
Feature/#1 implement language
  • Loading branch information
duysqubix committed Dec 5, 2020
2 parents bbacdea + 249088a commit 6d6c8b0
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ server/logs/lockwarnings.log.1
server/logs/portal.log.2020_11_30
server/logs/server.log.2020_11_24
server/logs/server.log.2020_11_25
resources/json/rooms.json
resources/json/zones.json
resources/json/objs.json
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
2 changes: 1 addition & 1 deletion resources/json/books.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"date": "2E418-431",
"author": "Doctor Alfidia Lupus ",
"title": "Crafting: Orc Style",
"contents": "Being notes by Doctor Alfidia Lupus for a series of pamphlets on the major cultural styles of Tamriel\n\n(Dr. Lupus was Imperial Ethnographer for Potentate Savirien-Chorak from 2E 418 to 431)\n\nI saw Divayth last night, briefly, at the Torchbug. I told him I truly cared for him, but that Morian had won my heart. He clouded over like a storm in the Jeralls, but then took a deep breath and managed a dignified exit. Oh, I do hope he'll be all right.\n\nThough I confess, I'm more worried about Morian. His experiments with Divayth are reaching their climax, when Morian will open a gate and personally make a visit to Oblivion. He says he's going to try for Azura's realm of Moonshadow, as he says that ought to be relatively safe. Safe! I'm as anxious as a scrib on a griddle. I dearly want to see Morian before he goes, but he says he must concentrate on mastering the ritual and can't be interrupted.\n\nHe did send a note by Seif-ij saying I should take his place representing the University at the Potentate's state dinner for the new envoy from Orsinium. He must really be busy to skip that event, as I know he was keen to go. Well, all the better for my Racial Motifs project, I suppose—work, work, work will take my mind off my worries!\n\nThe new province of Orsinium doesn't have an embassy yet, so for the dinner the Potentate's snake-staff set up a row of pavilions on the grounds of the White-Gold Tower. To honor Envoy Thuggikh they were all decorated with authentic Orcish paraphernalia imported from Wrothgar, so I got out my journal and took notes during the interminable speeches.\n\nStrange to think that a folk as brutish as the Orcs seem to be could design and create objects of such sophistication! Of course they're known across Tamriel as fine armorers, but I'd always assumed that was due to their great strength rather than skill. A glance at their arms and armor was enough to show me how wrong my assumption had been. Though never ornate or over-embellished, their metalwork, though even simpler and more utilitarian than the Nords', displays a deep understanding of the laws of proportion, symmetry, and harmonic congruity. An Orcish sword may be a weapon of violence, but to contemplate the dynamic sweep of its blade, visually balanced by its heavy but shapely hilt, obviously molded to flow into the hand of its wielder—why, it's almost restful and reassuring.\n\nAfterwards at the reception I was happy to see somebody I recognized in Lady Opel the Arch-Magister. She greeted me warmly and, over some West Weald wine and Eidar cheese, asked me how things were going with me and my pair of wizards. I told her I thought I'd made a terrible muddle of things, but she assured me everything would work out in the end. She said she's known Morian for ever so long, and he's really quite sensible beneath his fussy old-man ways. She was glad he'd found someone as clever as I to keep him from completely vanishing into his laboratory.\n\nBut as far as I'm concerned, that's exactly what he's done. I think I'll go talk to Seif-ij again—maybe he can help me get through to Morian before he leaves."
"contents": "Being notes by Doctor Alfidia Lupus for a series of pamphlets on the major cultural styles of Tamriel\n\n(Dr. Lupus was Imperial Ethnographer for Potentate Savirien-Chorak from 2E 418 to 431)\n\nI saw Divayth last night, briefly, at the Torchbug. I told him I truly cared for him, but that Morian had won my heart. He clouded over like a storm in the Jeralls, but then took a deep breath and managed a dignified exit. Oh, I do hope he'll be all right.\n\nThough I confess, I'm more worried about Morian. His experiments with Divayth are reaching their climax, when Morian will open a gate and personally make a visit to Oblivion. He says he's going to try for Azura's realm of Moonshadow, as he says that ought to be relatively safe. Safe! I'm as anxious as a scrib on a griddle. I dearly want to see Morian before he goes, but he says he must concentrate on mastering the ritual and can't be interrupted.\n\nHe did send a note by Seif-ij saying I should take his place representing the University at the Potentate's state dinner for the new envoy from Orsinium. He must really be busy to skip that event, as I know he was keen to go. Well, all the better for my Racial Motifs project, I suppose\u2014work, work, work will take my mind off my worries!\n\nThe new province of Orsinium doesn't have an embassy yet, so for the dinner the Potentate's snake-staff set up a row of pavilions on the grounds of the White-Gold Tower. To honor Envoy Thuggikh they were all decorated with authentic Orcish paraphernalia imported from Wrothgar, so I got out my journal and took notes during the interminable speeches.\n\nStrange to think that a folk as brutish as the Orcs seem to be could design and create objects of such sophistication! Of course they're known across Tamriel as fine armorers, but I'd always assumed that was due to their great strength rather than skill. A glance at their arms and armor was enough to show me how wrong my assumption had been. Though never ornate or over-embellished, their metalwork, though even simpler and more utilitarian than the Nords', displays a deep understanding of the laws of proportion, symmetry, and harmonic congruity. An Orcish sword may be a weapon of violence, but to contemplate the dynamic sweep of its blade, visually balanced by its heavy but shapely hilt, obviously molded to flow into the hand of its wielder\u2014why, it's almost restful and reassuring.\n\nAfterwards at the reception I was happy to see somebody I recognized in Lady Opel the Arch-Magister. She greeted me warmly and, over some West Weald wine and Eidar cheese, asked me how things were going with me and my pair of wizards. I told her I thought I'd made a terrible muddle of things, but she assured me everything would work out in the end. She said she's known Morian for ever so long, and he's really quite sensible beneath his fussy old-man ways. She was glad he'd found someone as clever as I to keep him from completely vanishing into his laboratory.\n\nBut as far as I'm concerned, that's exactly what he's done. I think I'll go talk to Seif-ij again\u2014maybe he can help me get through to Morian before he leaves."
}
}
]
1 change: 0 additions & 1 deletion resources/json/objs.json

This file was deleted.

23 changes: 0 additions & 23 deletions resources/json/rooms.json

This file was deleted.

14 changes: 0 additions & 14 deletions resources/json/zones.json

This file was deleted.

8 changes: 8 additions & 0 deletions typeclasses/characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ def get(self, name, default=None):
name = 'tamrielic'
return getattr(self, name, default)

def clear(self):
""" resets languages on self to 0.0"""
for lang in VALID_LANGUAGES.keys():
langattr = getattr(self, lang, None)
if not langattr:
continue
setattr(self, lang, LanguageSkill.untrained)


class EquipmentHandler:
"""
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
5 changes: 4 additions & 1 deletion world/races.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Holds information regarding races of the scrolls
"""

from world.languages import LanguageSkill, Tamrielic, Orcish
from world.languages import LanguageSkill, Tamrielic, Orcish, Aldmeris
from world.attributes import Attribute
from world.traits import *
from world.characteristics import StrChar, EndChar, AgiChar, IntChar, WpChar, PrcChar, PrsChar
Expand Down Expand Up @@ -106,6 +106,8 @@ def init(self):
'enchanting', 'illusion', 'mysticism', 'restoration'
])

self.known_languages.extend([Aldmeris.__lang_name__])


class Argonian(Race):
"""
Expand Down Expand Up @@ -450,5 +452,6 @@ def change_race(caller, race):
caller.attrs.race = Attribute(race.name, value=race)

# add known languages of race
caller.languages.clear() # reset languages to 0.0
for language in race.known_languages:
setattr(caller.languages, language, LanguageSkill.master)
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 6d6c8b0

Please sign in to comment.