Skip to content

Commit

Permalink
move payload 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
onee-only committed Nov 28, 2024
1 parent 72670db commit 9eed6ed
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
5 changes: 3 additions & 2 deletions message/internal/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Generic, TypeVar
from message.payload import Payload, FetchTilesPayload, TilesPayload, PointingPayload
from message.payload import Payload, FetchTilesPayload, TilesPayload, PointingPayload, MovingPayload
from .exceptions import InvalidEventTypeException

import json
Expand All @@ -12,7 +12,8 @@
DECODABLE_PAYLOAD_DICT: dict[str, Payload] = {
"fetch-tiles": FetchTilesPayload,
"tiles": TilesPayload,
"pointing": PointingPayload
"pointing": PointingPayload,
"moving": MovingPayload
}


Expand Down
1 change: 1 addition & 0 deletions message/payload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .internal.new_conn_payload import NewConnPayload, NewConnEvent, NearbyCursorPayload, CursorPayload, CursorAppearedPayload, NewCursorPayload
from .internal.parsable_payload import ParsablePayload
from .internal.pointing_payload import PointerSetPayload, PointingResultPayload, PointingPayload, TryPointingPayload, PointEvent, ClickType
from .internal.move_payload import MoveEvent, MovingPayload, MovedPayload, CheckMovablePayload, MovableResultPayload
35 changes: 35 additions & 0 deletions message/payload/internal/move_payload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from board import Point
from cursor import Color
from dataclasses import dataclass
from .base_payload import Payload
from enum import Enum


class MoveEvent(str, Enum):
MOVING = "moving"
MOVED = "moved"
CHECK_MOVABLE = "check-movable"
MOVABLE_RESULT = "movable-result"


@dataclass
class MovingPayload(Payload):
position: Point


@dataclass
class MovedPayload(Payload):
origin_position: Point
new_position: Point
color: Color


@dataclass
class CheckMovablePayload(Payload):
position: Point


@dataclass
class MovableResultPayload(Payload):
position: Point
movable: bool

0 comments on commit 9eed6ed

Please sign in to comment.