Skip to content

Commit

Permalink
fix: missed deep copies
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Aug 26, 2023
1 parent f24a7e9 commit 8e21b7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/card/equipment/artifact/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_actions(
) -> List[MoveObjectAction | RemoveObjectAction]:
"""
Act the artifact. will place it into artifact area.
TODO: when artifact is equipped, remove the old one.
When artifact is equipped, remove the old one.
"""
assert target is not None
ret: List[MoveObjectAction | RemoveObjectAction] = []
Expand All @@ -63,6 +63,6 @@ def get_actions(
ret.append(MoveObjectAction(
object_position = self.position,
object_id = self.id,
target_position = position.copy(),
target_position = position.copy(deep = True),
))
return ret
6 changes: 5 additions & 1 deletion server/modifiable_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class ModifiableValueBase(BaseModel):
def __init__(self, *argv, **kwargs):
super().__init__(*argv, **kwargs)
self.original_value = None
self.original_value = self.copy()
# set match to None to avoid deepcopy
match = self.match
self.match = None
self.original_value = self.copy(deep = True)
self.original_value.match = self.match = match


class InitialDiceColorValue(ModifiableValueBase):
Expand Down

0 comments on commit 8e21b7f

Please sign in to comment.