Updated the game template, renaming subdir typeclasses rather than types since the latter collides with the python library module of the same name.

This commit is contained in:
Griatch 2015-01-08 00:04:18 +01:00
parent 3fbc9acc51
commit c96c5a1fc7
112 changed files with 456 additions and 229 deletions

View file

@ -12,202 +12,204 @@ See www.evennia.com for full documentation.
"""
######################################################################
# set Evennia version in __version__ property
######################################################################
import os
try:
__version__ = "Evennia"
with os.path.join(open(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "VERSION.txt", 'r') as f:
__version__ += " %s" % f.read().strip()
except IOError:
__version__ += " (unknown version)"
del os
if False:
######################################################################
# Start Evennia API
# (easiest is to import this module interactively to explore it)
######################################################################
######################################################################
# set Evennia version in __version__ property
######################################################################
import os
try:
__version__ = "Evennia"
with os.path.join(open(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "VERSION.txt", 'r') as f:
__version__ += " %s" % f.read().strip()
except IOError:
__version__ += " (unknown version)"
del os
# help entries
from help.models import HelpEntry
######################################################################
# Start Evennia API
# (easiest is to import this module interactively to explore it)
######################################################################
# players
from players.player import DefaultPlayer
from players.models import PlayerDB
# commands
from commands.command import Command
from commands.cmdset import CmdSet
# (default_cmds is created below)
# locks
from locks import lockfuncs
# scripts
from scripts.scripts import Script
# comms
from comms.models import Msg, ChannelDB
from comms.comms import Channel
# objects
from objects.objects import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit
# utils
from utils.search import *
from utils.create import *
from scripts.tickerhandler import TICKER_HANDLER as tickerhandler
from utils import logger
from utils import utils
from utils import gametime
from utils import ansi
from utils.spawner import spawn
######################################################################
# API containers and helper functions
######################################################################
def help(header=False):
"""
Main Evennia API.
ev.help() views API contents
ev.help(True) or ev.README shows module instructions
See www.evennia.com for the full documentation.
"""
if header:
return __doc__
else:
import ev
names = [str(var) for var in ev.__dict__ if not var.startswith('_')]
return ", ".join(names)
class _EvContainer(object):
"""
Parent for other containers
"""
def _help(self):
"Returns list of contents"
names = [name for name in self.__class__.__dict__ if not name.startswith('_')]
names += [name for name in self.__dict__ if not name.startswith('_')]
print self.__doc__ + "-" * 60 + "\n" + ", ".join(names)
help = property(_help)
class DBmanagers(_EvContainer):
"""
Links to instantiated database managers.
helpentry - HelpEntry.objects
players - PlayerDB.objects
scripts - ScriptDB.objects
msgs - Msg.objects
channels - Channel.objects
objects - ObjectDB.objects
serverconfigs = ServerConfig.objects
tags - Tags.objects
attributes - Attributes.objects
"""
# help entries
from help.models import HelpEntry
# players
from players.player import DefaultPlayer
from players.models import PlayerDB
from scripts.models import ScriptDB
# commands
from commands.command import Command
from commands.cmdset import CmdSet
# (default_cmds is created below)
# locks
from locks import lockfuncs
# scripts
from scripts.scripts import Script
# comms
from comms.models import Msg, ChannelDB
from objects.models import ObjectDB
from server.models import ServerConfig
from typeclasses.attributes import Attribute
from typeclasses.tags import Tag
from comms.comms import Channel
# create container's properties
helpentries = HelpEntry.objects
players = PlayerDB.objects
scripts = ScriptDB.objects
msgs = Msg.objects
channels = ChannelDB.objects
objects = ObjectDB.objects
serverconfigs = ServerConfig.objects
attributes = Attribute.objects
tags = Tag.objects
# remove these so they are not visible as properties
del HelpEntry, PlayerDB, ScriptDB, Msg, ChannelDB
#del ExternalChannelConnection
del ObjectDB, ServerConfig, Tag, Attribute
# objects
from objects.objects import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit
managers = DBmanagers()
del DBmanagers
# utils
from utils.search import *
from utils.create import *
from scripts.tickerhandler import TICKER_HANDLER as tickerhandler
from utils import logger
from utils import utils
from utils import gametime
from utils import ansi
from utils.spawner import spawn
######################################################################
# API containers and helper functions
######################################################################
def help(header=False):
"""
Main Evennia API.
ev.help() views API contents
ev.help(True) or ev.README shows module instructions
See www.evennia.com for the full documentation.
"""
if header:
return __doc__
else:
import ev
names = [str(var) for var in ev.__dict__ if not var.startswith('_')]
return ", ".join(names)
class DefaultCmds(_EvContainer):
"""
This container holds direct shortcuts to all default commands in Evennia.
class _EvContainer(object):
"""
Parent for other containers
To access in code, do 'from evennia import default_cmds' then
access the properties on the imported default_cmds object.
"""
from commands.default.cmdset_character import CharacterCmdSet
from commands.default.cmdset_player import PlayerCmdSet
from commands.default.cmdset_unloggedin import UnloggedinCmdSet
from commands.default.cmdset_session import SessionCmdSet
from commands.default.muxcommand import MuxCommand, MuxPlayerCommand
def __init__(self):
"populate the object with commands"
def add_cmds(module):
"helper method for populating this object with cmds"
cmdlist = utils.variable_from_module(module, module.__all__)
self.__dict__.update(dict([(c.__name__, c) for c in cmdlist]))
from commands.default import (admin, batchprocess,
building, comms, general,
player, help, system, unloggedin)
add_cmds(admin)
add_cmds(building)
add_cmds(batchprocess)
add_cmds(building)
add_cmds(comms)
add_cmds(general)
add_cmds(player)
add_cmds(help)
add_cmds(system)
add_cmds(unloggedin)
default_cmds = DefaultCmds()
del DefaultCmds
"""
def _help(self):
"Returns list of contents"
names = [name for name in self.__class__.__dict__ if not name.startswith('_')]
names += [name for name in self.__dict__ if not name.startswith('_')]
print self.__doc__ + "-" * 60 + "\n" + ", ".join(names)
help = property(_help)
class SystemCmds(_EvContainer):
"""
Creating commands with keys set to these constants will make
them system commands called as a replacement by the parser when
special situations occur. If not defined, the hard-coded
responses in the server are used.
class DBmanagers(_EvContainer):
"""
Links to instantiated database managers.
CMD_NOINPUT - no input was given on command line
CMD_NOMATCH - no valid command key was found
CMD_MULTIMATCH - multiple command matches were found
CMD_CHANNEL - the command name is a channel name
CMD_LOGINSTART - this command will be called as the very
first command when a player connects to
the server.
helpentry - HelpEntry.objects
players - PlayerDB.objects
scripts - ScriptDB.objects
msgs - Msg.objects
channels - Channel.objects
objects - ObjectDB.objects
serverconfigs = ServerConfig.objects
tags - Tags.objects
attributes - Attributes.objects
To access in code, do 'from evennia import syscmdkeys' then
access the properties on the imported syscmdkeys object.
"""
from help.models import HelpEntry
from players.models import PlayerDB
from scripts.models import ScriptDB
from comms.models import Msg, ChannelDB
from objects.models import ObjectDB
from server.models import ServerConfig
from typeclasses.attributes import Attribute
from typeclasses.tags import Tag
"""
from commands import cmdhandler
CMD_NOINPUT = cmdhandler.CMD_NOINPUT
CMD_NOMATCH = cmdhandler.CMD_NOMATCH
CMD_MULTIMATCH = cmdhandler.CMD_MULTIMATCH
CMD_CHANNEL = cmdhandler.CMD_CHANNEL
CMD_LOGINSTART = cmdhandler.CMD_LOGINSTART
del cmdhandler
syscmdkeys = SystemCmds()
del SystemCmds
del _EvContainer
# create container's properties
helpentries = HelpEntry.objects
players = PlayerDB.objects
scripts = ScriptDB.objects
msgs = Msg.objects
channels = ChannelDB.objects
objects = ObjectDB.objects
serverconfigs = ServerConfig.objects
attributes = Attribute.objects
tags = Tag.objects
# remove these so they are not visible as properties
del HelpEntry, PlayerDB, ScriptDB, Msg, ChannelDB
#del ExternalChannelConnection
del ObjectDB, ServerConfig, Tag, Attribute
managers = DBmanagers()
del DBmanagers
class DefaultCmds(_EvContainer):
"""
This container holds direct shortcuts to all default commands in Evennia.
To access in code, do 'from evennia import default_cmds' then
access the properties on the imported default_cmds object.
"""
from commands.default.cmdset_character import CharacterCmdSet
from commands.default.cmdset_player import PlayerCmdSet
from commands.default.cmdset_unloggedin import UnloggedinCmdSet
from commands.default.cmdset_session import SessionCmdSet
from commands.default.muxcommand import MuxCommand, MuxPlayerCommand
def __init__(self):
"populate the object with commands"
def add_cmds(module):
"helper method for populating this object with cmds"
cmdlist = utils.variable_from_module(module, module.__all__)
self.__dict__.update(dict([(c.__name__, c) for c in cmdlist]))
from commands.default import (admin, batchprocess,
building, comms, general,
player, help, system, unloggedin)
add_cmds(admin)
add_cmds(building)
add_cmds(batchprocess)
add_cmds(building)
add_cmds(comms)
add_cmds(general)
add_cmds(player)
add_cmds(help)
add_cmds(system)
add_cmds(unloggedin)
default_cmds = DefaultCmds()
del DefaultCmds
class SystemCmds(_EvContainer):
"""
Creating commands with keys set to these constants will make
them system commands called as a replacement by the parser when
special situations occur. If not defined, the hard-coded
responses in the server are used.
CMD_NOINPUT - no input was given on command line
CMD_NOMATCH - no valid command key was found
CMD_MULTIMATCH - multiple command matches were found
CMD_CHANNEL - the command name is a channel name
CMD_LOGINSTART - this command will be called as the very
first command when a player connects to
the server.
To access in code, do 'from evennia import syscmdkeys' then
access the properties on the imported syscmdkeys object.
"""
from commands import cmdhandler
CMD_NOINPUT = cmdhandler.CMD_NOINPUT
CMD_NOMATCH = cmdhandler.CMD_NOMATCH
CMD_MULTIMATCH = cmdhandler.CMD_MULTIMATCH
CMD_CHANNEL = cmdhandler.CMD_CHANNEL
CMD_LOGINSTART = cmdhandler.CMD_LOGINSTART
del cmdhandler
syscmdkeys = SystemCmds()
del SystemCmds
del _EvContainer

View file

@ -274,26 +274,26 @@ SERVER_SESSION_CLASS = "evennia.server.serversession.ServerSession"
# Base paths for typeclassed object classes. These paths must be
# defined relative evennia's root directory. They will be searched in
# order to find relative typeclass paths.
OBJECT_TYPECLASS_PATHS = ["types", "contrib"]
SCRIPT_TYPECLASS_PATHS = ["types" "contrib"]
PLAYER_TYPECLASS_PATHS = ["types", "contrib"]
CHANNEL_TYPECLASS_PATHS = ["types", "contrib"]
OBJECT_TYPECLASS_PATHS = ["typeclasses", "contrib"]
SCRIPT_TYPECLASS_PATHS = ["typeclasses" "contrib"]
PLAYER_TYPECLASS_PATHS = ["typeclasses", "contrib"]
CHANNEL_TYPECLASS_PATHS = ["typeclasses", "contrib"]
# Typeclass for player objects (linked to a character) (fallback)
BASE_PLAYER_TYPECLASS = "types.player.Player"
BASE_PLAYER_TYPECLASS = "typeclasses.player.Player"
# Typeclass and base for all objects (fallback)
BASE_OBJECT_TYPECLASS = "types.object.Object"
BASE_OBJECT_TYPECLASS = "typeclasses.object.Object"
# Typeclass for character objects linked to a player (fallback)
BASE_CHARACTER_TYPECLASS = "types.character.Character"
BASE_CHARACTER_TYPECLASS = "typeclasses.character.Character"
# Typeclass for rooms (fallback)
BASE_ROOM_TYPECLASS = "types.room.Room"
BASE_ROOM_TYPECLASS = "typeclasses.room.Room"
# Typeclass for Exit objects (fallback).
BASE_EXIT_TYPECLASS = "types.exit.Exit"
BASE_EXIT_TYPECLASS = "typeclasses.exit.Exit"
# Typeclass for Channel (fallback).
BASE_CHANNEL_TYPECLASS = "type.channel.Channel"
BASE_CHANNEL_TYPECLASS = "typeclasses.channel.Channel"
# Typeclass for Scripts (fallback). You usually don't need to change this
# but create custom variations of scripts on a per-case basis instead.
BASE_SCRIPT_TYPECLASS = "type.scripts.Script"
BASE_SCRIPT_TYPECLASS = "typeclasses.scripts.Script"
# The default home location used for all objects. This is used as a
# fallback if an object's normal home location is deleted. Default
# is Limbo (#2).
@ -399,7 +399,7 @@ CLIENT_DEFAULT_HEIGHT = 45 # telnet standard is 24 but does anyone use such
# This enables guest logins, by default via "connect guest"
GUEST_ENABLED = False
# Typeclass for guest player objects (linked to a character)
BASE_GUEST_TYPECLASS = "types.player.Guest"
BASE_GUEST_TYPECLASS = "typeclasses.player.Guest"
# The permission given to guests
PERMISSION_GUEST_DEFAULT = "Guests"
# The default home location used for guests.

View file

@ -308,7 +308,7 @@ def get_evennia_version():
Check for the evennia version info.
"""
try:
f = open(settings.BASE_PATH + os.sep + "VERSION.txt", 'r')
f = open(settings.ROOT_DIR + os.sep + "VERSION.txt", 'r')
return "%s-%s" % (f.read().strip(), os.popen("git rev-parse --short HEAD").read().strip())
except IOError:
return "Unknown version"
@ -317,7 +317,7 @@ def get_evennia_version():
def pypath_to_realpath(python_path, file_ending='.py'):
"""
Converts a path on dot python form (e.g. 'evennia.objects.models') to
a system path ($BASE_PATH/evennia/objects/models.py). Calculates all
a system path ($ROOT_DIR/evennia/objects/models.py). Calculates all
paths as absoulte paths starting from the evennia main directory.
Since it seems to be a common mistake to include the file ending
@ -330,7 +330,7 @@ def pypath_to_realpath(python_path, file_ending='.py'):
pathsplit = pathsplit[:-1]
if not pathsplit:
return python_path
path = settings.BASE_PATH
path = settings.ROOT_DIR
for directory in pathsplit:
path = os.path.join(path, directory)
if file_ending: