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:
Jared Miller 2026-02-14 01:20:40 -05:00
parent a98f340e5a
commit 5a0c1b2151
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
6 changed files with 8 additions and 8 deletions

View file

@ -8,7 +8,7 @@ from mudlib.object import Object
from mudlib.thing import Thing from mudlib.thing import Thing
@dataclass @dataclass(eq=False)
class Container(Thing): class Container(Thing):
"""A container that can hold other items. """A container that can hold other items.

View file

@ -7,7 +7,7 @@ from dataclasses import dataclass, field
from mudlib.object import Object from mudlib.object import Object
@dataclass @dataclass(eq=False)
class Entity(Object): class Entity(Object):
"""Base class for anything with position and identity in the world. """Base class for anything with position and identity in the world.
@ -68,7 +68,7 @@ class Entity(Object):
pass pass
@dataclass @dataclass(eq=False)
class Mob(Entity): class Mob(Entity):
"""Represents a non-player character (NPC) in the world.""" """Represents a non-player character (NPC) in the world."""

View file

@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable
from dataclasses import dataclass, field from dataclasses import dataclass, field
@dataclass @dataclass(eq=False)
class Object: class Object:
"""Base class for everything in the world. """Base class for everything in the world.

View file

@ -17,7 +17,7 @@ if TYPE_CHECKING:
from mudlib.if_session import IFSession from mudlib.if_session import IFSession
@dataclass @dataclass(eq=False)
class Player(Entity): class Player(Entity):
"""Represents a connected player.""" """Represents a connected player."""

View file

@ -7,7 +7,7 @@ from dataclasses import dataclass, field
from mudlib.object import Object from mudlib.object import Object
@dataclass @dataclass(eq=False)
class Thing(Object): class Thing(Object):
"""An item in the world. """An item in the world.

View file

@ -8,7 +8,7 @@ from dataclasses import dataclass, field
from mudlib.object import Object from mudlib.object import Object
@dataclass @dataclass(eq=False)
class SpawnRule: class SpawnRule:
"""Configuration for spawning mobs in a zone. """Configuration for spawning mobs in a zone.
@ -21,7 +21,7 @@ class SpawnRule:
respawn_seconds: int = 300 respawn_seconds: int = 300
@dataclass @dataclass(eq=False)
class Zone(Object): class Zone(Object):
"""A spatial area with a grid of terrain tiles. """A spatial area with a grid of terrain tiles.