Exemplo n.º 1
0
def getItemsInEquipSlotNew(dynamicId, characterId):
    '''获取角色的装备栏信息
    @param dynamicId: int 客户端的id
    @param characterId: int 角色的id
    '''
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result': False, 'message': ""}
    equipmentList = player.pack.getEquipmentSlotItemList()
    keys_copy = dict(equipmentList)
    equipmentList_copy = []
    for position in range(0, 8):
        item = keys_copy.get(position, None)
        if item:
            _item = {}
            _item['id'] = item.baseInfo.id
            _item['strengthen'] = dbItems.getItem(
                characterId, item.baseInfo.id)[0]['strengthen']
            _item['tempid'] = item.baseInfo.getItemTemplateId()
            #_item['pos'] = position
            #_item['item'] = _item
            #_item['stacks'] = item.pack.getStack
            iteminfo = {'pos': position, 'item': _item}
            equipmentList_copy.append(iteminfo)
    #playerInfo = player.formatInfoForWeiXin()
    #data = {}
    #data['equip'] = equipmentList_copy
    #data['attack'] = playerInfo['attack']
    #data['fangyu'] = playerInfo['fangyu']
    #data['blood'] = playerInfo['blood']
    return {'result': True, 'message': u'', 'data': equipmentList_copy}
Exemplo n.º 2
0
def qianghua(dynamicId, characterId, itemId):
    '''获取包裹的信息
    '''
    player = PlayerCharacter(characterId, dynamicId=dynamicId)
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result': False, 'message': ""}
    playerinfo = player.formatInfo()
    data = dbItems.getItem(characterId, itemId)
    level = data[0]
    weaponlevel1 = level["strengthen"]
    playerlvl = playerinfo['level']
    if weaponlevel1 > playerlvl * 2:
        result = {'resutl': False, "message": "level limited"}
        return result

    stonedata = dbItems.getItem(characterId, 60001)
    stonenums = stonedata[0]
    stonenum = stonenums["stack"]
    Maxqianghualevel = int(int(playerinfo['viplevel']) / 2)

    stonecost = int(weaponlevel1 * 2)
    if (stonenum - stonecost) < 0:
        result = {'resutl': False, "message": "no enough stone"}
        return result

    b2 = math.pow(1.07, weaponlevel1)
    need = int(b2 * (weaponlevel1 * 70 + 40))

    money = player.finance.getCoin()
    if money < need:
        result = {'resutl': False, "message": "no enough coin"}
        return result

    levelup = random.randint(1, Maxqianghualevel)
    count = weaponlevel1 + levelup
    data = player.pack.qianghua(itemId, count, characterId)

    result = {'resutl': True, "message": "success", "data": levelup}
    if data:
        stonenum = stonenum - stonecost
        dbItems.setStack(stonenum, characterId, 60001)
        player.finance.addCoin(-need)

        return result
Exemplo n.º 3
0
def GetNewItem(dynamicId, characterId, list):
    '''
    获得物品
    '''
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result': False, 'message': ""}
    plist = player.pack.getPackageItemList()['data']['itemlist']
    print list
    print plist
    length = len(list)
    length2 = len(plist)
    print(length, length2)
    print list[1]['itemid']
    print plist[1]['tempid']
    needdel = []
    for i in range(0, length):
        for j in range(0, length2):
            if list[i]['itemid'] == plist[j]['tempid']:
                s = dbItems.getItem(characterId,
                                    plist[j]['itemid'])[0]['stack'] + 1
                dbItems.setStack(s, plist[j]['itemid'], characterId)
                needdel.append(i)
                print('same', i)
                print needdel
    if needdel:
        lendel = len(needdel)
        needdel.reverse()
        for i in range(0, lendel):
            print('i', i)
            a = needdel[i]
            print('a', a)
            del list[a]

    print('needdel', needdel)
    print('left', list)

    newlength = len(list)
    for i in range(0, newlength):
        data = {
            'characterId': characterId,
            'itemTemplateId': list[i]['itemid'],
            'isBound': 0,
            'accesstime': datetime.datetime.now(),
            'durability': 0,
            'stack': 1,
            'strengthen': 0,
            'workout': 0,
            'slot_1': 0,
            'slot_2': 0,
            'slot_3': 0,
            'slot_4': 0,
            'exp': 0
        }
        newitemmode = tbitemadmin.new(data)
        itemId = int(newitemmode._name.split(':')[1])
        print itemId
    def getWeaponList(self, characterId):
        '''获取包裹的武器信息
        '''

        data = {}
        itemList = self._package._items.values()
        equipidlist = self._equipmentSlot._items.values()
        data['itemlist'] = [{'itemid':itemInfo.baseInfo.id,
                             'tempid':itemInfo.baseInfo.getItemTemplateId(),
                             'stack':itemInfo.pack.getStack(),
                             'strengthen':dbItems.getItem(characterId,itemInfo.baseInfo.id)[0]['strengthen']
                            }\
                             for itemInfo in itemList \
                             if  itemInfo.baseInfo.getItemTemplateId() > 2000 and itemInfo.baseInfo.getItemTemplateId() < 3000]
        data.update({'Num': len(data['itemlist'])})
        return {'result': True, 'data': data}
