Esempio n. 1
0
    def post(self):
        bodyData = self.request.body
        dictData = MessageTools.decode(bodyData)
        udid = dictData['udid']
        name = dictData['name']
        cdkey = dictData.get('cdkey', '')
        returnData = MessData()
        player = None
        open_activate = True

        # 账户验证
        name = name.strip()
        contains = name.find(';') >= 0 or name.find(' ') > 0 or len(name) == 0
        charCount = len(name)
        max_length = gloabalBase.getValue('MAX_LENGTH_OF_NAME')
        max_length = int(max_length)

        # 长度验证
        if contains or charCount > max_length:
            returnData = MessData(ErrorCode.name_illegal)

        # 非法字符验证
        elif illegalWordManager.ContainIllegalWord(name):
            returnData = MessData(ErrorCode.name_illegal)

        # 是否已被使用验证
        elif not playerDataManager.isSign(udid):
            if playerDataManager.isNameUsed(name):
                returnData = MessData(ErrorCode.name_used)
            else:
                playerDataManager.createAccount(udid,name)
                player = playerDataManager.loginUseUidd(udid)
                player.connect_id = playerDataManager.create_connect_id(player.player_id)       # 重新生成连接ID
                player.revial = 1
                returnData.data = player
                player.server_date_time = GameTools.getDateTimeNowString()

        # 通过
        else:
            player = playerDataManager.loginUseUidd(udid)
            player.server_date_time = GameTools.getDateTimeNowString()
            player.connect_id = playerDataManager.create_connect_id(player.player_id)       # 重新生成连接ID
            returnData.data = player
            player.calculateOfflineResource()

        message = MessageTools.encode(returnData,False)

        if player != None:                          # 重置离线奖励
            player.offlineCash = 0

            # 使用cdkey
            if open_activate is True:
                cdkey_obj.is_use = True
                cdkey_obj.usedtime = datetime.datetime.now()
                cdkey_obj.use_udid = udid
                cdkey_obj.save()

        self.write(message)
        self.finish()
Esempio n. 2
0
    for i in range(2):
        udid += random.choice('abcdefghkmnpqrstuvwxyz')

    for i in range(6):
        udid += random.choice('0123456789')

    name = ''
    for i in range(2):
        name += random.choice(namelist)

    if random.choice([True, False]):
        if random.choice([True, False]):
            name += '.'
        name += random.choice('ABCDEFGHIJKLMOPQRSTUVWXYZ')

    if not playerDataManager.isSign(udid):
        if playerDataManager.isNameUsed(name):
            continue
        else:
            playerDataManager.createAccount(udid,name)
            player = playerDataManager.loginUseUidd(udid)
            player.server_date_time = GameTools.getDateTimeNowString()

        player.cash = 10000000
        player.skillUpgrade(0,static.pvp_level_limit)
        player.saveData2DB()
        rankManager.addRank(player.player_id)
    else:
        continue

    count -= 1