from util import endl from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from zoneTemplate import getSession, ZoneTemplate def zoneListCmd( clientId, remaining ): zoneTemplates = zoneList() zones = "{!{FGZone Templates:{FC" + endl for zt in zoneTemplates: zones += " " + str(zt) + endl sendToClient( clientId, zones ) def zoneList(): session = getSession() zoneTemplates = session.query(ZoneTemplate).all() session.close() return zoneTemplates rootCmdMap.addCmd( "zone list", zoneListCmd )
from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mud.format.columns import toColumns demoMsg = "{!{FYthe columns module ingests a set of strings and matching set of widths, returning a meshed 'columnified' version of the strings. \r\n\r\ncolumns preserves {BR{FGthe color\r\n\r\nof text{@{!{FY\r\n\r\n\r\n\r\n\r\n ... and auto-resizes to the\r\n maximum column length" noSeps = toColumns( ["{!{FCcolumns\r\n\r\n\r\nwithout", "\r\n{!{FWworks", "", "{!{FG\r\n\r\n\r\nseparators, {FYtoo{FR!"], [7,5,4,20]) def cmdColumnsDemo( clientId, remaining ): sendToClient( clientId, "\r\n{!{FYColumns Demo:\r\n\r\n" + toColumns( [ rootCmdMap.commands(), "no color\r\n{!bold\r\n{FMfore magenta\r\n" + rootCmdMap.commands(), demoMsg ], [9, 15, 40], True ) + noSeps ) rootCmdMap.addCmd( "demo columns", cmdColumnsDemo )
def zoneEditCmd(clientId, remaining): if remaining: (token, remaining) = first_token(remaining) templateId = toInt(token) if templateId: zoneTemplate = getZoneTemplate(templateId) if zoneTemplate: _editZone(clientId, zoneTemplate) return _invalidZoneId(clientId, token) # ZoneTemplateSelector sendToClient(clientId, "ZoneTemplateSelector not impl") def _invalidZoneId(clientId, token): sendToClient(clientId, "Invalid zone id '%s'" % token) def _editZone(clientId, zoneTemplate): session = getSession() session.add(zoneTemplate) form = ZoneTemplateForm(zoneTemplate, session) form.activate(clientId) rootCmdMap.addCmd("zone edit", zoneEditCmd)
from mud.core.rootCmdMap import rootCmdMap from mobTemplate import MobTemplate, getSession from mobTemplateForm import MobTemplateForm def mobNewCmd( clientId, remaining ): template = MobTemplate() session = getSession() session.add(template) form = MobTemplateForm( template, session ) form.activate( clientId ) rootCmdMap.addCmd( "mob new", mobNewCmd )
def _invalidZoneId( clientId, token ): sendToClient( clientId, "Invalid zone id '%s'" % token ) def zoneEditCmd( clientId, remaining): if remaining: (token, remaining) = first_token(remaining) templateId = toInt(token) if templateId: zoneTemplate = getZoneTemplate( templateId ) if zoneTemplate: _editZone( clientId, zoneTemplate ) return _invalidZoneId( clientId, token ) # ZoneTemplateSelector sendToClient( clientId, "ZoneTemplateSelector not impl" ) def _invalidZoneId( clientId, token ): sendToClient( clientId, "Invalid zone id '%s'" % token ) def _editZone( clientId, zoneTemplate ): session = getSession() session.add( zoneTemplate ) form = ZoneTemplateForm( zoneTemplate, session ) form.activate( clientId ) rootCmdMap.addCmd( "zone edit", zoneEditCmd )
def mobEditCmd(clientId, remaining): if remaining: (token, remaining) = first_token(remaining) templateId = toInt(token) if templateId: mobTemplate = getMobTemplate(templateId) if mobTemplate: _editMob(clientId, mobTemplate) return _invalidMobId(clientId, token) # MobTemplateSelector sendToClient(clientId, "MobTemplateSelector not impl") def _invalidMobId(clientId, token): sendToClient(clientId, "Invalid mob id '%s'" % token) def _editMob(clientId, mobTemplate): session = getSession() session.add(mobTemplate) form = MobTemplateForm(mobTemplate, session) form.activate(clientId) rootCmdMap.addCmd("mob edit", mobEditCmd)
from mud.core.rootCmdMap import rootCmdMap from zoneTemplate import ZoneTemplate, getSession from zoneTemplateForm import ZoneTemplateForm def zoneNew( clientId, remaining ): zt = ZoneTemplate() session = getSession() session.add(zt) form = ZoneTemplateForm( zt, session ) form.activate( clientId ) rootCmdMap.addCmd( "zone new", zoneNew )
from util import endl from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mobTemplate import getSession, MobTemplate def mobListCmd( clientId, remaining ): mobTemplates = mobList() mobs = "{!{FGMob Templates:{FC" + endl for mt in mobTemplates: mobs += " " + str(mt) + endl sendToClient( clientId, mobs ) def mobList(): session = getSession() mobTemplates = session.query(MobTemplate).all() session.close() return mobTemplates rootCmdMap.addCmd( "mob list", mobListCmd )
from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mud.core.prompt import pushPrompt, popPrompt from mud.menu.textInput import getOneLine, prompt as textPrompt def textCallback( clientId, text ): sendToClient( clientId, "{!{FUYou typed:{FG %s" % text ) popPrompt( clientId ) def cmdText( clientId, remaining ): getOneLine( clientId, textCallback ) pushPrompt( clientId, lambda x: textPrompt ) rootCmdMap.addCmd( "text", cmdText )
from mud.core.rootCmdMap import rootCmdMap from zoneTemplate import ZoneTemplate, getSession from zoneTemplateForm import ZoneTemplateForm def zoneNew(clientId, remaining): zt = ZoneTemplate() session = getSession() session.add(zt) form = ZoneTemplateForm(zt, session) form.activate(clientId) rootCmdMap.addCmd("zone new", zoneNew)
from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient, sendToAll from mud.core.mode import Mode from chatconfig import colorMenu def cmdChat( clientId, remaining ): if not remaining or len(remaining) == 0: sendToClient( clientId, "Usage: chat msg\r\n") return cmdChatFromMsg( clientId, remaining ) def cmdChatFromMsg( clientId, msg): color = "{FC" if clientId in colorMenu.colors: color = colorMenu.colors[ clientId ] sendToAll("{!{FC%i chats to everybody, '%s%s{FC'\r\n" % ( clientId, color, msg ) ) rootCmdMap.addCmd( "chat", cmdChat ) chatMode = Mode("chat", "mode chat", cmdChatFromMsg, False ) chatMode.register()
from util import endl from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from zoneTemplate import getSession, ZoneTemplate def zoneListCmd(clientId, remaining): zoneTemplates = zoneList() zones = "{!{FGZone Templates:{FC" + endl for zt in zoneTemplates: zones += " " + str(zt) + endl sendToClient(clientId, zones) def zoneList(): session = getSession() zoneTemplates = session.query(ZoneTemplate).all() session.close() return zoneTemplates rootCmdMap.addCmd("zone list", zoneListCmd)
from mud.core.prompt import popPrompt from mud.core.send import sendToClient import colorSelector def submenuSelectionCallback(clientId): sendToClient(clientId, menu(clientId)) colorMenu = colorSelector.ColorSelector(submenuSelectionCallback) def colorValueDescFunc(clientId): if clientId in colorMenu.colors: return colorMenu.colors[clientId] + "is this color" return "<select a color>" menuItems = [endl + "{FYChat Configuration:", ("font color", colorMenu.menu.activate, colorValueDescFunc)] def finishCallback(clientId, abort=False): popCmdHandler(clientId) popPrompt(clientId) form = Form(menuItems, finishCallback) menu = form.menu rootCmdMap.addCmd("config chat", lambda clientId, remaining: form.activate(clientId))
def submenuSelectionCallback(clientId): sendToClient(clientId, menu(clientId)) colorMenu = colorSelector.ColorSelector(submenuSelectionCallback) def colorValueDescFunc(clientId): if clientId in colorMenu.colors: return colorMenu.colors[clientId] + "is this color" return "<select a color>" menuItems = [ endl + "{FYChat Configuration:", ("font color", colorMenu.menu.activate, colorValueDescFunc), ] def finishCallback(clientId, abort=False): popCmdHandler(clientId) popPrompt(clientId) form = Form(menuItems, finishCallback) menu = form.menu rootCmdMap.addCmd("config chat", lambda clientId, remaining: form.activate(clientId))
from util import endl from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mud.menu.textEditor import TextEditor def submitEdit(clientId, text): sendToClient(clientId, endl + "{!{FUYou edited:%s{@%s" % (endl, text) + endl) def cmdEdit(clientId, remaining): TextEditor(clientId, "TestTitle", "initial text\r\nromg!!!", submitEdit) pass rootCmdMap.addCmd("edit", cmdEdit)
from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient, sendToAll from mud.core.mode import Mode from chatconfig import colorMenu def cmdChat(clientId, remaining): if not remaining or len(remaining) == 0: sendToClient(clientId, "Usage: chat msg\r\n") return cmdChatFromMsg(clientId, remaining) def cmdChatFromMsg(clientId, msg): color = "{FC" if clientId in colorMenu.colors: color = colorMenu.colors[clientId] sendToAll("{!{FC%i chats to everybody, '%s%s{FC'\r\n" % (clientId, color, msg)) rootCmdMap.addCmd("chat", cmdChat) chatMode = Mode("chat", "mode chat", cmdChatFromMsg, False) chatMode.register()
from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mud.core.prompt import pushPrompt, popPrompt from mud.menu.textInput import getOneLine, prompt as textPrompt def textCallback(clientId, text): sendToClient(clientId, "{!{FUYou typed:{FG %s" % text) popPrompt(clientId) def cmdText(clientId, remaining): getOneLine(clientId, textCallback) pushPrompt(clientId, lambda x: textPrompt) rootCmdMap.addCmd("text", cmdText)
from util import endl from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mud.menu.textEditor import TextEditor def submitEdit( clientId, text ): sendToClient( clientId, endl + "{!{FUYou edited:%s{@%s" % (endl, text) + endl ) def cmdEdit( clientId, remaining ): TextEditor( clientId, "TestTitle", "initial text\r\nromg!!!", submitEdit ) pass rootCmdMap.addCmd( "edit", cmdEdit )
from mud.core.rootCmdMap import rootCmdMap from mobTemplate import MobTemplate, getSession from mobTemplateForm import MobTemplateForm def mobNewCmd(clientId, remaining): template = MobTemplate() session = getSession() session.add(template) form = MobTemplateForm(template, session) form.activate(clientId) rootCmdMap.addCmd("mob new", mobNewCmd)
from util import endl from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mobTemplate import getSession, MobTemplate def mobListCmd(clientId, remaining): mobTemplates = mobList() mobs = "{!{FGMob Templates:{FC" + endl for mt in mobTemplates: mobs += " " + str(mt) + endl sendToClient(clientId, mobs) def mobList(): session = getSession() mobTemplates = session.query(MobTemplate).all() session.close() return mobTemplates rootCmdMap.addCmd("mob list", mobListCmd)
from mud.core.rootCmdMap import rootCmdMap from mud.core.send import sendToClient from mud.format.columns import toColumns demoMsg = "{!{FYthe columns module ingests a set of strings and matching set of widths, returning a meshed 'columnified' version of the strings. \r\n\r\ncolumns preserves {BR{FGthe color\r\n\r\nof text{@{!{FY\r\n\r\n\r\n\r\n\r\n ... and auto-resizes to the\r\n maximum column length" noSeps = toColumns([ "{!{FCcolumns\r\n\r\n\r\nwithout", "\r\n{!{FWworks", "", "{!{FG\r\n\r\n\r\nseparators, {FYtoo{FR!" ], [7, 5, 4, 20]) def cmdColumnsDemo(clientId, remaining): sendToClient( clientId, "\r\n{!{FYColumns Demo:\r\n\r\n" + toColumns([ rootCmdMap.commands(), "no color\r\n{!bold\r\n{FMfore magenta\r\n" + rootCmdMap.commands(), demoMsg ], [9, 15, 40], True) + noSeps) rootCmdMap.addCmd("demo columns", cmdColumnsDemo)