Esempio n. 1
0
def init():
        global saved_battles
        
        daemon.register_msg_handler(message.MSG_NET_GET_TOWER_INFO,     get_tower_info)
        daemon.register_msg_handler(message.MSG_NET_ENTER_TOWER,        enter_tower)
        daemon.register_msg_handler(message.MSG_NET_START_TOWER_BATTLE, start_tower_battle)
        daemon.register_msg_handler(message.MSG_NET_RESET_TOWER,        reset_tower)
        daemon.register_msg_handler(message.MSG_NET_AUTO_TOWER,         auto_tower)
        daemon.register_msg_handler(message.MSG_NET_AUTO_TOWER_END,     auto_tower_end)
        
        state.register_opt(message.MSG_NET_START_TOWER_BATTLE, [state_cfg.OPT_JOIN_BATTLE,])
        
        state.register_opt(message.MSG_NET_ENTER_TOWER, [state_cfg.OPT_MANUAL_TOWER,])
        state.register_opt(message.MSG_NET_RESET_TOWER, [state_cfg.OPT_MANUAL_TOWER,])
        
        state.register_opt(message.MSG_NET_AUTO_TOWER, [state_cfg.OPT_AUTO_TOWER,])
        
        #导出各层首杀信息
        for process in xrange(config.MAX_FLOOR_NUM):
                if not (process + 1) % 10:
                        for i in xrange(3):
                                save_key = "tower_" + str(process) + "_" + str(i)
                                
                                if not db_ins.gm_fdbm.has_key(save_key):
                                        break
                                
                                try:
                                        saved_battles[save_key] = common.my_decode(db_ins.gm_fdbm.read(save_key))
                                except:
                                        pass
Esempio n. 2
0
def init():
    global saved_battles

    daemon.register_msg_handler(message.MSG_NET_GET_TOWER_INFO, get_tower_info)
    daemon.register_msg_handler(message.MSG_NET_ENTER_TOWER, enter_tower)
    daemon.register_msg_handler(message.MSG_NET_START_TOWER_BATTLE,
                                start_tower_battle)
    daemon.register_msg_handler(message.MSG_NET_RESET_TOWER, reset_tower)
    daemon.register_msg_handler(message.MSG_NET_AUTO_TOWER, auto_tower)
    daemon.register_msg_handler(message.MSG_NET_AUTO_TOWER_END, auto_tower_end)

    state.register_opt(message.MSG_NET_START_TOWER_BATTLE, [
        state_cfg.OPT_JOIN_BATTLE,
    ])

    state.register_opt(message.MSG_NET_ENTER_TOWER, [
        state_cfg.OPT_MANUAL_TOWER,
    ])
    state.register_opt(message.MSG_NET_RESET_TOWER, [
        state_cfg.OPT_MANUAL_TOWER,
    ])

    state.register_opt(message.MSG_NET_AUTO_TOWER, [
        state_cfg.OPT_AUTO_TOWER,
    ])

    #导出各层首杀信息
    for process in xrange(config.MAX_FLOOR_NUM):
        if not (process + 1) % 10:
            for i in xrange(3):
                save_key = "tower_" + str(process) + "_" + str(i)

                if not db_ins.gm_fdbm.has_key(save_key):
                    break

                try:
                    saved_battles[save_key] = common.my_decode(
                        db_ins.gm_fdbm.read(save_key))
                except:
                    pass
Esempio n. 3
0
def init():
        #注册账户系统相关处理
        daemon.register_msg_handler(message.MSG_DB_UPDATE_USER_GLOBAL, db_handler.work_update_user_global)
        daemon.register_msg_handler(message.MSG_DB_UPDATE_USER_SUMMARY, db_handler.work_update_user_summary)
        
        #注册用户系统相关处理
        daemon.register_msg_handler(message.MSG_DB_INSERT_USER_CHARACTER, db_handler.work_insert_user_character)
        daemon.register_msg_handler(message.MSG_DB_UPDATE_CHARACTER_ATT, db_handler.work_update_character_att)
        
        #注册宠物系统相关处理
        daemon.register_msg_handler(message.MSG_DB_DELETE_PET, db_handler.work_delete_pet)
        
        #注册任务系统相关处理
        daemon.register_msg_handler(message.MSG_DB_DELETE_QUEST, db_handler.work_query_delete_quest)
        
        #注册竞技场系统相关处理
        daemon.register_msg_handler(message.MSG_DB_UPDATE_ARENA, db_handler.work_update_arena)
        daemon.register_msg_handler(message.MSG_DB_INSERT_ARENA, db_handler.work_insert_arena)
        daemon.register_msg_handler(message.MSG_DB_REMOVE_FROM_ARENA, db_handler.work_remove_from_arena)
        
        #注册装备系统相关处理
        daemon.register_msg_handler(message.MSG_DB_UPDATE_EQUIPS, db_handler.work_update_user_equips)
        daemon.register_msg_handler(message.MSG_DB_DEL_EQUIPS, db_handler.work_del_equips)
        
        #注册邮件系统相关处理
        daemon.register_msg_handler(message.MSG_DB_SAVE_MAILS, db_handler.work_update_mails)
        
        #注册用户数据接受处理
        daemon.register_msg_handler(message.MSG_DB_RECV_USER_DATA, db_handler.recv_user_data)
        
        #注册邮件数据接受处理
        daemon.register_msg_handler(message.MSG_DB_RECV_MAIL_DATA, db_handler.recv_mail_data)
        
        #注册国家数据接收处理
        daemon.register_msg_handler(message.MSG_DB_RECV_COUNTRY_DATA, db_handler.recv_country_data)
        
        #注册拍卖系统数据接收处理
        daemon.register_msg_handler(message.MSG_DB_ADD_AUCTION_DATA, db_handler.recv_auction_add_items)
        daemon.register_msg_handler(message.MSG_DB_DEl_AUCTION_DATA, db_handler.recv_auction_del_items)
        
        #注册交易系统数据接受处理
        daemon.register_msg_handler(message.MSG_DB_UPDATE_TRADE_DATA, db_handler.recv_trade_update_items)
        daemon.register_msg_handler(message.MSG_DB_DEL_TRADE_DATA, db_handler.recv_trade_del_items)
        
        #注册交易新手礼包接受处理
        daemon.register_msg_handler(message.MSG_DB_RECV_NEWBIE_GIFT_DATA, db_handler.recv_newbie_data)
        
        #注册充值数据接受处理
        daemon.register_msg_handler(message.MSG_DB_NEW_ORDER, db_handler.recv_new_order)
        daemon.register_msg_handler(message.MSG_DB_SETTLE_ORDER, db_handler.recv_settle_order)

        #联盟数据
        daemon.register_msg_handler(message.MSG_DB_UNION_UPDATE, db_handler.recv_union_update)
        daemon.register_msg_handler(message.MSG_DB_UNION_DELETE, db_handler.recv_union_delete)
        daemon.register_msg_handler(message.MSG_DB_UNION_USERINFO_UPDATE, db_handler.recv_union_userinfo_update)
        
        
        #活跃时间统计
        daemon.register_msg_handler(message.MSG_DB_LOGIN_TIME_UPDATE, db_handler.recv_login_time_update)
        
        def would_close_handler(hid, content):
                #向主游戏进程发送即将关闭确认的信息
                net_trans.direct_send_data(hid, json.dumps({"msg_id":message.MSG_DB_WOULD_CLOSE,"content":{}, "from":net_cfg.RECV_FROM_DATABASE}))
                
                daemon.signal_handle(10, None)
                
        daemon.register_msg_handler(message.MSG_DB_WOULD_CLOSE, would_close_handler)