Skip to content

Commit

Permalink
refactor(games): Consumer에서 PingPongGame 필드 할당 데이터 타입 변경
Browse files Browse the repository at this point in the history
- PingPongMap 대신 namedtuple 사용
  • Loading branch information
nyj001012 committed Mar 11, 2024
1 parent 2fc1c1b commit 488d5a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/games/consumers/GameConsumer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
from collections import namedtuple

import autobahn
import json
import logging
Expand All @@ -8,7 +10,7 @@
from channels.db import database_sync_to_async
from channels.generic.websocket import AsyncWebsocketConsumer
from django.contrib.auth.models import AnonymousUser
from games.models import Game, PingPongGame, PingPongMap, Result
from games.models import Game, PingPongGame, Result
from games.serializers import PvPMatchSerializer, TournamentMatchSerializer, TournamentFinalMatchSerializer
from src.choices import MODE_CHOICES_DICT, GAME_SETTINGS_DICT
from users.models import User
Expand Down Expand Up @@ -388,7 +390,7 @@ def _init_game(self, message_data, match):
map_width = message_data['map_width']
map_height = message_data['map_height']

self.ping_pong_map = PingPongMap(map_width, map_height)
self.ping_pong_map = namedtuple('Map', ['width', 'height'])(map_width, map_height)

if match == 1:
self.match1 = PingPongGame(self.ping_pong_map, self.game.match1.player1, self.game.match1.player2)
Expand Down

0 comments on commit 488d5a8

Please sign in to comment.