Apply black to codes

This commit is contained in:
Griatch 2024-04-01 17:51:05 +02:00
parent 870c0f5f75
commit c5a4a34bac
180 changed files with 495 additions and 288 deletions

View file

@ -374,8 +374,12 @@ def setup(app):
# build toctree file # build toctree file
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
from docs.pylib import (auto_link_remapper, contrib_readmes2docs, from docs.pylib import (
update_default_cmd_index, update_dynamic_pages) auto_link_remapper,
contrib_readmes2docs,
update_default_cmd_index,
update_dynamic_pages,
)
_no_autodoc = os.environ.get("NOAUTODOC") _no_autodoc = os.environ.get("NOAUTODOC")
update_default_cmd_index.run_update(no_autodoc=_no_autodoc) update_default_cmd_index.run_update(no_autodoc=_no_autodoc)

View file

@ -16,6 +16,7 @@ to launch such a shell (using python or ipython depending on your install).
See www.evennia.com for full documentation. See www.evennia.com for full documentation.
""" """
import evennia import evennia
# docstring header # docstring header

View file

@ -10,18 +10,20 @@ character object, so you should customize that
instead for most things). instead for most things).
""" """
import re import re
import time import time
import typing import typing
from random import getrandbits from random import getrandbits
import evennia
from django.conf import settings from django.conf import settings
from django.contrib.auth import authenticate, password_validation from django.contrib.auth import authenticate, password_validation
from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.utils import timezone from django.utils import timezone
from django.utils.module_loading import import_string from django.utils.module_loading import import_string
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
import evennia
from evennia.accounts.manager import AccountManager from evennia.accounts.manager import AccountManager
from evennia.accounts.models import AccountDB from evennia.accounts.models import AccountDB
from evennia.commands.cmdsethandler import CmdSetHandler from evennia.commands.cmdsethandler import CmdSetHandler
@ -29,17 +31,24 @@ from evennia.comms.models import ChannelDB
from evennia.objects.models import ObjectDB from evennia.objects.models import ObjectDB
from evennia.scripts.scripthandler import ScriptHandler from evennia.scripts.scripthandler import ScriptHandler
from evennia.server.models import ServerConfig from evennia.server.models import ServerConfig
from evennia.server.signals import (SIGNAL_ACCOUNT_POST_CREATE, from evennia.server.signals import (
SIGNAL_ACCOUNT_POST_CREATE,
SIGNAL_ACCOUNT_POST_LOGIN_FAIL, SIGNAL_ACCOUNT_POST_LOGIN_FAIL,
SIGNAL_OBJECT_POST_PUPPET, SIGNAL_OBJECT_POST_PUPPET,
SIGNAL_OBJECT_POST_UNPUPPET) SIGNAL_OBJECT_POST_UNPUPPET,
)
from evennia.server.throttle import Throttle from evennia.server.throttle import Throttle
from evennia.typeclasses.attributes import ModelAttributeBackend, NickHandler from evennia.typeclasses.attributes import ModelAttributeBackend, NickHandler
from evennia.typeclasses.models import TypeclassBase from evennia.typeclasses.models import TypeclassBase
from evennia.utils import class_from_module, create, logger from evennia.utils import class_from_module, create, logger
from evennia.utils.optionhandler import OptionHandler from evennia.utils.optionhandler import OptionHandler
from evennia.utils.utils import (is_iter, lazy_property, make_iter, to_str, from evennia.utils.utils import (
variable_from_module) is_iter,
lazy_property,
make_iter,
to_str,
variable_from_module,
)
__all__ = ("DefaultAccount", "DefaultGuest") __all__ = ("DefaultAccount", "DefaultGuest")

View file

@ -7,6 +7,7 @@ import datetime
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import UserManager from django.contrib.auth.models import UserManager
from django.utils import timezone from django.utils import timezone
from evennia.server import signals from evennia.server import signals
from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager
from evennia.utils.utils import class_from_module, dbid_to_obj, make_iter from evennia.utils.utils import class_from_module, dbid_to_obj, make_iter

View file

@ -15,6 +15,7 @@ persistently store attributes of its own. This is ideal for extra
account info and OOC account configuration variables etc. account info and OOC account configuration variables etc.
""" """
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
from django.db import models from django.db import models

View file

@ -36,13 +36,14 @@ from weakref import WeakValueDictionary
from django.conf import settings from django.conf import settings
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet.task import deferLater
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
from evennia.commands.command import InterruptCommand from evennia.commands.command import InterruptCommand
from evennia.utils import logger, utils from evennia.utils import logger, utils
from evennia.utils.utils import string_suggestions from evennia.utils.utils import string_suggestions
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet.task import deferLater
_IN_GAME_ERRORS = settings.IN_GAME_ERRORS _IN_GAME_ERRORS = settings.IN_GAME_ERRORS

View file

@ -6,7 +6,6 @@ same inputs as the default one.
""" """
import re import re
from django.conf import settings from django.conf import settings

View file

@ -26,6 +26,7 @@ Set theory.
to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5 to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5
""" """
from weakref import WeakKeyDictionary from weakref import WeakKeyDictionary
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _

View file

@ -64,6 +64,7 @@ example, you can have a 'On a boat' set, onto which you then tack on
the 'Fishing' set. Fishing from a boat? No problem! the 'Fishing' set. Fishing from a boat? No problem!
""" """
import sys import sys
from importlib import import_module from importlib import import_module
from inspect import trace from inspect import trace

View file

@ -4,6 +4,7 @@ The base Command class.
All commands in Evennia inherit from the 'Command' class in this module. All commands in Evennia inherit from the 'Command' class in this module.
""" """
import inspect import inspect
import math import math
import re import re
@ -11,6 +12,7 @@ import re
from django.conf import settings from django.conf import settings
from django.urls import reverse from django.urls import reverse
from django.utils.text import slugify from django.utils.text import slugify
from evennia.locks.lockhandler import LockHandler from evennia.locks.lockhandler import LockHandler
from evennia.utils.ansi import ANSIString from evennia.utils.ansi import ANSIString
from evennia.utils.evtable import EvTable from evennia.utils.evtable import EvTable
@ -19,9 +21,7 @@ from evennia.utils.utils import fill, is_iter, lazy_property, make_iter
CMD_IGNORE_PREFIXES = settings.CMD_IGNORE_PREFIXES CMD_IGNORE_PREFIXES = settings.CMD_IGNORE_PREFIXES
class InterruptCommand(Exception): class InterruptCommand(Exception):
"""Cleanly interrupt a command.""" """Cleanly interrupt a command."""
pass pass
@ -491,11 +491,10 @@ class Command(metaclass=CommandMeta):
Command \"{cmdname}\" has no defined `func()` method. Available properties on this command are: Command \"{cmdname}\" has no defined `func()` method. Available properties on this command are:
{variables}""" {variables}"""
variables = [" |w{}|n ({}): {}".format( variables = [
key, type(val), f'"{val}"' if isinstance(val, str) else val " |w{}|n ({}): {}".format(key, type(val), f'"{val}"' if isinstance(val, str) else val)
) for key, val in (
for key, val in ("self.key", self.key),
(("self.key", self.key),
("self.cmdname", self.cmdstring), ("self.cmdname", self.cmdstring),
("self.raw_cmdname", self.raw_cmdname), ("self.raw_cmdname", self.raw_cmdname),
("self.raw_string", self.raw_string), ("self.raw_string", self.raw_string),
@ -506,7 +505,8 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th
("self.session", self.session), ("self.session", self.session),
("self.locks", self.locks), ("self.locks", self.locks),
("self.help_category", self.help_category), ("self.help_category", self.help_category),
("self.cmdset", self.cmdset)) ("self.cmdset", self.cmdset),
)
] ]
output = output_string.format(cmdname=self.key, variables="\n ".join(variables)) output = output_string.format(cmdname=self.key, variables="\n ".join(variables))
self.msg(output) self.msg(output)

View file

@ -18,6 +18,7 @@ self.msg() and similar methods to reroute returns to the correct
method. Otherwise all text will be returned to all connected sessions. method. Otherwise all text will be returned to all connected sessions.
""" """
import time import time
from codecs import lookup as codecs_lookup from codecs import lookup as codecs_lookup

View file

@ -17,6 +17,7 @@ the Evennia API. It is also a severe security risk and should
therefore always be limited to superusers only. therefore always be limited to superusers only.
""" """
import re import re
from django.conf import settings from django.conf import settings

View file

@ -1,16 +1,17 @@
""" """
Building and world design commands Building and world design commands
""" """
import re import re
import typing import typing
import evennia
from django.conf import settings from django.conf import settings
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.db.models import Max, Min, Q from django.db.models import Max, Min, Q
import evennia
from evennia import InterruptCommand from evennia import InterruptCommand
from evennia.commands.cmdhandler import (generate_cmdset_providers, from evennia.commands.cmdhandler import generate_cmdset_providers, get_and_merge_cmdsets
get_and_merge_cmdsets)
from evennia.locks.lockhandler import LockException from evennia.locks.lockhandler import LockException
from evennia.objects.models import ObjectDB from evennia.objects.models import ObjectDB
from evennia.prototypes import menus as olc_menus from evennia.prototypes import menus as olc_menus
@ -23,10 +24,18 @@ from evennia.utils.dbserialize import deserialize
from evennia.utils.eveditor import EvEditor from evennia.utils.eveditor import EvEditor
from evennia.utils.evmore import EvMore from evennia.utils.evmore import EvMore
from evennia.utils.evtable import EvTable from evennia.utils.evtable import EvTable
from evennia.utils.utils import (class_from_module, crop, dbref, display_len, from evennia.utils.utils import (
format_grid, get_all_typeclasses, class_from_module,
inherits_from, interactive, list_to_string, crop,
variable_from_module) dbref,
display_len,
format_grid,
get_all_typeclasses,
inherits_from,
interactive,
list_to_string,
variable_from_module,
)
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS) COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
@ -259,7 +268,7 @@ class CmdSetObjAlias(COMMAND_DEFAULT_CLASS):
obj = caller.search(objname) obj = caller.search(objname)
if not obj: if not obj:
return return
if self.rhs is None and 'delete' not in self.switches: if self.rhs is None and "delete" not in self.switches:
# no =, and not deleting, so we just list aliases on object. # no =, and not deleting, so we just list aliases on object.
aliases = obj.aliases.all(return_key_and_category=True) aliases = obj.aliases.all(return_key_and_category=True)
if aliases: if aliases:
@ -2956,9 +2965,9 @@ class CmdExamine(ObjManipCommand):
): ):
objdata["Stored Cmdset(s)"] = self.format_stored_cmdsets(obj) objdata["Stored Cmdset(s)"] = self.format_stored_cmdsets(obj)
objdata["Merged Cmdset(s)"] = self.format_merged_cmdsets(obj, current_cmdset) objdata["Merged Cmdset(s)"] = self.format_merged_cmdsets(obj, current_cmdset)
objdata[ objdata[f"Commands available to {obj.key} (result of Merged Cmdset(s))"] = (
f"Commands available to {obj.key} (result of Merged Cmdset(s))" self.format_current_cmds(obj, current_cmdset)
] = self.format_current_cmds(obj, current_cmdset) )
if self.object_type == "script": if self.object_type == "script":
objdata["Description"] = self.format_script_desc(obj) objdata["Description"] = self.format_script_desc(obj)
objdata["Persistent"] = self.format_script_is_persistent(obj) objdata["Persistent"] = self.format_script_is_persistent(obj)
@ -3415,9 +3424,11 @@ class ScriptEvMore(EvMore):
table.add_row( table.add_row(
f"#{script.id}", f"#{script.id}",
(
f"{script.obj.key}({script.obj.dbref})" f"{script.obj.key}({script.obj.dbref})"
if (hasattr(script, "obj") and script.obj) if (hasattr(script, "obj") and script.obj)
else "<Global>", else "<Global>"
),
script.key, script.key,
script.interval if script.interval > 0 else "--", script.interval if script.interval > 0 else "--",
nextrep, nextrep,

View file

@ -4,6 +4,7 @@ available (i.e. IC commands). Note that some commands, such as
communication-commands are instead put on the account level, in the communication-commands are instead put on the account level, in the
Account cmdset. Account commands remain available also to Characters. Account cmdset. Account commands remain available also to Characters.
""" """
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
from evennia.commands.default import ( from evennia.commands.default import (
admin, admin,

View file

@ -1,6 +1,7 @@
""" """
This module stores session-level commands. This module stores session-level commands.
""" """
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
from evennia.commands.default import account from evennia.commands.default import account

View file

@ -3,6 +3,7 @@ This module describes the unlogged state of the default game.
The setting STATE_UNLOGGED should be set to the python path The setting STATE_UNLOGGED should be set to the python path
of the state instance in this module. of the state instance in this module.
""" """
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
from evennia.commands.default import unloggedin from evennia.commands.default import unloggedin

View file

@ -9,6 +9,7 @@ Communication commands:
from django.conf import settings from django.conf import settings
from django.db.models import Q from django.db.models import Q
from evennia.accounts import bots from evennia.accounts import bots
from evennia.accounts.models import AccountDB from evennia.accounts.models import AccountDB
from evennia.comms.comms import DefaultChannel from evennia.comms.comms import DefaultChannel
@ -1412,8 +1413,12 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
message = f"{caller.key} {message.strip(':').strip()}" message = f"{caller.key} {message.strip(':').strip()}"
# create the persistent message object # create the persistent message object
create.create_message(caller, message, receivers=targets, create.create_message(
locks=(f"read:id({caller.id}) or perm(Admin);" caller,
message,
receivers=targets,
locks=(
f"read:id({caller.id}) or perm(Admin);"
f"delete:id({caller.id}) or perm(Admin);" f"delete:id({caller.id}) or perm(Admin);"
f"edit:id({caller.id}) or perm(Admin)" f"edit:id({caller.id}) or perm(Admin)"
), ),

View file

@ -1,10 +1,12 @@
""" """
General Character commands usually available to all characters General Character commands usually available to all characters
""" """
import re import re
import evennia
from django.conf import settings from django.conf import settings
import evennia
from evennia.typeclasses.attributes import NickTemplateInvalid from evennia.typeclasses.attributes import NickTemplateInvalid
from evennia.utils import utils from evennia.utils import utils

View file

@ -4,7 +4,6 @@ System commands
""" """
import code import code
import datetime import datetime
import os import os
@ -112,7 +111,6 @@ class CmdReset(COMMAND_DEFAULT_CLASS):
class CmdShutdown(COMMAND_DEFAULT_CLASS): class CmdShutdown(COMMAND_DEFAULT_CLASS):
""" """
stop the server completely stop the server completely
@ -277,7 +275,6 @@ def evennia_local_vars(caller):
class EvenniaPythonConsole(code.InteractiveConsole): class EvenniaPythonConsole(code.InteractiveConsole):
"""Evennia wrapper around a Python interactive console.""" """Evennia wrapper around a Python interactive console."""
def __init__(self, caller): def __init__(self, caller):

View file

@ -14,17 +14,32 @@ main test suite started with
import datetime import datetime
from unittest.mock import MagicMock, Mock, patch from unittest.mock import MagicMock, Mock, patch
import evennia
from anything import Anything from anything import Anything
from django.conf import settings from django.conf import settings
from django.test import override_settings from django.test import override_settings
from evennia import (DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom, from parameterized import parameterized
ObjectDB, search_object) from twisted.internet import task
import evennia
from evennia import (
DefaultCharacter,
DefaultExit,
DefaultObject,
DefaultRoom,
ObjectDB,
search_object,
)
from evennia.commands import cmdparser from evennia.commands import cmdparser
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
from evennia.commands.command import Command, InterruptCommand from evennia.commands.command import Command, InterruptCommand
from evennia.commands.default import (account, admin, batchprocess, building, from evennia.commands.default import (
comms, general) account,
admin,
batchprocess,
building,
comms,
general,
)
from evennia.commands.default import help as help_module from evennia.commands.default import help as help_module
from evennia.commands.default import syscommands, system, unloggedin from evennia.commands.default import syscommands, system, unloggedin
from evennia.commands.default.cmdset_character import CharacterCmdSet from evennia.commands.default.cmdset_character import CharacterCmdSet
@ -33,8 +48,6 @@ from evennia.prototypes import prototypes as protlib
from evennia.utils import create, gametime, utils from evennia.utils import create, gametime, utils
from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTest from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTest
from parameterized import parameterized
from twisted.internet import task
# ------------------------------------------------------------ # ------------------------------------------------------------
# Command testing # Command testing
@ -368,8 +381,7 @@ class TestCmdTasks(BaseEvenniaCommandTest):
self.timedelay = 5 self.timedelay = 5
global _TASK_HANDLER global _TASK_HANDLER
if _TASK_HANDLER is None: if _TASK_HANDLER is None:
from evennia.scripts.taskhandler import \ from evennia.scripts.taskhandler import TASK_HANDLER as _TASK_HANDLER
TASK_HANDLER as _TASK_HANDLER
_TASK_HANDLER.clock = task.Clock() _TASK_HANDLER.clock = task.Clock()
self.task_handler = _TASK_HANDLER self.task_handler = _TASK_HANDLER
self.task_handler.clear() self.task_handler.clear()
@ -787,19 +799,20 @@ class TestBuilding(BaseEvenniaCommandTest):
self.call(building.CmdSetObjAlias(), "Obj2 =", "No aliases to clear.") self.call(building.CmdSetObjAlias(), "Obj2 =", "No aliases to clear.")
self.call(building.CmdSetObjAlias(), "Obj =", "Cleared aliases from Obj: testobj1b") self.call(building.CmdSetObjAlias(), "Obj =", "Cleared aliases from Obj: testobj1b")
self.call(building.CmdSetObjAlias(), self.call(
building.CmdSetObjAlias(),
"/category Obj = testobj1b:category1", "/category Obj = testobj1b:category1",
"Alias(es) for 'Obj' set to 'testobj1b' (category: 'category1')." "Alias(es) for 'Obj' set to 'testobj1b' (category: 'category1').",
) )
self.call( self.call(
building.CmdSetObjAlias(), building.CmdSetObjAlias(),
"/category Obj = testobj1b:category2", "/category Obj = testobj1b:category2",
"Alias(es) for 'Obj' set to 'testobj1b,testobj1b' (category: 'category2')." "Alias(es) for 'Obj' set to 'testobj1b,testobj1b' (category: 'category2').",
) )
self.call( self.call(
building.CmdSetObjAlias(), # delete both occurences of alias 'testobj1b' building.CmdSetObjAlias(), # delete both occurences of alias 'testobj1b'
"/delete Obj = testobj1b", "/delete Obj = testobj1b",
"Alias 'testobj1b' deleted from Obj." "Alias 'testobj1b' deleted from Obj.",
) )
self.call(building.CmdSetObjAlias(), "Obj =", "No aliases to clear.") self.call(building.CmdSetObjAlias(), "Obj =", "No aliases to clear.")
@ -1773,8 +1786,7 @@ class TestBuilding(BaseEvenniaCommandTest):
self.call( self.call(
building.CmdSpawn(), building.CmdSpawn(),
"{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', " "{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', "
"'key':'goblin', 'location':'%s'}" "'key':'goblin', 'location':'%s'}" % spawnLoc.dbref,
% spawnLoc.dbref,
"Spawned goblin", "Spawned goblin",
) )
goblin = get_object(self, "goblin") goblin = get_object(self, "goblin")
@ -1822,8 +1834,7 @@ class TestBuilding(BaseEvenniaCommandTest):
self.call( self.call(
building.CmdSpawn(), building.CmdSpawn(),
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo'," "/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo',"
" 'location':'%s'}" " 'location':'%s'}" % spawnLoc.dbref,
% spawnLoc.dbref,
"Spawned Ball", "Spawned Ball",
) )
ball = get_object(self, "Ball") ball = get_object(self, "Ball")
@ -2068,6 +2079,7 @@ class TestComms(BaseEvenniaCommandTest):
receiver=self.account, receiver=self.account,
) )
from evennia.comms.models import Msg from evennia.comms.models import Msg
msgs = Msg.objects.filter(db_tags__db_key="page", db_tags__db_category="comms") msgs = Msg.objects.filter(db_tags__db_key="page", db_tags__db_category="comms")
self.assertEqual(msgs[0].senders, [self.account]) self.assertEqual(msgs[0].senders, [self.account])
self.assertEqual(msgs[0].receivers, [self.account2]) self.assertEqual(msgs[0].receivers, [self.account2])

View file

@ -2,6 +2,7 @@
Commands that are available from the connect screen. Commands that are available from the connect screen.
""" """
import datetime import datetime
import re import re
from codecs import lookup as codecs_lookup from codecs import lookup as codecs_lookup

View file

@ -2,6 +2,7 @@
Base typeclass for in-game Channels. Base typeclass for in-game Channels.
""" """
import re import re
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType

View file

@ -4,7 +4,6 @@ Comm system components.
""" """
from django.conf import settings from django.conf import settings
from django.db.models import Q from django.db.models import Q

View file

@ -18,6 +18,7 @@ connect to channels by use of a ChannelConnect object (this object is
necessary to easily be able to delete connections on the fly). necessary to easily be able to delete connections on the fly).
""" """
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone

View file

@ -221,7 +221,6 @@ def get_available_overwrite_name(name, max_length):
@deconstructible @deconstructible
class S3Boto3StorageFile(File): class S3Boto3StorageFile(File):
""" """
The default file object used by the S3Boto3Storage backend. The default file object used by the S3Boto3Storage backend.
This file implements file streaming using boto's multipart This file implements file streaming using boto's multipart

View file

@ -2,5 +2,6 @@
Build-menu contrib - vincent-lg 2018 Build-menu contrib - vincent-lg 2018
""" """
from .building_menu import BuildingMenu # noqa from .building_menu import BuildingMenu # noqa
from .building_menu import GenericBuildingCmd # noqa from .building_menu import GenericBuildingCmd # noqa

View file

@ -331,7 +331,6 @@ def menu_edit(caller, choice, obj):
class CmdNoInput(Command): class CmdNoInput(Command):
"""No input has been found.""" """No input has been found."""
key = _CMD_NOINPUT key = _CMD_NOINPUT
@ -352,7 +351,6 @@ class CmdNoInput(Command):
class CmdNoMatch(Command): class CmdNoMatch(Command):
"""No input has been found.""" """No input has been found."""
key = _CMD_NOMATCH key = _CMD_NOMATCH
@ -394,7 +392,6 @@ class CmdNoMatch(Command):
class BuildingMenuCmdSet(CmdSet): class BuildingMenuCmdSet(CmdSet):
"""Building menu CmdSet.""" """Building menu CmdSet."""
key = "building_menu" key = "building_menu"
@ -421,7 +418,6 @@ class BuildingMenuCmdSet(CmdSet):
class Choice: class Choice:
"""A choice object, created by `add_choice`.""" """A choice object, created by `add_choice`."""
def __init__( def __init__(
@ -557,7 +553,6 @@ class Choice:
class BuildingMenu: class BuildingMenu:
""" """
Class allowing to create and set building menus to edit specific objects. Class allowing to create and set building menus to edit specific objects.
@ -1200,7 +1195,6 @@ class BuildingMenu:
# Generic building menu and command # Generic building menu and command
class GenericBuildingMenu(BuildingMenu): class GenericBuildingMenu(BuildingMenu):
"""A generic building menu, allowing to edit any object. """A generic building menu, allowing to edit any object.
This is more a demonstration menu. By default, it allows to edit the This is more a demonstration menu. By default, it allows to edit the
@ -1241,7 +1235,6 @@ class GenericBuildingMenu(BuildingMenu):
class GenericBuildingCmd(Command): class GenericBuildingCmd(Command):
""" """
Generic building command. Generic building command.

View file

@ -7,6 +7,7 @@ This helps writing isolated code and reusing it over multiple objects.
See the docs for more information. See the docs for more information.
""" """
from . import exceptions # noqa from . import exceptions # noqa
from .component import Component # noqa from .component import Component # noqa
from .dbfield import DBField, NDBField, TagField # noqa from .dbfield import DBField, NDBField, TagField # noqa

View file

@ -3,6 +3,7 @@ Components - ChrisLR 2022
This file contains the Descriptors used to set Fields in Components This file contains the Descriptors used to set Fields in Components
""" """
import typing import typing
from evennia.typeclasses.attributes import AttributeProperty, NAttributeProperty from evennia.typeclasses.attributes import AttributeProperty, NAttributeProperty

View file

@ -309,7 +309,6 @@ def schedule(callback, repeat=False, **kwargs):
class GametimeScript(DefaultScript): class GametimeScript(DefaultScript):
"""Gametime-sensitive script.""" """Gametime-sensitive script."""
def at_script_creation(self): def at_script_creation(self):

View file

@ -10,6 +10,7 @@ You could also pass extra data to this client for advanced functionality.
See the docs for more information. See the docs for more information.
""" """
from evennia.contrib.base_systems.godotwebsocket.text2bbcode import ( from evennia.contrib.base_systems.godotwebsocket.text2bbcode import (
BBCODE_PARSER, BBCODE_PARSER,
parse_to_bbcode, parse_to_bbcode,

View file

@ -3,6 +3,7 @@ Godot Websocket - ChrisLR 2022
This file contains the necessary code and data to convert text with color tags to bbcode (For godot) This file contains the necessary code and data to convert text with color tags to bbcode (For godot)
""" """
from evennia.utils.ansi import * from evennia.utils.ansi import *
from evennia.utils.text2html import TextToHTMLparser from evennia.utils.text2html import TextToHTMLparser

View file

@ -4,6 +4,7 @@ Godot Websocket - ChrisLR 2022
This file contains the code necessary to dedicate a port to communicate with Godot via Websockets. This file contains the code necessary to dedicate a port to communicate with Godot via Websockets.
It uses the plugin system and should be plugged via settings as detailed in the readme. It uses the plugin system and should be plugged via settings as detailed in the readme.
""" """
import json import json
from autobahn.twisted import WebSocketServerFactory from autobahn.twisted import WebSocketServerFactory

View file

@ -6,7 +6,6 @@ from collections import namedtuple
class CallbackHandler(object): class CallbackHandler(object):
""" """
The callback handler for a specific object. The callback handler for a specific object.

View file

@ -70,7 +70,6 @@ Use the /del switch to remove callbacks that should not be connected.
class CmdCallback(COMMAND_DEFAULT_CLASS): class CmdCallback(COMMAND_DEFAULT_CLASS):
""" """
Command to edit callbacks. Command to edit callbacks.
""" """

View file

@ -27,7 +27,6 @@ RE_LINE_ERROR = re.compile(r'^ File "\<string\>", line (\d+)')
class EventHandler(DefaultScript): class EventHandler(DefaultScript):
""" """
The event handler that contains all events in a global script. The event handler that contains all events in a global script.
@ -600,7 +599,6 @@ class EventHandler(DefaultScript):
# Script to call time-related events # Script to call time-related events
class TimeEventScript(DefaultScript): class TimeEventScript(DefaultScript):
"""Gametime-sensitive script.""" """Gametime-sensitive script."""
def at_script_creation(self): def at_script_creation(self):

View file

@ -25,7 +25,6 @@ OLD_EVENTS = {}
class TestEventHandler(BaseEvenniaTest): class TestEventHandler(BaseEvenniaTest):
""" """
Test cases of the event handler to add, edit or delete events. Test cases of the event handler to add, edit or delete events.
""" """
@ -259,7 +258,6 @@ class TestEventHandler(BaseEvenniaTest):
class TestCmdCallback(BaseEvenniaCommandTest): class TestCmdCallback(BaseEvenniaCommandTest):
"""Test the @callback command.""" """Test the @callback command."""
def setUp(self): def setUp(self):
@ -448,7 +446,6 @@ class TestCmdCallback(BaseEvenniaCommandTest):
class TestDefaultCallbacks(BaseEvenniaCommandTest): class TestDefaultCallbacks(BaseEvenniaCommandTest):
"""Test the default callbacks.""" """Test the default callbacks."""
def setUp(self): def setUp(self):

View file

@ -166,7 +166,6 @@ Variables you can use in this event:
@register_events @register_events
class EventCharacter(DefaultCharacter): class EventCharacter(DefaultCharacter):
"""Typeclass to represent a character and call event types.""" """Typeclass to represent a character and call event types."""
_events = { _events = {
@ -625,7 +624,6 @@ Variables you can use in this event:
@register_events @register_events
class EventExit(DefaultExit): class EventExit(DefaultExit):
"""Modified exit including management of events.""" """Modified exit including management of events."""
_events = { _events = {
@ -721,7 +719,6 @@ Variables you can use in this event:
@register_events @register_events
class EventObject(DefaultObject): class EventObject(DefaultObject):
"""Default object with management of events.""" """Default object with management of events."""
_events = { _events = {
@ -892,7 +889,6 @@ Variables you can use in this event:
@register_events @register_events
class EventRoom(DefaultRoom): class EventRoom(DefaultRoom):
"""Default room with management of events.""" """Default room with management of events."""
_events = { _events = {

View file

@ -251,7 +251,6 @@ def phrase_event(callbacks, parameters):
class InterruptEvent(RuntimeError): class InterruptEvent(RuntimeError):
""" """
Interrupt the current event. Interrupt the current event.

View file

@ -21,10 +21,14 @@ called automatically when a new user connects.
""" """
from django.conf import settings from django.conf import settings
from evennia import CmdSet, Command, syscmdkeys from evennia import CmdSet, Command, syscmdkeys
from evennia.utils.evmenu import EvMenu from evennia.utils.evmenu import EvMenu
from evennia.utils.utils import (callables_from_module, class_from_module, from evennia.utils.utils import (
random_string_from_module) callables_from_module,
class_from_module,
random_string_from_module,
)
_CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE _CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
_GUEST_ENABLED = settings.GUEST_ENABLED _GUEST_ENABLED = settings.GUEST_ENABLED

View file

@ -41,6 +41,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
``` ```
""" """
from django.conf import settings from django.conf import settings
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet

View file

@ -9,7 +9,6 @@ from .unixcommand import UnixCommand
class CmdDummy(UnixCommand): class CmdDummy(UnixCommand):
"""A dummy UnixCommand.""" """A dummy UnixCommand."""
key = "dummy" key = "dummy"

View file

@ -72,14 +72,12 @@ from evennia.utils.ansi import raw
class ParseError(Exception): class ParseError(Exception):
"""An error occurred during parsing.""" """An error occurred during parsing."""
pass pass
class UnixCommandParser(argparse.ArgumentParser): class UnixCommandParser(argparse.ArgumentParser):
"""A modifier command parser for unix commands. """A modifier command parser for unix commands.
This parser is used to replace `argparse.ArgumentParser`. It This parser is used to replace `argparse.ArgumentParser`. It
@ -183,7 +181,6 @@ class UnixCommandParser(argparse.ArgumentParser):
class HelpAction(argparse.Action): class HelpAction(argparse.Action):
"""Override the -h/--help action in the default parser. """Override the -h/--help action in the default parser.
Using the default -h/--help will call the exit function in different Using the default -h/--help will call the exit function in different

View file

@ -7,6 +7,7 @@ Here player user can set their own description as well as select to create a
new room (to start from scratch) or join an existing room (with other players). new room (to start from scratch) or join an existing room (with other players).
""" """
from evennia import EvMenu from evennia import EvMenu
from evennia.utils import create, justify, list_to_string, logger from evennia.utils import create, justify, list_to_string, logger
from evennia.utils.evmenu import list_node from evennia.utils.evmenu import list_node

View file

@ -43,6 +43,7 @@ Available parents:
- Positionable (supports sit/lie/knee/climb at once) - Positionable (supports sit/lie/knee/climb at once)
""" """
import inspect import inspect
import re import re

View file

@ -2,6 +2,7 @@
Unit tests for the Evscaperoom Unit tests for the Evscaperoom
""" """
import inspect import inspect
import pkgutil import pkgutil
from os import path from os import path

View file

@ -72,9 +72,11 @@ with which to test the system:
wear shirt wear shirt
""" """
from collections import defaultdict from collections import defaultdict
from django.conf import settings from django.conf import settings
from evennia import DefaultCharacter, DefaultObject, default_cmds from evennia import DefaultCharacter, DefaultObject, default_cmds
from evennia.commands.default.muxcommand import MuxCommand from evennia.commands.default.muxcommand import MuxCommand
from evennia.utils import ( from evennia.utils import (

View file

@ -30,6 +30,7 @@ or implement the same locks/hooks in your own typeclasses.
at_pre_get_from(getter, target, **kwargs) - called with the pre-get hooks at_pre_get_from(getter, target, **kwargs) - called with the pre-get hooks
at_pre_put_in(putter, target, **kwargs) - called with the pre-put hooks at_pre_put_in(putter, target, **kwargs) - called with the pre-put hooks
""" """
from django.conf import settings from django.conf import settings
from evennia import AttributeProperty, CmdSet, DefaultObject from evennia import AttributeProperty, CmdSet, DefaultObject

View file

@ -615,9 +615,11 @@ class CraftingRecipe(CraftingRecipeBase):
) )
else: else:
self.output_names = [ self.output_names = [
(
prot.get("key", prot.get("typeclass", "unnamed")) prot.get("key", prot.get("typeclass", "unnamed"))
if isinstance(prot, dict) if isinstance(prot, dict)
else str(prot) else str(prot)
)
for prot in self.output_prototypes for prot in self.output_prototypes
] ]

View file

@ -3,7 +3,6 @@ Test gendersub contrib.
""" """
from mock import patch from mock import patch
from evennia.commands.default.tests import BaseEvenniaCommandTest from evennia.commands.default.tests import BaseEvenniaCommandTest

View file

@ -25,6 +25,7 @@ Reload the server and you should have the +desc command available (it
will replace the default `desc` command). will replace the default `desc` command).
""" """
import re import re
from evennia import default_cmds from evennia import default_cmds

View file

@ -47,8 +47,17 @@ from collections import deque
from django.conf import settings from django.conf import settings
from django.db.models import Q from django.db.models import Q
from evennia import (CmdSet, DefaultRoom, EvEditor, FuncParser,
InterruptCommand, default_cmds, gametime, utils) from evennia import (
CmdSet,
DefaultRoom,
EvEditor,
FuncParser,
InterruptCommand,
default_cmds,
gametime,
utils,
)
from evennia.typeclasses.attributes import AttributeProperty from evennia.typeclasses.attributes import AttributeProperty
from evennia.utils.utils import list_to_string, repeat from evennia.utils.utils import list_to_string, repeat
@ -814,7 +823,6 @@ class CmdExtendedRoomDesc(default_cmds.CmdDesc):
class CmdExtendedRoomDetail(default_cmds.MuxCommand): class CmdExtendedRoomDetail(default_cmds.MuxCommand):
""" """
sets a detail on a room sets a detail on a room

View file

@ -6,11 +6,12 @@ Testing of ExtendedRoom contrib
import datetime import datetime
from django.conf import settings from django.conf import settings
from evennia import create_object
from evennia.utils.test_resources import BaseEvenniaCommandTest, EvenniaTestCase
from mock import Mock, patch from mock import Mock, patch
from parameterized import parameterized from parameterized import parameterized
from evennia import create_object
from evennia.utils.test_resources import BaseEvenniaCommandTest, EvenniaTestCase
from . import extended_room from . import extended_room

View file

@ -56,6 +56,7 @@ This changes the default map width/height. 2-5 for most clients is sensible.
If you don't want the player to be able to specify the size of the map, ignore any If you don't want the player to be able to specify the size of the map, ignore any
arguments passed into the Map command. arguments passed into the Map command.
""" """
import time import time
from django.conf import settings from django.conf import settings

View file

@ -3,7 +3,6 @@ Tests of ingame_map_display.
""" """
from typeclasses import exits, rooms from typeclasses import exits, rooms
from evennia.commands.default.tests import BaseEvenniaCommandTest from evennia.commands.default.tests import BaseEvenniaCommandTest

View file

@ -3,7 +3,6 @@ Tests of simpledoor.
""" """
from evennia.commands.default.tests import BaseEvenniaCommandTest from evennia.commands.default.tests import BaseEvenniaCommandTest
from . import simpledoor from . import simpledoor

View file

@ -2,6 +2,7 @@
XYZGrid - Griatch 2021 XYZGrid - Griatch 2021
""" """
from . import ( from . import (
example, example,
launchcmd, launchcmd,

View file

@ -14,6 +14,7 @@ and/or
{'prototype_parent': 'xyz_exit', ...} {'prototype_parent': 'xyz_exit', ...}
""" """
from django.conf import settings from django.conf import settings
try: try:

View file

@ -3,14 +3,15 @@
Tests for the XYZgrid system. Tests for the XYZgrid system.
""" """
from random import randint from random import randint
from unittest import mock from unittest import mock
from django.test import TestCase from django.test import TestCase
from evennia.utils.test_resources import (BaseEvenniaCommandTest,
BaseEvenniaTest)
from parameterized import parameterized from parameterized import parameterized
from evennia.utils.test_resources import BaseEvenniaCommandTest, BaseEvenniaTest
from . import commands, xymap, xymap_legend, xyzgrid, xyzroom from . import commands, xymap, xymap_legend, xyzgrid, xyzroom
MAP1 = """ MAP1 = """

View file

@ -92,6 +92,7 @@ See `./example.py` for a full grid example.
---- ----
""" """
import pickle import pickle
from collections import defaultdict from collections import defaultdict
from os import mkdir from os import mkdir
@ -108,6 +109,7 @@ except ImportError as err:
"the SciPy package. Install with `pip install scipy'." "the SciPy package. Install with `pip install scipy'."
) )
from django.conf import settings from django.conf import settings
from evennia.prototypes import prototypes as protlib from evennia.prototypes import prototypes as protlib
from evennia.prototypes.spawner import flatten_prototype from evennia.prototypes.spawner import flatten_prototype
from evennia.utils import logger from evennia.utils import logger
@ -172,6 +174,7 @@ class XYMap:
but recommended for readability! but recommended for readability!
""" """
mapcorner_symbol = "+" mapcorner_symbol = "+"
max_pathfinding_length = 500 max_pathfinding_length = 500
empty_symbol = " " empty_symbol = " "
@ -475,11 +478,11 @@ class XYMap:
max_X, max_Y = max(max_X, iX), max(max_Y, iY) max_X, max_Y = max(max_X, iX), max(max_Y, iY)
node_index += 1 node_index += 1
xygrid[ix][iy] = XYgrid[iX][iY] = node_index_map[ xygrid[ix][iy] = XYgrid[iX][iY] = node_index_map[node_index] = (
node_index mapnode_or_link_class(
] = mapnode_or_link_class(
x=ix, y=iy, Z=self.Z, node_index=node_index, symbol=char, xymap=self x=ix, y=iy, Z=self.Z, node_index=node_index, symbol=char, xymap=self
) )
)
else: else:
# we have a link at this xygrid position (this is ok everywhere) # we have a link at this xygrid position (this is ok everywhere)
@ -668,8 +671,7 @@ class XYMap:
""" """
global _XYZROOMCLASS global _XYZROOMCLASS
if not _XYZROOMCLASS: if not _XYZROOMCLASS:
from evennia.contrib.grid.xyzgrid.xyzroom import \ from evennia.contrib.grid.xyzgrid.xyzroom import XYZRoom as _XYZROOMCLASS
XYZRoom as _XYZROOMCLASS
x, y = xy x, y = xy
wildcard = "*" wildcard = "*"
spawned = [] spawned = []

View file

@ -20,11 +20,11 @@ import uuid
from collections import defaultdict from collections import defaultdict
from django.core import exceptions as django_exceptions from django.core import exceptions as django_exceptions
from evennia.prototypes import spawner from evennia.prototypes import spawner
from evennia.utils.utils import class_from_module from evennia.utils.utils import class_from_module
from .utils import (BIGVAL, MAPSCAN, REVERSE_DIRECTIONS, MapError, from .utils import BIGVAL, MAPSCAN, REVERSE_DIRECTIONS, MapError, MapParserError
MapParserError)
NodeTypeclass = None NodeTypeclass = None
ExitTypeclass = None ExitTypeclass = None
@ -844,6 +844,7 @@ class SmartRerouterMapLink(MapLink):
/| /|
""" """
multilink = True multilink = True
def get_direction(self, start_direction): def get_direction(self, start_direction):

View file

@ -16,6 +16,7 @@ The grid has three main functions:
""" """
from evennia.scripts.scripts import DefaultScript from evennia.scripts.scripts import DefaultScript
from evennia.utils import logger from evennia.utils import logger
from evennia.utils.utils import variable_from_module from evennia.utils.utils import variable_from_module

View file

@ -1,4 +1,3 @@
from .buff import (BaseBuff, BuffableProperty, BuffHandler, CmdBuff, # noqa from .buff import CmdBuff # noqa
Mod, cleanup_buffs, tick_buff) from .buff import BaseBuff, BuffableProperty, BuffHandler, Mod, cleanup_buffs, tick_buff
from .samplebuffs import (Exploit, Exploited, Leeching, Poison, Sated, # noqa from .samplebuffs import Exploit, Exploited, Leeching, Poison, Sated, StatBuff # noqa
StatBuff)

View file

@ -98,6 +98,7 @@ You can see all the features of the `BaseBuff` class below, or browse `samplebuf
many attributes and hook methods you can overload to create complex, interrelated buffs. many attributes and hook methods you can overload to create complex, interrelated buffs.
""" """
import time import time
from random import random from random import random

View file

@ -1,6 +1,7 @@
""" """
Tests for the buff system contrib Tests for the buff system contrib
""" """
from unittest.mock import Mock, call, patch from unittest.mock import Mock, call, patch
from evennia import DefaultObject, create_object from evennia import DefaultObject, create_object

View file

@ -15,6 +15,7 @@ and examples, including how to allow players to choose and confirm
character names from within the menu. character names from within the menu.
""" """
import string import string
from random import choices from random import choices

View file

@ -57,6 +57,7 @@ of the roll separately:
""" """
import re import re
from ast import literal_eval from ast import literal_eval
from random import randint from random import randint

View file

@ -137,6 +137,7 @@ This allows to quickly build a large corpus of translated words
that never change (if this is desired). that never change (if this is desired).
""" """
import re import re
from collections import defaultdict from collections import defaultdict
from random import choice, randint from random import choice, randint

View file

@ -148,19 +148,25 @@ Extra Installation Instructions:
`type/reset/force me = typeclasses.characters.Character` `type/reset/force me = typeclasses.characters.Character`
""" """
import re import re
from collections import defaultdict from collections import defaultdict
from string import punctuation from string import punctuation
import inflect import inflect
from django.conf import settings from django.conf import settings
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
from evennia.commands.command import Command from evennia.commands.command import Command
from evennia.objects.models import ObjectDB from evennia.objects.models import ObjectDB
from evennia.objects.objects import DefaultCharacter, DefaultObject from evennia.objects.objects import DefaultCharacter, DefaultObject
from evennia.utils import ansi, logger from evennia.utils import ansi, logger
from evennia.utils.utils import (iter_to_str, lazy_property, make_iter, from evennia.utils.utils import (
variable_from_module) iter_to_str,
lazy_property,
make_iter,
variable_from_module,
)
_INFLECT = inflect.engine() _INFLECT = inflect.engine()

View file

@ -2,9 +2,11 @@
Tests for RP system Tests for RP system
""" """
import time import time
from anything import Anything from anything import Anything
from evennia import DefaultObject, create_object, default_cmds from evennia import DefaultObject, create_object, default_cmds
from evennia.commands.default import building from evennia.commands.default import building
from evennia.commands.default.tests import BaseEvenniaCommandTest from evennia.commands.default.tests import BaseEvenniaCommandTest

View file

@ -452,7 +452,6 @@ class Character(DefaultCharacter):
""" """
from functools import total_ordering from functools import total_ordering
from time import time from time import time

View file

@ -13,6 +13,7 @@ The script will only send messages to the object it is stored on, so
make sure to put it on yourself or you won't see any messages! make sure to put it on yourself or you won't see any messages!
""" """
import random import random
from evennia import DefaultScript from evennia import DefaultScript

View file

@ -2,6 +2,7 @@
Tests for the bodyfunctions. Tests for the bodyfunctions.
""" """
from mock import Mock, patch from mock import Mock, patch
from evennia.utils.test_resources import BaseEvenniaTest from evennia.utils.test_resources import BaseEvenniaTest

View file

@ -49,9 +49,9 @@ class AIHandler:
def __init__(self, obj): def __init__(self, obj):
self.obj = obj self.obj = obj
self.ai_state = obj.attributes.get(self.attribute_name, self.ai_state = obj.attributes.get(
category=self.attribute_category, self.attribute_name, category=self.attribute_category, default="idle"
default="idle") )
def set_state(self, state): def set_state(self, state):
self.ai_state = state self.ai_state = state
@ -122,6 +122,7 @@ class AIMixin:
of multiple inheritance. In a real game, you would probably want to use a mixin like this. of multiple inheritance. In a real game, you would probably want to use a mixin like this.
""" """
@lazy_property @lazy_property
def ai(self): def ai(self):
return AIHandler(self) return AIHandler(self)

View file

@ -2,6 +2,7 @@
EvAdventure character generation. EvAdventure character generation.
""" """
from django.conf import settings from django.conf import settings
from evennia.objects.models import ObjectDB from evennia.objects.models import ObjectDB

View file

@ -18,7 +18,6 @@ action that takes several vulnerable turns to complete.
""" """
import random import random
from collections import defaultdict from collections import defaultdict
@ -26,9 +25,15 @@ from evennia import AttributeProperty, CmdSet, Command, EvMenu
from evennia.utils import inherits_from, list_to_string from evennia.utils import inherits_from, list_to_string
from .characters import EvAdventureCharacter from .characters import EvAdventureCharacter
from .combat_base import (CombatAction, CombatActionAttack, CombatActionHold, from .combat_base import (
CombatActionStunt, CombatActionUseItem, CombatAction,
CombatActionWield, EvAdventureCombatBaseHandler) CombatActionAttack,
CombatActionHold,
CombatActionStunt,
CombatActionUseItem,
CombatActionWield,
EvAdventureCombatBaseHandler,
)
from .enums import Ability from .enums import Ability

View file

@ -6,15 +6,27 @@ This implements a 'twitch' (aka DIKU or other traditional muds) style of MUD com
---- ----
""" """
from evennia import AttributeProperty, CmdSet, default_cmds from evennia import AttributeProperty, CmdSet, default_cmds
from evennia.commands.command import Command, InterruptCommand from evennia.commands.command import Command, InterruptCommand
from evennia.utils.utils import (display_len, inherits_from, list_to_string, from evennia.utils.utils import (
pad, repeat, unrepeat) display_len,
inherits_from,
list_to_string,
pad,
repeat,
unrepeat,
)
from .characters import EvAdventureCharacter from .characters import EvAdventureCharacter
from .combat_base import (CombatActionAttack, CombatActionHold, from .combat_base import (
CombatActionStunt, CombatActionUseItem, CombatActionAttack,
CombatActionWield, EvAdventureCombatBaseHandler) CombatActionHold,
CombatActionStunt,
CombatActionUseItem,
CombatActionWield,
EvAdventureCombatBaseHandler,
)
from .enums import ABILITY_REVERSE_MAP from .enums import ABILITY_REVERSE_MAP

View file

@ -105,10 +105,10 @@ class EvAdventureDungeonRoom(EvAdventureRoom):
""" """
self.tags.add("not_clear", category="dungeon_room") self.tags.add("not_clear", category="dungeon_room")
def clear_room(self): def clear_room(self):
self.tags.remove("not_clear", category="dungeon_room") self.tags.remove("not_clear", category="dungeon_room")
@property @property
def is_room_clear(self): def is_room_clear(self):
return not bool(self.tags.get("not_clear", category="dungeon_room")) return not bool(self.tags.get("not_clear", category="dungeon_room"))
@ -146,9 +146,7 @@ class EvAdventureDungeonExit(DefaultExit):
dungeon_branch = self.location.db.dungeon_branch dungeon_branch = self.location.db.dungeon_branch
if target_location == self.location: if target_location == self.location:
# destination points back to us - create a new room # destination points back to us - create a new room
self.destination = target_location = dungeon_branch.new_room( self.destination = target_location = dungeon_branch.new_room(self)
self
)
dungeon_branch.register_exit_traversed(self) dungeon_branch.register_exit_traversed(self)
super().at_traverse(traversing_object, target_location, **kwargs) super().at_traverse(traversing_object, target_location, **kwargs)

View file

@ -17,6 +17,7 @@ To get the `value` of an enum (must always be hashable, useful for Attribute loo
---- ----
""" """
from enum import Enum from enum import Enum

View file

@ -2,6 +2,7 @@
EvAdventure NPCs. This includes both friends and enemies, only separated by their AI. EvAdventure NPCs. This includes both friends and enemies, only separated by their AI.
""" """
from random import choice from random import choice
from evennia import DefaultCharacter from evennia import DefaultCharacter
@ -253,6 +254,7 @@ class EvAdventureMob(EvAdventureNPC):
Mob (mobile) NPC; this is usually an enemy. Mob (mobile) NPC; this is usually an enemy.
""" """
# change this to make the mob more or less likely to perform different actions # change this to make the mob more or less likely to perform different actions
combat_probabilities = { combat_probabilities = {
"hold": 0.0, "hold": 0.0,

View file

@ -59,7 +59,6 @@ class EvAdventureQuest:
desc = "This is the base quest class" desc = "This is the base quest class"
start_step = "start" start_step = "start"
# help entries for quests (could also be methods) # help entries for quests (could also be methods)
help_start = "You need to start first" help_start = "You need to start first"
help_end = "You need to end the quest" help_end = "You need to end the quest"
@ -191,8 +190,9 @@ class EvAdventureQuest:
""" """
if self.status in ("abandoned", "completed", "failed"): if self.status in ("abandoned", "completed", "failed"):
help_resource = getattr(self, f"help_{self.status}", help_resource = getattr(
f"You have {self.status} this quest.") self, f"help_{self.status}", f"You have {self.status} this quest."
)
else: else:
help_resource = getattr(self, f"help_{self.current_step}", "No help available.") help_resource = getattr(self, f"help_{self.current_step}", "No help available.")
@ -203,7 +203,6 @@ class EvAdventureQuest:
# normally it's just a string # normally it's just a string
return str(help_resource) return str(help_resource)
# step methods and hooks # step methods and hooks
def step_start(self, *args, **kwargs): def step_start(self, *args, **kwargs):
@ -377,6 +376,7 @@ class CmdQuests(Command):
quest <questname> quest <questname>
""" """
key = "quests" key = "quests"
aliases = ["quest"] aliases = ["quest"]
@ -399,4 +399,3 @@ class CmdQuests(Command):
for quest in quests: for quest in quests:
self.msg(f"Quest {quest.key}: {quest.status}") self.msg(f"Quest {quest.key}: {quest.status}")

View file

@ -7,6 +7,7 @@ and determining what the outcome is.
---- ----
""" """
from random import randint from random import randint
from .enums import Ability from .enums import Ability

View file

@ -2,6 +2,7 @@
Test the ai module. Test the ai module.
""" """
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from evennia import create_object from evennia import create_object

View file

@ -3,7 +3,6 @@ Test the EvAdventure equipment handler.
""" """
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from parameterized import parameterized from parameterized import parameterized

View file

@ -17,7 +17,6 @@ Attacks using |w{attack_type_name}|n against |w{defense_type_name}|n
Damage roll: |w{damage_roll}|n""".strip() Damage roll: |w{damage_roll}|n""".strip()
def get_obj_stats(obj, owner=None): def get_obj_stats(obj, owner=None):
""" """
Get a string of stats about the object. Get a string of stats about the object.

View file

@ -31,6 +31,7 @@ Timers are handled by persistent delays on the button. These are examples of
such as when closing the lid and un-blinding a character. such as when closing the lid and un-blinding a character.
""" """
import random import random
from evennia import CmdSet, Command, DefaultObject from evennia import CmdSet, Command, DefaultObject

View file

@ -2,6 +2,7 @@
Tutorial - talking NPC tests. Tutorial - talking NPC tests.
""" """
from evennia.commands.default.tests import BaseEvenniaCommandTest from evennia.commands.default.tests import BaseEvenniaCommandTest
from evennia.utils.create import create_object from evennia.utils.create import create_object

View file

@ -9,7 +9,6 @@ in a separate module (e.g. if they could have been re-used elsewhere.)
""" """
import random import random
# the system error-handling module is defined in the settings. We load the # the system error-handling module is defined in the settings. We load the

View file

@ -13,6 +13,7 @@ the easiest place to do it. Write a method and invoke it via
Evennia contribution - Johnny 2017 Evennia contribution - Johnny 2017
""" """
import json import json
import syslog import syslog

View file

@ -5,6 +5,7 @@ user inputs and system outputs.
Evennia contribution - Johnny 2017 Evennia contribution - Johnny 2017
""" """
import os import os
import re import re
import socket import socket

View file

@ -138,6 +138,7 @@ Optional:
object dbrefs). For boolean fields, return '0' or '1' to set object dbrefs). For boolean fields, return '0' or '1' to set
the field to False or True. the field to False or True.
""" """
import evennia import evennia
from evennia import Command from evennia import Command
from evennia.utils import delay, evmenu, evtable, list_to_string, logger from evennia.utils import delay, evmenu, evtable, list_to_string, logger

View file

@ -59,7 +59,6 @@ from evennia.utils.create import create_script
class RejectedRegex(RuntimeError): class RejectedRegex(RuntimeError):
"""The provided regular expression has been rejected. """The provided regular expression has been rejected.
More details regarding why this error occurred will be provided in More details regarding why this error occurred will be provided in
@ -72,14 +71,12 @@ class RejectedRegex(RuntimeError):
class ExhaustedGenerator(RuntimeError): class ExhaustedGenerator(RuntimeError):
"""The generator hasn't any available strings to generate anymore.""" """The generator hasn't any available strings to generate anymore."""
pass pass
class RandomStringGeneratorScript(DefaultScript): class RandomStringGeneratorScript(DefaultScript):
""" """
The global script to hold all generators. The global script to hold all generators.
@ -99,7 +96,6 @@ class RandomStringGeneratorScript(DefaultScript):
class RandomStringGenerator: class RandomStringGenerator:
""" """
A generator class to generate pseudo-random strings with a rule. A generator class to generate pseudo-random strings with a rule.

View file

@ -7,6 +7,7 @@ is setup to be the "default" character type created by the default
creation commands. creation commands.
""" """
from evennia.objects.objects import DefaultCharacter from evennia.objects.objects import DefaultCharacter
from .objects import ObjectParent from .objects import ObjectParent

View file

@ -6,6 +6,7 @@ set and has a single command defined on itself with the same name as its key,
for allowing Characters to traverse the exit to its destination. for allowing Characters to traverse the exit to its destination.
""" """
from evennia.objects.objects import DefaultExit from evennia.objects.objects import DefaultExit
from .objects import ObjectParent from .objects import ObjectParent

View file

@ -10,6 +10,7 @@ the other types, you can do so by adding this as a multiple
inheritance. inheritance.
""" """
from evennia.objects.objects import DefaultObject from evennia.objects.objects import DefaultObject

View file

@ -6,7 +6,6 @@ The main web/urls.py includes these routes for all urls starting with `admin/`
""" """
from django.urls import path from django.urls import path
from evennia.web.admin.urls import urlpatterns as evennia_admin_urlpatterns from evennia.web.admin.urls import urlpatterns as evennia_admin_urlpatterns

View file

@ -12,6 +12,7 @@ should modify urls.py in those sub directories.
Search the Django documentation for "URL dispatcher" for more help. Search the Django documentation for "URL dispatcher" for more help.
""" """
from django.urls import include, path from django.urls import include, path
# default evennia patterns # default evennia patterns

View file

@ -1,6 +1,7 @@
""" """
Custom manager for HelpEntry objects. Custom manager for HelpEntry objects.
""" """
from django.db import IntegrityError from django.db import IntegrityError
from evennia.server import signals from evennia.server import signals

View file

@ -9,6 +9,7 @@ forms of help that do not concern commands, like information about the
game world, policy info, rules and similar. game world, policy info, rules and similar.
""" """
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db import models from django.db import models
from django.urls import reverse from django.urls import reverse

View file

@ -5,6 +5,7 @@ sub-categories.
This is used primarily by the default `help` command. This is used primarily by the default `help` command.
""" """
import re import re
from django.conf import settings from django.conf import settings

Some files were not shown because too many files have changed in this diff Show more