Ran black on sources

This commit is contained in:
Griatch 2023-11-02 20:56:31 +01:00
parent 24d52f229f
commit f6b43b0416
125 changed files with 355 additions and 329 deletions

View file

@ -126,6 +126,7 @@ from inspect import getfullargspec
from textwrap import dedent
from django.conf import settings
from evennia import CmdSet, Command
from evennia.commands import cmdhandler
from evennia.utils.ansi import strip_ansi

View file

@ -98,6 +98,7 @@ class TestBuildingMenu(BaseEvenniaCommandTest):
def test_multi_level(self):
"""Test multi-level choices."""
# Creaste three succeeding menu (t2 is contained in t1, t3 is contained in t2)
def on_nomatch_t1(caller, menu):
menu.move("whatever") # this will be valid since after t1 is a joker

View file

@ -58,7 +58,7 @@ class TestComponents(EvenniaTest):
InheritedTCWithComponents, key="char_with_c", location=self.room1, home=self.room1
)
assert self.char1.test_a
assert not self.char1.cmp.get('test_c')
assert not self.char1.cmp.get("test_c")
assert char_with_c.test_c
def test_character_instances_components_properly(self):

View file

@ -70,6 +70,7 @@ def start_plugin_services(portal):
factory.noisy = False
factory.protocol = GodotWebSocketClient
from evennia.server.portal.portalsessionhandler import PORTAL_SESSIONS
factory.sessionhandler = PORTAL_SESSIONS
interface = "127.0.0.1" if LOCKDOWN_MODE else settings.GODOT_CLIENT_WEBSOCKET_CLIENT_INTERFACE

View file

@ -167,7 +167,6 @@ def node_enter_password(caller, raw_string, **kwargs):
username = kwargs["username"]
if kwargs["new_user"]:
if kwargs.get("retry_password"):
# Attempting to fix password
text = "Enter a new password:"

View file

@ -296,7 +296,6 @@ class CmdWho(CmdEvscapeRoom, default_cmds.CmdWho):
obj2_search = False
def func(self):
caller = self.caller
if self.args == "all":
@ -344,7 +343,6 @@ class CmdSpeak(Command):
arg_regex = r"\w|\s|$"
def func(self):
args = self.args.strip()
caller = self.caller
action = self.cmdname
@ -584,7 +582,6 @@ class CmdFocusInteraction(CmdEvscapeRoom):
self.room = self.caller.location
def func(self):
focused = self.focus
action = self.action
@ -604,7 +601,6 @@ class CmdStand(CmdEvscapeRoom):
key = "stand"
def func(self):
# Positionable objects will set this flag on you.
pos = self.caller.attributes.get("position", category=self.room.tagcategory)
@ -710,7 +706,6 @@ class CmdSetFlag(CmdEvscapeRoom):
obj2_search = False
def func(self):
if not self.arg2:
self.caller.msg("Usage: flag <obj> with <flagname>")
return

View file

