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
|
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.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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."""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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."""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue