X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=lib%2Fmuff%2Fmuffmisc.py;h=749af917b4bd75f5222299fc62debdafb464d45d;hp=d2848b20b8ddd887a10690768af0e5d9997fbde4;hb=da136e612520ef6a3a19d99563e44b6518f91e7e;hpb=1ff00115321d800bec7313a3fdfc97a8b0b006fa diff --git a/lib/muff/muffmisc.py b/lib/muff/muffmisc.py index d2848b2..749af91 100644 --- a/lib/muff/muffmisc.py +++ b/lib/muff/muffmisc.py @@ -3,6 +3,8 @@ # Copyright (c) 2005 mudpy, Jeremy Stanley , all rights reserved. # Licensed per terms in the LICENSE file distributed with this software. +import ConfigParser + # used by several functions for random calls import random @@ -147,7 +149,14 @@ def repr_long(value): else: return string_value def getlong(config, section, option): - return int(config.get(section, option).strip("L")) + try: + return int(config.get(section, option).strip("L")) + except ConfigParser.NoSectionError: + config.add_section(section) + return getlong(config, section, option) + except ConfigParser.NoOptionError: + setlong(config, section, option, 0) + return getlong(config, section, option) def setlong(config, section, option, value): return config.set(section, option, repr_long(value)) @@ -165,6 +174,33 @@ def replace_macros(user, text, is_input=False): elif macro == "$(account)": text = string.replace(text, macro, user.name) + # third person subjective pronoun + elif macro == "$(tpsp)": + if user.avatar.get("gender") == "male": + text = string.replace(text, macro, "he") + elif user.avatar.get("gender") == "female": + text = string.replace(text, macro, "she") + else: + text = string.replace(text, macro, "it") + + # third person objective pronoun + elif macro == "$(tpop)": + if user.avatar.get("gender") == "male": + text = string.replace(text, macro, "him") + elif user.avatar.get("gender") == "female": + text = string.replace(text, macro, "her") + else: + text = string.replace(text, macro, "it") + + # third person possessive pronoun + elif macro == "$(tppp)": + if user.avatar.get("gender") == "male": + text = string.replace(text, macro, "his") + elif user.avatar.get("gender") == "female": + text = string.replace(text, macro, "hers") + else: + text = string.replace(text, macro, "its") + # if we get here, log and replace it with null else: text = string.replace(text, macro, "") @@ -203,6 +239,7 @@ def on_pulse(): if check_time("frequency_save"): muffvars.save() for user in muffvars.userlist: user.save() + muffuniv.universe.save() # pause for a configurable amount of time (decimal seconds) time.sleep(muffconf.getfloat("time", "increment"))