Example #1
0
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 )



Example #2
0
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 )

Example #3
0
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)
Example #4
0
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 )
Example #5
0
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 )
Example #6
0
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)
Example #7
0
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 )
Example #8
0
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 )



Example #9
0
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 )
    
    
Example #10
0
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)
Example #11
0
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()

Example #12
0
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)
Example #13
0
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))
Example #14
0
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))
Example #15
0
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)
Example #16
0
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()
Example #17
0
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)
Example #18
0
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 )
Example #19
0
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)
Example #20
0
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)
Example #21
0
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)