mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Add ObjectParent mixin to default gamedir template
This commit is contained in:
parent
0cd57ad0ed
commit
919bf1a907
10 changed files with 32 additions and 16 deletions
|
|
@ -158,7 +158,8 @@ Up requirements to Django 4.0+, Twisted 22+, Python 3.9 or 3.10
|
|||
- Have `type/force` default to `update`-mode rather than `reset`mode and add more verbose
|
||||
warning when using reset mode.
|
||||
- Attribute storage support defaultdics (Hendher)
|
||||
- Add `is_ooc` lockfunc (meant for limiting commands at the OOC level)
|
||||
- Add ObjectParent mixin to default game folder template as an easy, ready-made
|
||||
way to override features on all ObjectDB-inheriting objects easily.
|
||||
|
||||
|
||||
## Evennia 0.9.5
|
||||
|
|
|
|||
|
|
@ -2969,7 +2969,7 @@ class CmdExamine(ObjManipCommand):
|
|||
# we are only interested in specific attributes
|
||||
attrs = [attr for attr in obj.db_attributes.all() if attr.db_key in obj_attrs]
|
||||
if not attrs:
|
||||
self.msg("No attributes found on {obj.name}.")
|
||||
self.msg(f"No attributes found on {obj.name}.")
|
||||
else:
|
||||
out_strings = []
|
||||
for attr in attrs:
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ class TestTraitGauge(_TraitHandlerBase):
|
|||
self.trait = self.traithandler.get("test1")
|
||||
|
||||
def _get_values(self):
|
||||
"""Get (base, mod, value, min, max)."""
|
||||
"""Get (base, mod, mult, value, min, max)."""
|
||||
return (self.trait.base, self.trait.mod, self.trait.mult, self.trait.value, self.trait.min, self.trait.max)
|
||||
|
||||
def test_init(self):
|
||||
|
|
@ -778,7 +778,7 @@ class TestTraitGauge(_TraitHandlerBase):
|
|||
self.trait.min = -10
|
||||
self.assertEqual(self._get_values(), (0, 2, 1.0, 2, -10, 2))
|
||||
del self.trait.min
|
||||
self.assertEqual(self._get_values(), (0, 2, 2, 0, 2))
|
||||
self.assertEqual(self._get_values(), (0, 2, 1.0, 2, 0, 2))
|
||||
|
||||
def test_percentage(self):
|
||||
"""Test percentage calculation"""
|
||||
|
|
@ -793,7 +793,7 @@ class TestTraitGauge(_TraitHandlerBase):
|
|||
def test_descs(self):
|
||||
"""Test descriptions"""
|
||||
self.trait.min = -5
|
||||
self.assertEqual(self._get_values(), (8, 2, 10, -5, 10))
|
||||
self.assertEqual(self._get_values(), (8, 2, 1.0, 10, -5, 10))
|
||||
self.trait.current = -2
|
||||
self.assertEqual(self.trait.desc(), "range0")
|
||||
self.trait.current = 0
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ several more options for customizing the Guest account system.
|
|||
|
||||
"""
|
||||
|
||||
from evennia import DefaultAccount, DefaultGuest
|
||||
from evennia.accounts.accounts import DefaultAccount, DefaultGuest
|
||||
|
||||
|
||||
class Account(DefaultAccount):
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ to be modified.
|
|||
|
||||
"""
|
||||
|
||||
from evennia import DefaultChannel
|
||||
from evennia.comms.comms import DefaultChannel
|
||||
|
||||
|
||||
class Channel(DefaultChannel):
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@ is setup to be the "default" character type created by the default
|
|||
creation commands.
|
||||
|
||||
"""
|
||||
from evennia import DefaultCharacter
|
||||
from evennia.objects.objects import DefaultCharacter
|
||||
from .objects import ObjectParent
|
||||
|
||||
|
||||
class Character(DefaultCharacter):
|
||||
class Character(DefaultCharacter, ObjectParent):
|
||||
"""
|
||||
The Character defaults to reimplementing some of base Object's hook methods with the
|
||||
following functionality:
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ 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.
|
||||
|
||||
"""
|
||||
from evennia import DefaultExit
|
||||
from evennia.objects.objects import DefaultExit
|
||||
from .objects import ObjectParent
|
||||
|
||||
|
||||
class Exit(DefaultExit):
|
||||
class Exit(DefaultExit, ObjectParent):
|
||||
"""
|
||||
Exits are connectors between rooms. Exits are normal Objects except
|
||||
they defines the `destination` property. It also does work in the
|
||||
|
|
|
|||
|
|
@ -10,10 +10,22 @@ the other types, you can do so by adding this as a multiple
|
|||
inheritance.
|
||||
|
||||
"""
|
||||
from evennia import DefaultObject
|
||||
from evennia.objects.objects import DefaultObject
|
||||
|
||||
|
||||
class Object(DefaultObject):
|
||||
class ObjectParent:
|
||||
"""
|
||||
This is a mixin that can be used to override *all* entities inheriting at
|
||||
some distance from DefaultObject (Objects, Exits, Characters and Rooms).
|
||||
|
||||
Just add any method that exists on `DefaultObject` to this class. If one
|
||||
of the derived classes has itself defined that same hook already, that will
|
||||
take precedence.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class Object(DefaultObject, ObjectParent):
|
||||
"""
|
||||
This is the root typeclass object, implementing an in-game Evennia
|
||||
game object, such as having a location, being able to be
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ Rooms are simple containers that has no location of their own.
|
|||
|
||||
"""
|
||||
|
||||
from evennia import DefaultRoom
|
||||
from evennia.objects.objects import DefaultRoom
|
||||
from .objects import ObjectParent
|
||||
|
||||
|
||||
class Room(DefaultRoom):
|
||||
class Room(DefaultRoom, ObjectParent):
|
||||
"""
|
||||
Rooms are like any Object, except their location is None
|
||||
(which is default). They also use basetype_setup() to
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ just overloads its hooks to have it perform its function.
|
|||
|
||||
"""
|
||||
|
||||
from evennia import DefaultScript
|
||||
from evennia.scripts.scripts import DefaultScript
|
||||
|
||||
|
||||
class Script(DefaultScript):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue