Skip to content

Commit

Permalink
Merge pull request #85 from gamultong/hotfix-merge
Browse files Browse the repository at this point in the history
핫픽스 병합
  • Loading branch information
onee-only authored Dec 27, 2024
2 parents 5453d47 + 3a5a60f commit b5655f6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion board/event/handler/internal/board_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async def receive_try_pointing(message: Message[TryPointingPayload]):
await asyncio.gather(*publish_coroutines)
return

if tile.number is None:
if (not tile.is_mine) and (tile.number is None):
# 빈 칸. 주변 칸 모두 열기.
start_p, end_p, tiles = BoardHandler.open_tiles_cascade(pointer)
tiles.hide_info()
Expand Down
2 changes: 2 additions & 0 deletions board/event/handler/test/board_handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ async def test_try_pointing_pointable_not_interactable(self, mock: AsyncMock):

@patch("event.EventBroker.publish")
async def test_try_pointing_pointable_closed_general_click(self, mock: AsyncMock):
# TODO: 연쇄 개방에 대한 테스트케이스 추가

cursor_pos = Point(0, 0)
pointer = Point(1, 0)

Expand Down
11 changes: 6 additions & 5 deletions cursor/event/handler/internal/cursor_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ async def receive_movable_result(message: Message[MovableResultPayload]):

if len(original_watchings) > 0:
# 범위 벗어난 커서들 연관관계 해제
for watching in original_watchings:
in_view = cursor.check_in_view(watching.position)
for other_cursor in original_watchings:
in_view = cursor.check_in_view(other_cursor.position)
if not in_view:
CursorHandler.remove_watcher(watcher=cursor, watching=other_cursor)

Expand Down Expand Up @@ -290,10 +290,10 @@ async def receive_movable_result(message: Message[MovableResultPayload]):
publish_coroutines.append(EventBroker.publish(message))

# 범위 벗어나면 watcher 제거
for watcher in original_watchers:
in_view = watcher.check_in_view(cursor.position)
for other_cursor in original_watchers:
in_view = other_cursor.check_in_view(cursor.position)
if not in_view:
CursorHandler.remove_watcher(watcher=watcher, watching=cursor)
CursorHandler.remove_watcher(watcher=other_cursor, watching=cursor)

new_watchers = list(filter(lambda c: c.conn_id not in original_watcher_ids, watchers_new_pos))
if len(new_watchers) > 0:
Expand Down Expand Up @@ -390,6 +390,7 @@ async def receive_single_tile_opened(message: Message[SingleTileOpenedPayload]):
await asyncio.gather(*publish_coroutines)

@staticmethod
@EventBroker.add_receiver(InteractionEvent.TILES_OPENED)
async def receive_tiles_opened(message: Message[TilesOpenedPayload]):
start_p = message.payload.start_p
end_p = message.payload.end_p
Expand Down
27 changes: 27 additions & 0 deletions cursor/event/handler/test/cursor_event_handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,33 @@ async def test_receive_movable_result_c_left(self, mock: AsyncMock):
self.assertIn("A", c_watchings)
self.assertIn("B", c_watchings)

@patch("event.EventBroker.publish")
async def test_receive_movable_result_b_down(self, mock: AsyncMock):
"""
B가 한 칸 아래로 이동.
B의 뷰에서 A가 사라진다.
"""
original_position = self.cur_c.position
message = Message(
event=MoveEvent.MOVABLE_RESULT,
header={"receiver": self.cur_b.conn_id},
payload=MovableResultPayload(
movable=True,
position=Point(
x=self.cur_b.position.x,
y=self.cur_b.position.y - 1,
)
)
)

await CursorEventHandler.receive_movable_result(message)

mock.assert_not_called()

# watcher 관계 확인
c_watchings = CursorHandler.get_watching("C")
self.assertEqual(len(c_watchings), 0)


class CursorEventHandler_TileStateChanged_TestCase(unittest.IsolatedAsyncioTestCase):
def setUp(self):
Expand Down

0 comments on commit b5655f6

Please sign in to comment.