Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 459-feat-1vs1-모드-전적-상…
Browse files Browse the repository at this point in the history
…세-페이지에서-승자-표시
  • Loading branch information
nyj001012 committed Mar 11, 2024
2 parents de37616 + 81562a3 commit 94412a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
24 changes: 12 additions & 12 deletions backend/games/consumers/GameConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ async def _send_end_message(self, match: Result):
'data': data
}
)
await self.game_end({
'type': type_,
'data': data
})
# await self.game_end({
# 'type': type_,
# 'data': data
# })

async def _send_start_message(self, match, group_name):
data = {
Expand Down Expand Up @@ -409,10 +409,10 @@ async def _send_start_message(self, match, group_name):
'data': data
}
)
await self.game_start({
'type': 'game_start',
'data': data
})
# await self.game_start({
# 'type': 'game_start',
# 'data': data
# })

async def _send_in_game_message(self, match, group_name):
data = {
Expand All @@ -438,10 +438,10 @@ async def _send_in_game_message(self, match, group_name):
'data': data
}
)
await self.in_game({
'type': 'in_game',
'data': data
})
# await self.in_game({
# 'type': 'in_game',
# 'data': data
# })

async def game_info(self, event):
try:
Expand Down
24 changes: 15 additions & 9 deletions backend/games/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,25 @@ class Meta:
fields = ['match1', 'match2', 'match3']

def get_match1(self, game):
return MatchSerializer(game.match1).data
if game.match1 is not None and game.match1.player1 is not None and game.match1.player2 is not None:
return MatchSerializer(game.match1).data
return None

def get_match2(self, game):
return MatchSerializer(game.match2).data
if game.match2 is not None and game.match2.player1 is not None and game.match2.player2 is not None:
return MatchSerializer(game.match2).data
return None

def get_match3(self, game):
data = MatchSerializer(game.match3).data
if game.match3.winner is None:
data['winner'] = None
else:
data['winner'] = game.match3.winner.nickname
data['date'] = game.started_at
return data
if game.match3 is not None and game.match3.player1 is not None and game.match3.player2 is not None:
data = MatchSerializer(game.match3).data
if game.match3.winner is None:
data['winner'] = None
else:
data['winner'] = game.match3.winner.nickname
data['date'] = game.started_at
return data
return None


class PvPMatchSerializer(serializers.ModelSerializer):
Expand Down

0 comments on commit 94412a5

Please sign in to comment.