multiplayer interactive fiction over telnet (python)
a(symbol_pred, "bound_pred"), non("registered")
make it easy to specify dispatch guards on the fly. equals(literal), has("key")
also provided.@given(a("closed", "container"))
def adjectives(e):
return "closed"
@given(a("open", "container"))
def adjectives(e):
return "open"
@check("entity", a("closed", "container"))
def close(a, b):
say("It's already closed.")
return False
@given("entity", a("opened", "container"))
def close(a, b):
b["closed"] = True
report("[Subject] close[s] [object].")
_base_.json
files{"id":"chest",
"name":"wooden chest",
"descripton":"It is likely to have a thing or two inside",
"extends":["object"],
"contents":[{"id":"mouse","color":"random"}],
"color":"brown",
"capacity":5,
"closed":true,
"opaque":true}
from mud.core import *
import random
@construct
def color(c):
if c == "random": return random.choice(["brown","red","cyan"])
return c
def _color_is(c):
def hue(e): return e.get('color') == c
return hue
#binding predicates allows any other module to use or overwrite them
bind.predicate("colored", has('color'))
bind.predicate("red", _color_is("red"))
bind.predicate("cyan", _color_is("cyan"))
#binding predicates as adjectives to be used for player input
bind.adjective("colored", "colored")
bind.adjective("red", "red")
bind.adjective("cyan", "cyan")
@before(a("cyan", "thing"))
def printed_name(e): return "{#bold}{#cyan}"
@before(a("red", "thing"))
def printed_name(e): return "{#red}"
@after(a("colored", "thing"))
def printed_name(e): return "{#reset}"
game/
modulesverbs can have multiple gramatical forms with arbitrary argument count and ordering.
The standard game modules (standard/player
and standard/scope
) handle resolution of captured strings to entities or values.
verbs.register("write", "write|inscribe", {"past":"wrote"})
verbs.register_structure("write", "{1:text}on|in{2}","{1:text}on|in{2}with|using{3}")
subject, verb, objects, and observing scope can be set and rewound with mud.core.context
's understood
Text can easily be customized for the observer, (especially useful to refer to acting player as "you|yourself")
#player commands have proper context.understood,
#but this can be changed and reverted incrementally if needed
understood.subject(e)
report("[Subject] introduce[s] [itself] to [object].")
#undoes the previous subject change
understood.previous()
parse.template
tracks fg/bg color stacks, allowing you to nest colorcoded strings. parse
also includes utilities for getting length, indicies, and splices of a templated string.
parse.template("{%green}bg-green{#yellow}fg-yellow {#red}fg-red {#magenta}fg-magenta{%reset}bg-default{#reset}fg-red {#reset}fg-yellow {#reset}fg-default")