@ -66,7 +66,6 @@ def _move_to_room(caller, raw_string, **kwargs):
def _create_new_room(caller, raw_string, **kwargs):
# create a random name, retrying until we find
# a unique one
key = create_fantasy_word(length=5, capitalize=True)
@ -147,7 +146,6 @@ def node_start(caller, raw_string, **kwargs):
def node_set_desc(caller, raw_string, **kwargs):
current_desc = kwargs.get("desc", caller.db.desc)
text = (
@ -176,7 +174,6 @@ def node_set_desc(caller, raw_string, **kwargs):
def node_create_room(caller, raw_string, **kwargs):
text = _CREATE_ROOM_TEXT
options = (
@ -188,7 +185,6 @@ def node_create_room(caller, raw_string, **kwargs):
def node_join_room(caller, raw_string, **kwargs):
room = kwargs["room"]
stats = room.db.stats or {"progress": 0}
@ -282,7 +278,6 @@ def _set_thing_style(caller, raw_string, **kwargs):
def _toggle_screen_reader(caller, raw_string, **kwargs):
session = kwargs["session"]
# flip old setting
session.protocol_flags["SCREENREADER"] = not session.protocol_flags.get("SCREENREADER", False)

View file

@ -416,7 +416,6 @@ class Rotatable(EvscaperoomObject):
self.set_flag("rotatable")
def at_focus_rotate(self, caller, **kwargs):
if self.check_flag("rotatable"):
self.at_rotate(caller)
else:
@ -501,7 +500,6 @@ class Readable(EvscaperoomObject):
self.set_flag(self.read_flag)
def at_focus_read(self, caller, **kwargs):
if self.read_flag is None or self.check_flag(self.read_flag):
self.at_read(caller)
else:
@ -525,7 +523,6 @@ class IndexReadable(Readable):
index = {"page1": "This is page1", "page2": "This is page2", "page two": "page2"} # alias
def at_focus_read(self, caller, **kwargs):
topic = kwargs.get("args").strip().lower()
entry = self.index.get(topic, None)
@ -931,7 +928,6 @@ class CodeInput(EvscaperoomObject):
infinitely_locked = False
def at_focus_code(self, caller, **kwargs):
args = self.parse(kwargs["args"].strip())
if not args:

View file

@ -14,7 +14,6 @@ from .room import EvscapeRoom
class CleanupScript(DefaultScript):
def at_script_creation(self):
self.key = "evscaperoom_cleanup"
self.desc = "Cleans up empty evscaperooms"
@ -23,7 +22,6 @@ class CleanupScript(DefaultScript):
self.persistent = True
def at_repeat(self):
for room in EvscapeRoom.objects.all():
if not room.get_all_characters():
# this room is empty

View file

@ -24,7 +24,6 @@ class TestEvscaperoomCommands(BaseEvenniaCommandTest):
self.obj1.location = self.room1
def test_base_search(self):
cmd = commands.CmdEvscapeRoom()
cmd.caller = self.char1
@ -35,7 +34,6 @@ class TestEvscaperoomCommands(BaseEvenniaCommandTest):
self.assertRaises(InterruptCommand, cmd._search, "Foo", True)
def test_base_parse(self):
cmd = commands.CmdEvscapeRoom()
cmd.caller = self.char1
@ -211,7 +209,6 @@ class TestUtils(BaseEvenniaTest):
self.assertTrue(bool(obj2.pk))
def test_parse_for_perspectives(self):
second, third = utils.parse_for_perspectives("~You ~look at the nice book", "TestGuy")
self.assertTrue(second, "You look at the nice book")
self.assertTrue(third, "TestGuy looks at the nice book")
@ -221,7 +218,6 @@ class TestUtils(BaseEvenniaTest):
self.assertTrue(third, "With a smile, TestGuy was gone")
def test_parse_for_things(self):
string = "Looking at *book and *key."
self.assertEqual(utils.parse_for_things(string, 0), "Looking at book and key.")
self.assertEqual(utils.parse_for_things(string, 1), "Looking at |ybook|n and |ykey|n.")
@ -240,7 +236,6 @@ class TestEvScapeRoom(BaseEvenniaTest):
self.room.delete()
def test_room_methods(self):
room = self.room
self.char1.location = room
@ -279,7 +274,6 @@ class TestStates(BaseEvenniaTest):
return states
def test_base_state(self):
st = basestate.BaseState(self.room.statehandler, self.room)
st.init()
obj = st.create_object(objects.Edible, key="apple")
@ -291,7 +285,6 @@ class TestStates(BaseEvenniaTest):
"Tick through all defined states"
for mod in self._get_all_state_modules():
state = mod.State(self.room.statehandler, self.room)
state.init()

View file

@ -33,7 +33,7 @@ or implement the same locks/hooks in your own typeclasses.
from django.conf import settings
from evennia import AttributeProperty, CmdSet, DefaultObject
from evennia.commands.default.general import CmdLook, CmdGet, CmdDrop
from evennia.commands.default.general import CmdDrop, CmdGet, CmdLook
from evennia.utils import class_from_module
# establish the right inheritance for container objects

View file

@ -1,6 +1,7 @@
from evennia import create_object
from evennia.utils.test_resources import BaseEvenniaTest, BaseEvenniaCommandTest # noqa
from .containers import ContribContainer, CmdContainerGet, CmdContainerLook, CmdPut
from evennia.utils.test_resources import BaseEvenniaCommandTest, BaseEvenniaTest # noqa
from .containers import CmdContainerGet, CmdContainerLook, CmdPut, ContribContainer
class TestContainer(BaseEvenniaTest):
@ -52,7 +53,7 @@ class TestContainerCmds(BaseEvenniaCommandTest):
# move object to character to try putting
self.obj1.location = self.char1
self.call(CmdPut(), "obj in box", "You can't put things in that.")
def test_at_capacity_put(self):
# set container capacity
self.container.capacity = 1
@ -61,5 +62,3 @@ class TestContainerCmds(BaseEvenniaCommandTest):
# move object to character to try putting
self.obj1.location = self.char1
self.call(CmdPut(), "obj in box", "You can't fit anything else in a Box.")

View file

@ -318,7 +318,6 @@ class CraftingRecipeBase:
"""
craft_result = None
if self.allow_craft:
# override/extend craft_kwargs from initialization.
craft_kwargs = copy(self.craft_kwargs)
craft_kwargs.update(kwargs)
@ -626,7 +625,6 @@ class CraftingRecipe(CraftingRecipeBase):
self.allow_reuse = not bool(self.consumable_tags)
def _format_message(self, message, **kwargs):
missing = iter_to_str(kwargs.get("missing", ""))
excess = iter_to_str(kwargs.get("excess", ""))
involved_tools = iter_to_str(kwargs.get("tools", ""))
@ -702,7 +700,6 @@ class CraftingRecipe(CraftingRecipeBase):
tools = []
for itag, tag in enumerate(cls.tool_tags):
tools.append(
create_object(
key=tool_key or (cls.tool_names[itag] if cls.tool_names else tag.capitalize()),

View file

@ -511,7 +511,6 @@ class CmdCast(Command):
self.target = self.caller
def func(self):
# all items carried by the caller could work
possible_tools = self.caller.contents

View file

@ -646,7 +646,6 @@ class CmdUsePuzzleParts(MuxCommand):
return
if not part.tags.get(_PUZZLES_TAG_MEMBER, category=_PUZZLES_TAG_CATEGORY):
# not a puzzle part ... abort
caller.msg("You have no idea how %s can be used" % (many))
return

View file

@ -184,7 +184,6 @@ class TestPuzzles(BaseEvenniaCommandTest):
return msg
def test_cmd_use(self):
self._use("", "Use what?")
self._use("something", "There is no something around.")
self._use("steel", "You have no idea how this can be used")

View file

@ -323,7 +323,7 @@ class TBBasicCharacter(DefaultCharacter):
can be changed at creation and factor into combat calculations.
"""
def at_pre_move(self, destination, move_type='move', **kwargs):
def at_pre_move(self, destination, move_type="move", **kwargs):
"""
Called just before starting to move this object to
destination.

View file

@ -259,7 +259,6 @@ class ItemCombatRules(tb_basic.BasicCombatRules):
user.msg("%s has %i uses remaining." % (item.key.capitalize(), item.db.item_uses))
else: # All uses spent
if not item.db.item_consumable: # Item isn't consumable
# Just inform the player that the uses are gone
user.msg("%s has no uses remaining." % item.key.capitalize())

View file

@ -14,7 +14,6 @@ from . import tb_basic, tb_equip, tb_items, tb_magic, tb_range
class TestTurnBattleBasicCmd(BaseEvenniaCommandTest):
# Test basic combat commands
def test_turnbattlecmd(self):
self.call(tb_basic.CmdFight(), "", "You can't start a fight if you've been defeated!")
@ -81,7 +80,6 @@ class TestTurnBattleItemsCmd(BaseEvenniaCommandTest):
class TestTurnBattleMagicCmd(BaseEvenniaCommandTest):
# Test magic commands
def test_turnbattlemagiccmd(self):
self.call(tb_magic.CmdStatus(), "", "You have 100 / 100 HP and 20 / 20 MP.")

View file

@ -47,6 +47,7 @@ from collections import deque
from django.conf import settings
from django.db.models import Q
from evennia import (
CmdSet,
DefaultRoom,

View file

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

View file

@ -123,7 +123,13 @@ create a new wilderness (with the name "default") but using our new map provider
"""
from evennia import DefaultExit, DefaultRoom, DefaultScript, create_object, create_script
from evennia import (
DefaultExit,
DefaultRoom,
DefaultScript,
create_object,
create_script,
)
from evennia.typeclasses.attributes import AttributeProperty
from evennia.utils import inherits_from

View file

@ -2,6 +2,16 @@
XYZGrid - Griatch 2021
"""
from . import example, launchcmd, prototypes, tests, utils, xymap, xymap_legend, xyzgrid, xyzroom
from . import (
example,
launchcmd,
prototypes,
tests,
utils,
xymap,
xymap_legend,
xyzgrid,
xyzroom,
)
from . import commands # isort:skip - this needs to be imported last

View file

@ -10,6 +10,7 @@ the commands with XYZ-aware equivalents.
from collections import namedtuple
from django.conf import settings
from evennia import CmdSet, InterruptCommand, default_cmds
from evennia.commands.default import building
from evennia.contrib.grid.xyzgrid.xyzgrid import get_xyzgrid
@ -227,7 +228,6 @@ class CmdGoto(COMMAND_DEFAULT_CLASS):
step_sequence=None,
step=True,
):
path_data = caller.ndb.xy_path_data
if target:
@ -244,7 +244,6 @@ class CmdGoto(COMMAND_DEFAULT_CLASS):
)
if step and path_data:
step_sequence = path_data.step_sequence
try:

View file

@ -172,6 +172,7 @@ MAP2 = r"""
"""
# custom map node
class TransitionToLargeTree(xymap_legend.TransitionMapNode):
"""

View file

@ -7,9 +7,10 @@ from random import randint
from unittest import mock
from django.test import TestCase
from evennia.utils.test_resources import BaseEvenniaCommandTest, BaseEvenniaTest
from parameterized import parameterized
from evennia.utils.test_resources import BaseEvenniaCommandTest, BaseEvenniaTest
from . import commands, xymap, xymap_legend, xyzgrid, xyzroom
MAP1 = """

View file

@ -563,7 +563,6 @@ class XYMap:
def _scan_neighbors(
start_node, points, dist=2, xmin=BIGVAL, ymin=BIGVAL, xmax=0, ymax=0, depth=0
):
x0, y0 = start_node.x, start_node.y
points.append((x0, y0))
xmin, xmax = min(xmin, x0), max(xmax, x0)
@ -930,7 +929,7 @@ class XYMap:
# now different from the original for future cropping
width, height = xmax - xmin + 1, ymax - ymin + 1
gridmap = [[" "] * width for _ in range(height)]
for (ix0, iy0) in points:
for ix0, iy0 in points:
gridmap[iy0 - ymin][ix0 - xmin] = display_map[iy0][ix0]
elif mode == "scan":

View file

@ -20,6 +20,7 @@ import uuid
from collections import defaultdict
from django.core import exceptions as django_exceptions
from evennia.prototypes import spawner
from evennia.utils.utils import class_from_module
@ -182,7 +183,6 @@ class MapNode:
# scan in all directions for links
for direction, (dx, dy) in MAPSCAN.items():
lx, ly = x + dx, y + dy
if lx in xygrid and ly in xygrid[lx]:
@ -273,7 +273,6 @@ class MapNode:
return self.X, self.Y, self.Z
def get_exit_spawn_name(self, direction, return_aliases=True):
"""
Retrieve the spawn name for the exit being created by this link.
@ -365,7 +364,6 @@ class MapNode:
maplinks = {}
for direction, link in self.first_links.items():
key, *aliases = self.get_exit_spawn_name(direction)
if not link.prototype.get("prototype_key"):
# generate a deterministic prototype_key if it doesn't exist
@ -389,7 +387,6 @@ class MapNode:
# build all exits first run)
differing_keys = set(maplinks.keys()).symmetric_difference(set(linkobjs.keys()))
for differing_key in differing_keys:
if differing_key not in maplinks:
# an exit without a maplink - delete the exit-object
self.log(f" deleting exit at xyz={xyz}, direction={differing_key}")

View file

@ -150,7 +150,6 @@ class XYZGrid(DefaultScript):
# generate all Maps - this will also initialize their components
# and bake any pathfinding paths (or load from disk-cache)
for zcoord, old_mapdata in mapdata.items():
self.log(f"Loading map '{zcoord}'...")
# we reload the map from module

View file

@ -9,6 +9,7 @@ used as stand-alone XYZ-coordinate-aware rooms.
from django.conf import settings
from django.db.models import Q
from evennia.objects.manager import ObjectManager
from evennia.objects.objects import DefaultExit, DefaultRoom
@ -440,7 +441,6 @@ class XYZRoom(DefaultRoom):
xymap = self.xyzgrid.get_map(xyz[2])
if xymap and kwargs.get("map_display", xymap.options.get("map_display", self.map_display)):
# show the near-area map.
map_character_symbol = kwargs.get(
"map_character_symbol",

View file

@ -168,7 +168,8 @@ class BaseBuff:
Args:
handler: The handler this buff is attached to
buffkey: The key this buff uses on the cache
cache: The cache dictionary (what you get if you use `handler.buffcache.get(key)`)"""
cache: The cache dictionary (what you get if you use `handler.buffcache.get(key)`)
"""
required = {"handler": handler, "buffkey": buffkey, "cache": cache}
self.__dict__.update(cache)
self.__dict__.update(required)
@ -196,7 +197,8 @@ class BaseBuff:
loud: (optional) Whether to call at_remove or not (default: True)
expire: (optional) Whether to call at_expire or not (default: False)
delay: (optional) How long you want to delay the remove call for
context: (optional) A dictionary you wish to pass to the at_remove/at_expire method as kwargs"""
context: (optional) A dictionary you wish to pass to the at_remove/at_expire method as kwargs
"""
if not context:
context = {}
self.handler.remove(self.buffkey, loud=loud, expire=expire, context=context)
@ -207,7 +209,8 @@ class BaseBuff:
Args:
loud: (optional) Whether to call at_remove or not (default: True)
delay: (optional) How long you want to delay the remove call for
context: (optional) A dictionary you wish to pass to the at_remove/at_dispel method as kwargs"""
context: (optional) A dictionary you wish to pass to the at_remove/at_dispel method as kwargs
"""
if not context:
context = {}
self.handler.remove(self.buffkey, loud=loud, dispel=True, delay=delay, context=context)
@ -225,7 +228,8 @@ class BaseBuff:
"""Helper method which unpauses this buff on its handler.
Args:
context: (optional) A dictionary you wish to pass to the at_unpause method as kwargs"""
context: (optional) A dictionary you wish to pass to the at_unpause method as kwargs
"""
if not context:
context = {}
self.handler.unpause(self.buffkey, context)
@ -322,7 +326,6 @@ class Mod:
class BuffHandler:
ownerref = None
dbkey = "buffs"
autopause = False
@ -333,7 +336,8 @@ class BuffHandler:
Args:
owner: The object this handler is attached to
dbkey: (optional) The string key of the db attribute to use for the buff cache
autopause: (optional) Whether this handler autopauses playtime buffs on owning object's unpuppet"""
autopause: (optional) Whether this handler autopauses playtime buffs on owning object's unpuppet
"""
self.ownerref = owner.dbref
self.dbkey = dbkey
self.autopause = autopause
@ -434,7 +438,6 @@ class BuffHandler:
*args,
**kwargs,
):
"""Add a buff to this object, respecting all stacking/refresh/reapplication rules. Takes
a number of optional parameters to allow for customization.
@ -702,7 +705,8 @@ class BuffHandler:
buff: The buff class to search for
to_filter: (optional) A dictionary you wish to slice. If not provided, uses the whole buffcache.
Returns a dictionary of instanced buffs of the specified type in the format {buffkey: instance}."""
Returns a dictionary of instanced buffs of the specified type in the format {buffkey: instance}.
"""
_cache = self.get_all() if not to_filter else to_filter
return {k: _buff for k, _buff in _cache.items() if isinstance(_buff, buff)}
@ -713,7 +717,8 @@ class BuffHandler:
stat: The string identifier to find relevant mods
to_filter: (optional) A dictionary you wish to slice. If not provided, uses the whole buffcache.
Returns a dictionary of instanced buffs which modify the specified stat in the format {buffkey: instance}."""
Returns a dictionary of instanced buffs which modify the specified stat in the format {buffkey: instance}.
"""
_cache = self.traits if not to_filter else to_filter
buffs = {k: buff for k, buff in _cache.items() for m in buff.mods if m.stat == stat}
return buffs
@ -725,7 +730,8 @@ class BuffHandler:
trigger: The string identifier to find relevant buffs
to_filter: (optional) A dictionary you wish to slice. If not provided, uses the whole buffcache.
Returns a dictionary of instanced buffs which fire off the designated trigger, in the format {buffkey: instance}."""
Returns a dictionary of instanced buffs which fire off the designated trigger, in the format {buffkey: instance}.
"""
_cache = self.effects if not to_filter else to_filter
buffs = {k: buff for k, buff in _cache.items() if trigger in buff.triggers}
return buffs
@ -737,7 +743,8 @@ class BuffHandler:
source: The source you want to filter buffs by
to_filter: (optional) A dictionary you wish to slice. If not provided, uses the whole buffcache.
Returns a dictionary of instanced buffs which came from the provided source, in the format {buffkey: instance}."""
Returns a dictionary of instanced buffs which came from the provided source, in the format {buffkey: instance}.
"""
_cache = self.all if not to_filter else to_filter
buffs = {k: buff for k, buff in _cache.items() if buff.source == source}
return buffs
@ -750,7 +757,8 @@ class BuffHandler:
value: (optional) The value to match to. If None, merely checks to see if the value exists
to_filter: (optional) A dictionary you wish to slice. If not provided, uses the whole buffcache.
Returns a dictionary of instanced buffs with cache values matching the specified value, in the format {buffkey: instance}."""
Returns a dictionary of instanced buffs with cache values matching the specified value, in the format {buffkey: instance}.
"""
_cache = self.all if not to_filter else to_filter
if not value:
buffs = {k: buff for k, buff in _cache.items() if buff.cache.get(key)}
@ -907,7 +915,8 @@ class BuffHandler:
Args:
key: The key for the buff you wish to pause
context: (optional) A dictionary you wish to pass to the at_unpause method as kwargs"""
context: (optional) A dictionary you wish to pass to the at_unpause method as kwargs
"""
if key in self.buffcache.keys():
# Mark the buff as unpaused
buff = dict(self.buffcache.get(key))
@ -945,7 +954,8 @@ class BuffHandler:
"""Returns a buff flavor text as a dictionary of tuples in the format {key: (name, flavor)}. Common use for this is a buff readout of some kind.
Args:
to_filter: (optional) The dictionary of buffs to iterate over. If none is provided, returns all buffs (default: None)"""
to_filter: (optional) The dictionary of buffs to iterate over. If none is provided, returns all buffs (default: None)
"""
if not isinstance(to_filter, dict):
raise TypeError
self.cleanup()
@ -1156,7 +1166,8 @@ def tick_buff(handler: BuffHandler, buffkey: str, context=None, initial=True):
handler: The handler managing the ticking buff
buffkey: The key of the ticking buff
context: (optional) A dictionary you wish to pass to the at_tick method as kwargs
initial: (optional) Whether this tick_buff call is the first one. Starts True, changes to False for future ticks"""
initial: (optional) Whether this tick_buff call is the first one. Starts True, changes to False for future ticks
"""
# Cache a reference and find the buff on the object
if buffkey not in handler.buffcache.keys():
return

View file

@ -302,8 +302,7 @@ class CmdDice(default_cmds.MuxCommand):
except ValueError:
self.caller.msg(
"You need to enter valid integer numbers, modifiers and operators."
" |w%s|n was not understood."
% self.args
" |w%s|n was not understood." % self.args
)
return
# format output

View file

@ -3,9 +3,10 @@ Testing of TestDice.
"""
from evennia.commands.default.tests import BaseEvenniaCommandTest
from mock import patch
from evennia.commands.default.tests import BaseEvenniaCommandTest
from . import dice

View file

@ -25,8 +25,6 @@ DEFAULT_LLM_REQUEST_BODY = {...} # see below, this controls how to prompt the
import json
from django.conf import settings
from evennia import logger
from evennia.utils.utils import make_iter
from twisted.internet import defer, protocol, reactor
from twisted.internet.defer import inlineCallbacks
from twisted.web.client import Agent, HTTPConnectionPool, _HTTP11ClientFactory
@ -34,6 +32,9 @@ from twisted.web.http_headers import Headers
from twisted.web.iweb import IBodyProducer
from zope.interface import implementer
from evennia import logger
from evennia.utils.utils import make_iter
DEFAULT_LLM_HOST = "http://127.0.0.1:5000"
DEFAULT_LLM_PATH = "/api/v1/generate"
DEFAULT_LLM_HEADERS = {"Content-Type": "application/json"}

View file

@ -14,11 +14,12 @@ from collections import defaultdict
from random import choice
from django.conf import settings
from evennia import AttributeProperty, Command, DefaultCharacter
from evennia.utils.utils import make_iter
from twisted.internet import reactor, task
from twisted.internet.defer import CancelledError, inlineCallbacks
from evennia import AttributeProperty, Command, DefaultCharacter
from evennia.utils.utils import make_iter
from .llm_client import LLMClient
# fallback if not specified anywhere else. Check order is

View file

@ -5,9 +5,10 @@ Unit tests for the LLM Client and npc.
from anything import Something
from django.test import override_settings
from mock import Mock, patch
from evennia.utils.create import create_object
from evennia.utils.test_resources import EvenniaTestCase
from mock import Mock, patch
from .llm_npc import LLMNPC

View file

@ -154,12 +154,18 @@ from string import punctuation
import inflect
from django.conf import settings
from evennia.commands.cmdset import CmdSet
from evennia.commands.command import Command
from evennia.objects.models import ObjectDB
from evennia.objects.objects import DefaultCharacter, DefaultObject
from evennia.utils import ansi, logger
from evennia.utils.utils import iter_to_str, lazy_property, make_iter, variable_from_module
from evennia.utils.utils import (
iter_to_str,
lazy_property,
make_iter,
variable_from_module,
)
_INFLECT = inflect.engine()

View file

@ -5,6 +5,7 @@ Tests for RP system
import time
from anything import Anything
from evennia import create_object
from evennia.commands.default.tests import BaseEvenniaCommandTest
from evennia.utils.test_resources import BaseEvenniaTest
@ -329,7 +330,6 @@ class TestRPSystemCommands(BaseEvenniaCommandTest):
self.char2.swap_typeclass(rpsystem.ContribRPCharacter)
def test_commands(self):
self.call(
rpsystem.CmdSdesc(), "Foobar Character", "Char's sdesc was set to 'Foobar Character'."
)

View file

@ -3,6 +3,7 @@ EvAdventure character generation.
"""
from django.conf import settings
from evennia.objects.models import ObjectDB
from evennia.prototypes.spawner import spawn
from evennia.utils.create import create_object

View file

@ -8,7 +8,14 @@ This implements a 'twitch' (aka DIKU or other traditional muds) style of MUD com
"""
from evennia import AttributeProperty, CmdSet, default_cmds
from evennia.commands.command import Command, InterruptCommand
from evennia.utils.utils import display_len, inherits_from, list_to_string, pad, repeat, unrepeat
from evennia.utils.utils import (
display_len,
inherits_from,
list_to_string,
pad,
repeat,
unrepeat,
)
from .characters import EvAdventureCharacter
from .combat_base import (

View file

@ -316,11 +316,9 @@ class EvAdventureRollEngine:
setattr(character, abi, current_abi)
character.msg(
"~" * 78
+ "\n|yYou survive your brush with death, "
"~" * 78 + "\n|yYou survive your brush with death, "
f"but are |r{result.upper()}|y and permanently |rlose {loss} {abi}|y.|n\n"
f"|GYou recover |g{new_hp}|G health|.\n"
+ "~" * 78
f"|GYou recover |g{new_hp}|G health|.\n" + "~" * 78
)

View file

@ -43,7 +43,6 @@ class EvAdventureCharacterGenerationTest(BaseEvenniaTest):
@patch("evennia.contrib.tutorials.evadventure.chargen.spawn")
def test_apply(self, mock_spawn):
gambeson = create_object(objects.EvAdventureArmor, key="gambeson")
mock_spawn.return_value = [gambeson]
account = MagicMock()

View file

@ -7,7 +7,11 @@ from unittest.mock import Mock, call, patch
from evennia.utils import create
from evennia.utils.ansi import strip_ansi
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTestMixin, EvenniaTestCase
from evennia.utils.test_resources import (
BaseEvenniaTest,
EvenniaCommandTestMixin,
EvenniaTestCase,
)
from .. import combat_base, combat_turnbased, combat_twitch
from ..characters import EvAdventureCharacter

View file

@ -6,6 +6,7 @@ Test the EvAdventure commands.
from unittest.mock import call, patch
from anything import Something
from evennia.utils.create import create_object
from evennia.utils.test_resources import BaseEvenniaCommandTest

View file

@ -12,7 +12,6 @@ from ..objects import EvAdventureObject
class TestUtils(BaseEvenniaTest):
def test_get_obj_stats(self):
obj = create.create_object(
EvAdventureObject, key="testobj", attributes=(("desc", "A test object"),)
)

View file

@ -748,7 +748,6 @@ class TutorialEvMenu(EvMenu):
self.caller.account.execute_cmd("unquell")
def options_formatter(self, optionslist):
navigation_keys = ("next", "back", "back to start")
other = []