示例#1
0
    async def call_message(self, event):
        user_id = event['sender_id']
        nickname = get_user_nickname(user_id)

        msg = f'{nickname}이 올린 금액을 승낙했습니다.'
        msg_obj = ClientMessage('CALL', msg)
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#2
0
    async def die_message(self, event):
        user_id = event['sender_id']
        nickname = get_user_nickname(user_id)

        msg = f'{nickname}이 포기했습니다.'
        msg_obj = ClientMessage('DIE', msg)
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#3
0
    async def check_message(self, event):
        user_id = event['sender_id']

        nickname = get_user_nickname(user_id)
        msg = f'{nickname}님이 check했습니다.'
        msg_obj = ClientMessage('CHECK', msg)
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#4
0
 async def turn_message(self, event):
     next_user = event['sender_id']
     nickname = get_user_nickname(next_user)
     msg = f'{nickname}님 차례입니다.'
     msg_obj = ClientMessage('ORDER', msg)
     msg_obj.this_turn = next_user
     await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#5
0
    async def ready_message(self, event):
        user_id = event['sender_id']

        nickname = get_user_nickname(user_id)
        msg = f'{nickname}님이 레디를 눌렀습니다.'
        msg_obj = ClientMessage('READY', msg)
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#6
0
    async def bet_message(self, event):
        user_id = event['sender_id']
        bet = event['bet']

        nickname = get_user_nickname(user_id)
        msg = f'{nickname}이 {bet}만큼 베팅 금액을 올렸습니다. .'
        msg_obj = ClientMessage('BET', msg)
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#7
0
    async def enter_message(self, event):
        nickname = get_user_nickname(event['sender_id'])

        msg = f'{nickname}님이 입장하셨습니다'
        msg_obj = ClientMessage('ENTER', msg)

        # send message to websocket
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#8
0
    async def round_message(self, event):
        this_round = event['round']

        if this_round < 10:
            msg = f'{this_round}라운드 입니다.'
        else:
            msg = '마지막 라운드입니다.'

        msg_obj = ClientMessage('ROUND', msg)
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#9
0
    async def exit_message(self, event):

        user_id = event['sender_id']
        room_id = event['room_id']
        nickname = get_user_nickname(user_id)

        # leave room group
        await self.channel_layer.group_discard(user_id, self.channel_name)
        await self.channel_layer.group_discard(room_id, self.channel_name)

        msg = f'{nickname}님이 퇴장하셨습니다'
        msg_obj = ClientMessage('EXIT', msg)
        await self.send_message(msg_obj.to_json(), msg_obj.type)

        await self.close()
示例#10
0
    async def choice_message(self, event):
        next_user = event['next_user']
        opponent_card = event['opponent_card']
        this_round = event['round']

        nickname = get_user_nickname(next_user)
        msg = f'{nickname}님 선택해주세요'
        msg_obj = ClientMessage('GAME', msg)
        msg_obj.this_round = this_round
        msg_obj.my_point = get_user_point(next_user)
        msg_obj.set_card_info(me=next_user, opponent_card=opponent_card)
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#11
0
    async def result_message(self, event):
        winner = event['winner']
        loser = event['loser']
        my_card = event['my_card']
        opponent_card = event['opponent_card']
        my_point = event['my_point']

        msg = '라운드가 끝났습니다. 결과를 확인해주세요'
        msg_obj = ClientMessage('RESULT', msg)
        msg_obj.set_result(winner, loser, my_card, opponent_card)
        msg_obj.my_point = my_point
        await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#12
0
 async def tie_message(self, event):
     card = event['card']
     msg = '무승부입니다.'
     msg_obj = ClientMessage('TIE', msg)
     msg_obj.set_result('TIE', 'TIE', card, card)
     await self.send_message(msg_obj.to_json(), msg_obj.type)
示例#13
0
 async def start_message(self, event):
     msg2 = '5초 후에 게임이 시작됩니다.'
     msg_obj2 = ClientMessage('START', msg2)
     await self.send_message(msg_obj2.to_json(), msg_obj2.type)