Fix dataclass equality causing duplicate items in move_to
Objects were comparing by value instead of identity, causing list.remove() to remove the wrong object when moving items with identical attributes. Set eq=False on all dataclasses to use identity-based comparison.
This commit is contained in:
parent
a98f340e5a
commit
5a0c1b2151
6 changed files with 8 additions and 8 deletions
|
|
@ -8,7 +8,7 @@ from mudlib.object import Object
|
|||
from mudlib.thing import Thing
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class Container(Thing):
|
||||
"""A container that can hold other items.
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from dataclasses import dataclass, field
|
|||
from mudlib.object import Object
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class Entity(Object):
|
||||
"""Base class for anything with position and identity in the world.
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ class Entity(Object):
|
|||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class Mob(Entity):
|
||||
"""Represents a non-player character (NPC) in the world."""
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable
|
|||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class Object:
|
||||
"""Base class for everything in the world.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ if TYPE_CHECKING:
|
|||
from mudlib.if_session import IFSession
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class Player(Entity):
|
||||
"""Represents a connected player."""
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from dataclasses import dataclass, field
|
|||
from mudlib.object import Object
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class Thing(Object):
|
||||
"""An item in the world.
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from dataclasses import dataclass, field
|
|||
from mudlib.object import Object
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class SpawnRule:
|
||||
"""Configuration for spawning mobs in a zone.
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class SpawnRule:
|
|||
respawn_seconds: int = 300
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(eq=False)
|
||||
class Zone(Object):
|
||||
"""A spatial area with a grid of terrain tiles.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue