예제 #1
0
def game_start(ro, data):
    '''
    麻将开局;
    :param ro:
    :param data:
    :return:
    '''
    print 'game_start:::::::::::'
    obj=Parser(data)
    zuang=obj.read_ubyte()
    pai=obj.read_string()
    sai=[]
    for i in range(6):
        sai.append(obj.read_ubyte())
    jin1=chr(obj.read_ubyte())
    jin2=chr(obj.read_ubyte())
    jin=[]
    for i in range(4):
        jin.append(obj.read_string())
    print u'庄:',zuang
    print u'牌:',pai
    print u'骰子:',sai
    print u'上精:',jin1
    print u'下精:',jin2
    print u'下精分布:',jin
    yield msg_notify(ro,'game_start',zuang,pai,sai,jin1,jin2,jin)
예제 #2
0
def auth_login(ro, data):
    '''
    用户登录
    :param ro:连接
    :param data:客户端数据包
    :return:
    '''
    print 'auth_login:::::::::::'
    obj=Parser(data)
    sign=obj.read_short()
    if sign==1:
        print u'login successed!'
        avatar=obj.read_ushort()
        yield msg_notify(ro,'login_success',avatar)
    else:
        yield msg_notify(ro,'login_failed')
        print u'login failed!', obj.read_string()
    yield
예제 #3
0
def player_drop(ro, data):
    '''
    玩家出牌广播;
    :param ro:
    :param data:
    :return:
    '''
    obj=Parser(data)
    tableid=obj.read_ubyte()
    pai=chr(obj.read_ubyte())
    print 'player_drop:::::::::::', tableid, PAI_NAME(pai)
    yield msg_notify(ro,'player_drop',tableid,pai)
예제 #4
0
def zua_pai(ro, data):
    '''
    抓牌;
    :param ro:
    :param data:
    :return:
    '''
    obj=Parser(data)
    pai=chr(obj.read_ubyte())
    tableid=obj.read_ubyte()
    print 'zua_pai:::::::::::', tableid, PAI_NAME(pai)
    yield msg_notify(ro,'zua_pai',tableid,pai)
예제 #5
0
def list_rooms(ro, data):
    '''
    获取大厅房间列表;
    :param ro:
    :param data:
    :return:
    '''
    print 'list_rooms:::::::::::'
    obj=Parser(data)
    sign=obj.read_short()
    if sign==1:
        print u'lobby enter!'
        dat=obj.read_string()
        print dat
        yield msg_notify(ro,'lobby_enter')
    yield
예제 #6
0
def user_register(ro, data):
    '''
    玩家注册
    :param ro:连接
    :param data:客户端数据包
    :return:
    '''
    print 'user_register:::::::::::'
    obj=Parser(data)
    sign=obj.read_short()
    if sign==1:
        print u'register successed!'
        yield msg_notify(ro,'register_success')
    else:
        print u'register failed!', obj.read_string()
    yield
예제 #7
0
def hu_pai(ro, data):
    '''
    胡牌
    :return:
    '''
    print u"hu_pai:"
    obj=Parser(data)
    tableid=obj.read_ubyte()
    str1=obj.read_string()
    pai=obj.read_ubyte()
    int1=obj.read_short()
    int2=obj.read_short()
    int3=obj.read_short()
    int4=obj.read_short()
    flag=obj.read_string()
    yield msg_notify(ro,'hu_pai',tableid,pai)
예제 #8
0
def enter_room(ro, data):
    '''
    加入游戏房间;
    :param ro:
    :param data:
    :return:
    '''
    print 'enter_room:::::::::::'
    obj=Parser(data)
    sign=obj.read_short()
    if sign==1:
        roomid=obj.read_ushort()
        tableid=obj.read_ubyte()
        print u'room enter!', roomid,  tableid
        yield msg_notify(ro,'room_enter',roomid,tableid)
    else:
        print u'room enter failed!', obj.read_string()
    yield
예제 #9
0
파일: client.py 프로젝트: TTXDM/firstGame
 def connectionLost(self, reason):
     logging.getLogger('sock').info(u'disconnected:'+str(self.transport.getPeer()))
     from packet import msg_notify
     msg_notify(self,'connectionLost')