Exemplo n.º 5
0
def RewardCleanOut(dynamicId, characterId, orders):
    '''奖励发放'''

    player = PlayersManager().getPlayerBydynamicId(dynamicId)
    if dynamicId != player.getDynamicId():
        return {'result': False, 'message': ""}
    if 'Coin' in orders:
        coinadd = orders['Coin']
        player.finance.addCoin(coinadd)
    if 'Gold' in orders:
        goldadd = orders['Gold']
        player.finance.addGold(goldadd)
        print 1
    if 'stone' in orders:
        stoneadd = orders['stone']
        newstone = dbItems.getItem(characterId, 60001)[0]['stack']
        newstone += stoneadd
        result2 = dbItems.setStack(newstone, characterId, 60001)
Exemplo n.º 6
0
def getWeaponInEquipSlotNew(dynamicId, characterId):
    '''获取角色的装备武器信息
    @param dynamicId: int 客户端的id
    @param characterId: int 角色的id
    '''
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result': False, 'message': ""}
    equipmentList = player.pack.getEquipmentSlotItemList()
    keys_copy = dict(equipmentList)
    position = 0
    item = keys_copy.get(position, None)
    if item:
        _item = {}
        _item['id'] = item.baseInfo.id
        _item['strengthen'] = dbItems.getItem(
            characterId, item.baseInfo.id)[0]['strengthen']
        _item['tempid'] = item.baseInfo.getItemTemplateId()
        iteminfo = {'item': _item}
    return {'wearing': iteminfo}
Exemplo n.º 7
0
def SignReward3715(dynamicId, characterId):
    '''签到
    '''
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result': False, 'message': u""}
    delta = datetime.datetime.now()
    data = dbCharacter.getlastsignByCharacterId(characterId)
    lastsign = data["lastsignday"]
    times = data["signtimes"]
    if lastsign < delta.day:
        times += 1
        addcoin = player.finance.addCoin(10000)
        newstone = dbItems.getItem(characterId, 60001)[0]['stack']
        nums = newstone + 5
        result = dbItems.setStack(nums, characterId, 60001)
        dbCharacter.sign1(characterId, delta.day)
        dbCharacter.signtimes(characterId, times)
        print {"message": result, 'data': {"signtimes": times}}
        return {"message": result, 'data': {"signtimes": times}}
    return {"message": 'got', 'data': {"signtimes": times}}
Exemplo n.º 8
0
def getReward3711(dynamicId, characterId):
    '''签到奖励
    '''
    player = PlayerCharacter(characterId, dynamicId=dynamicId)
    #player.updatePlayerDBInfo
    dat = dbCharacter.getreward(characterId)
    data = dat[0]
    i1 = int(data / 1000)
    i2 = int((data - i1 * 1000) / 100)
    i3 = int((data - i2 * 100 - i1 * 1000) / 10)
    i4 = int(data - i2 * 100 - i1 * 1000 - i3 * 10)
    signtimes = dbCharacter.getlastsignByCharacterId(characterId)['signtimes']
    result11 = False
    result2 = False
    result3 = False
    result4 = False

    if i1 == 1 and signtimes > 2:
        addcoin = player.finance.addCoin(50000)
        addgold = player.finance.addGold(10)
        player.updatePlayerDBInfo()
        print(addcoin, addgold)
        newstone = dbItems.getItem(characterId, 60001)[0]['stack']
        nums = newstone + 5
        result11 = dbItems.setStack(nums, characterId, 60001)
        i1 += 1

    if i2 == 1 and signtimes > 6:
        i2 += 1
        player.finance.addCoin(80000)
        player.finance.addGold(30)
        newstone = dbItems.getItem(characterId, 60001)[0]['stack']
        newstone += 20
        result2 = dbItems.setStack(newstone, characterId, 60001)
    if i3 == 1 and signtimes > 14:
        i3 += 1
        player.finance.addCoin(200000)
        player.finance.addGold(60)
        newstone = dbItems.getItem(characterId, 60001)[0]['stack']
        newstone += 80
        result3 = dbItems.setStack(newstone, characterId, 60001)

    if i4 == 1 and signtimes > 24:
        i4 += 1
        player.finance.addCoin(300000)
        player.finance.addGold(100)
        newstone = dbItems.getItem(characterId, 60001)[0]['stack']
        newstone += 150
        result4 = dbItems.setStack(newstone, characterId, 60001)

    newdata = i1 * 1000 + i2 * 100 + i3 * 10 + i4
    genxin = dbCharacter.updatePlayerDB(player)
    result1 = dbCharacter.setget(characterId, newdata)
    print {
        "message": {
            '3': result11,
            '7': result2,
            '15': result3,
            '25': result4
        }
    }
    return {
        "message": {
            '3': result11,
            '7': result2,
            '15': result3,
            '25': result4
        }
    }