def addItem(self, itemId, characterId, coinnum, cointype, addtime, stack):
        '''添加寄卖物品
        @param itemId: int 物品id (tb_item主键)
        @param characterId: int 寄卖人角色id
        @param coinnum: int 物品货币数量
        @param cointype: int 物品货币类型
        @param addtime: int 寄售多少小时
        @param stack: int 物品层叠数
        '''
        player = PlayersManager().getPlayerByID(characterId)
        if not player:
            return {'result': False, 'message': Lg().g(199)}
        ks = stack * 10  #寄卖物品应缴纳的手续费(金币)
        if player.finance.getCoin() < ks:
            return {'result': False, 'message': Lg().g(512)}
        else:
            player.finance.updateCoin(player.finance.getCoin() -
                                      ks)  #扣除寄卖人的手续费

        packone = player.pack._package.getWholePagePack()  #获取角色的全部物品包裹
        position = packone.getPositionByItemId(itemId)  #物品在包裹中的位置
        if position == -1:
            return {'result': False, 'message': Lg().g(513)}
        result1 = player.pack.dropItem(position, 3, stack, tag=0)  #删除物品
        if not result1.get('result', False):
            #print'添加寄卖物品时没有删除物品'
            return {'result': False, 'message': result1.get('message', False)}
        result = dbconsignment.addItem(itemId, characterId, coinnum, cointype,
                                       addtime, stack)
        if not result:
            return {'result': False, 'message': Lg().g(514)}
        pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
        return {'result': True, 'message': u'寄卖成功'}
    def addItem(self,itemId,characterId,coinnum,cointype,addtime,stack):
        '''添加寄卖物品
        @param itemId: int 物品id (tb_item主键)
        @param characterId: int 寄卖人角色id
        @param coinnum: int 物品货币数量
        @param cointype: int 物品货币类型
        @param addtime: int 寄售多少小时
        @param stack: int 物品层叠数
        '''
        player=PlayersManager().getPlayerByID(characterId)
        if not player:
            return{'result':False,'message':Lg().g(199)}
        ks=stack*10 #寄卖物品应缴纳的手续费(金币)
        if player.finance.getCoin()<ks:
            return{'result':False,'message':Lg().g(512)}
        else:
            player.finance.updateCoin(player.finance.getCoin()-ks) #扣除寄卖人的手续费

        packone=player.pack._package.getWholePagePack() #获取角色的全部物品包裹
        position = packone.getPositionByItemId(itemId) #物品在包裹中的位置
        if position==-1:
            return {'result':False ,'message':Lg().g(513)}
        result1 = player.pack.dropItem(position,3,stack,tag = 0) #删除物品 
        if not result1.get('result',False):
            #print'添加寄卖物品时没有删除物品'
            return {'result':False ,'message':result1.get('message',False)}
        result=dbconsignment.addItem(itemId, characterId, coinnum, cointype, addtime, stack)
        if not result:
            return {'result':False ,'message':Lg().g(514)}
        pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
        return {'result':True ,'message':u'寄卖成功'}
 def buyGold(self,characterid,id):
     '''购买寄卖货币
     @param characterid: 购买人id
     @param id: 货币寄卖表主键id
     '''
     item=dbconsignment.getOneGold(id)
     player=PlayersManager().getPlayerByID(characterid)
     if not player:
         return{'result':False,'message':Lg().g(199)}
     buymoney=item.get('buymoney',0)#换取的货币数量
     buytype=item.get('buytype',1)#换取的货币种类    1钻 2金币
     
     if buytype==1:
         if player.finance.getGold()<buymoney:
             return{'result':False,'message':u'您钻不足,无法购买。'}
     elif buytype==2:
         if player.finance.getCoin()<buymoney:
             return{'result':False,'message':u'您金币不足,无法购买。'}
                 
     result=dbconsignment.buyGold(characterid, id,item)
     if result:
         pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
         return{'result':True,'message':Lg().g(193)}
     else:
         return{'result':False,'message':Lg().g(470)}
    def addGold(self, salemoney, saletype, buymoney, buytype, adtime,
                characterid):
        '''添加寄卖金币
        @param salemoney: int 寄卖者出售货币数量
        @param saletype: int 寄卖者出售货币类型 1钻 2金币
        @param buymoney: int 购买货币数量
        @param buytype: int 购买货币类型  1钻 2金币
        @param adtime: int 寄售的小时数
        @param characterid: int 寄卖者的id
        '''
        player = PlayersManager().getPlayerByID(characterid)
        if not player:
            return {'result': False, 'message': Lg().g(199)}

        if saletype == 1:
            if salemoney > player.finance.getGold():
                return {'result': False, 'message': u'钻不足'}
            player.finance.updateGold(player.finance.getGold() - salemoney)
        if saletype == 2:
            if salemoney > player.finance.getCoin():
                return {'result': False, 'message': Lg().g(88)}
            player.finance.updateCoin(player.finance.getCoin() - salemoney)
        result = dbconsignment.addGold(salemoney, saletype, buymoney, buytype,
                                       adtime, characterid)
        if not result:
            return {'result': False, 'message': u'添加寄卖表失败'}
        pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
        return {'result': False, 'message': u'添加寄卖成功'}
    def buyItem(self, characterid, id):
        '''购买寄卖物品
        @param characterid: int 购买者的角色id
        @param id: int 物品寄卖表的主键id
        '''
        item = dbconsignment.getItemByoneid(id)  #获取寄卖物品信息
        if not item:
            return {'result': False, 'message': u'该物品已下架', 'data': None}
        tocharacterid = item.get('characterid', 0)  #寄卖物品的角色id
        itemid = item.get('itemid', 0)  #tb_item中的主键id
        buymoney = item.get('coinnum', 0)  #购买物品需要的货币数量
        if buymoney == 0:
            return {'result': False, 'message': u'价格不能为0', 'data': None}
        buytype = item.get('cointype', 0)  #购买物品需要的货币类型  1钻 2金币
        if buytype == 1:
            buytype == 2
        elif buytype == 2:
            buytype == 1
        counts = item.get('count', 0)  #购买的数量
        player = PlayersManager().getPlayerByID(characterid)
        if not player:
            return {'result': False, 'message': Lg().g(199)}
        if buytype == 1:
            if player.finance.getGold() < buymoney:
                return {'result': False, 'message': u'您钻不足,无法购买。'}
        elif buytype == 2:
            if player.finance.getCoin() < buymoney:
                return {'result': False, 'message': u'您金币不足,无法购买。'}

        result = player.shop.buyConsItem(tocharacterid, id, counts, itemid,
                                         buymoney, buytype)
        pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
        return result
    def buyGold(self, characterid, id):
        '''购买寄卖货币
        @param characterid: 购买人id
        @param id: 货币寄卖表主键id
        '''
        item = dbconsignment.getOneGold(id)
        player = PlayersManager().getPlayerByID(characterid)
        if not player:
            return {'result': False, 'message': Lg().g(199)}
        buymoney = item.get('buymoney', 0)  #换取的货币数量
        buytype = item.get('buytype', 1)  #换取的货币种类    1钻 2金币

        if buytype == 1:
            if player.finance.getGold() < buymoney:
                return {'result': False, 'message': u'您钻不足,无法购买。'}
        elif buytype == 2:
            if player.finance.getCoin() < buymoney:
                return {'result': False, 'message': u'您金币不足,无法购买。'}

        result = dbconsignment.buyGold(characterid, id, item)
        if result:
            pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
            return {'result': True, 'message': Lg().g(193)}
        else:
            return {'result': False, 'message': Lg().g(470)}
 def addGold(self,salemoney,saletype,buymoney,buytype,adtime,characterid):
     '''添加寄卖金币
     @param salemoney: int 寄卖者出售货币数量
     @param saletype: int 寄卖者出售货币类型 1钻 2金币
     @param buymoney: int 购买货币数量
     @param buytype: int 购买货币类型  1钻 2金币
     @param adtime: int 寄售的小时数
     @param characterid: int 寄卖者的id
     '''
     player=PlayersManager().getPlayerByID(characterid)
     if not player:
         return{'result':False,'message':Lg().g(199)}
     
     if saletype==1:
         if salemoney>player.finance.getGold():
             return{'result':False,'message':u'钻不足'}
         player.finance.updateGold(player.finance.getGold()-salemoney)
     if saletype==2:
         if salemoney>player.finance.getCoin():
             return{'result':False,'message':Lg().g(88)}
         player.finance.updateCoin(player.finance.getCoin()-salemoney)
     result=dbconsignment.addGold(salemoney, saletype, buymoney, buytype, adtime, characterid)
     if not result:
         return{'result':False,'message':u'添加寄卖表失败'}
     pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
     return{'result':False,'message':u'添加寄卖成功'}
 def buyItem(self,characterid,id):
     '''购买寄卖物品
     @param characterid: int 购买者的角色id
     @param id: int 物品寄卖表的主键id
     '''
     item = dbconsignment.getItemByoneid(id) #获取寄卖物品信息
     if not item:
         return{'result':False,'message':u'该物品已下架','data':None}
     tocharacterid=item.get('characterid',0) #寄卖物品的角色id
     itemid=item.get('itemid',0) #tb_item中的主键id
     buymoney=item.get('coinnum',0) #购买物品需要的货币数量
     if buymoney==0:
         return{'result':False,'message':u'价格不能为0','data':None}
     buytype=item.get('cointype',0) #购买物品需要的货币类型  1钻 2金币
     if buytype==1:
         buytype==2
     elif buytype==2:
         buytype==1
     counts=item.get('count',0) #购买的数量
     player=PlayersManager().getPlayerByID(characterid)
     if not player:
         return{'result':False,'message':Lg().g(199)}
     if buytype==1:
         if player.finance.getGold()<buymoney:
             return{'result':False,'message':u'您钻不足,无法购买。'}
     elif buytype==2:
         if player.finance.getCoin()<buymoney:
             return{'result':False,'message':u'您金币不足,无法购买。'}
     
     result=player.shop.buyConsItem(tocharacterid,id,counts,itemid,buymoney,buytype)
     pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
     return result
Exemple #9
0
def buyServicepack(player, mall_item, toid):
    '''把物品放入包裹中并扣除角色钱
    @param player: object 购买者的实例
    @param mall_item: 商城中的物品信息
    @param isGold: bool  是否是钻支付  ture 钻支付   false 绑定钻支付
    @param toid: int 送给角色的id 0为没有赠送人
    '''
    zhekou = player.attribute.getMallrebate()  #VIP折扣
    gold = int(mall_item['gold'] * 1.0 * zhekou)
    if mall_item['cx'] > 0:
        gold = mall_item['cx']
    newitem = mall_item['templateid']
    count = mall_item['count']
    itemTemplateId = newitem
    value = player.finance.getGold() - gold

    if value < 0:
        data = {
            'recharge': True,
            'priceType': 1,
            'itemTemplateId': itemTemplateId,
            'count': count
        }
        return {'result': False, 'message': Lg().g(190), 'data': data}
    if toid > 0:
        result = PlayerCharacter(toid).pack.putNewItemsInPackage(
            newitem, count)
        if not result:
            data = {
                'recharge': False,
                'priceType': 1,
                'itemTemplateId': itemTemplateId,
                'count': count
            }
            return {'result': False, 'message': Lg().g(191), 'data': data}
    else:
        result = player.pack.putNewItemsInPackage(newitem, count)
    if not result:
        data = {
            'recharge': False,
            'priceType': 1,
            'itemTemplateId': itemTemplateId,
            'count': count
        }
        return {'result': False, 'message': Lg().g(16), 'data': data}
    player.finance.updateGold(value)
    player.finance.consGold(gold, 2, itemId=newitem)

    player.schedule.noticeSchedule(12, goal=gold)
    data = {
        'recharge': False,
        'priceType': 1,
        'itemTemplateId': itemTemplateId,
        'count': count
    }
    pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
    if toid > 0:
        return {'result': True, 'message': Lg().g(192), 'data': data}
    return {'result': True, 'message': Lg().g(193), 'data': data}
Exemple #10
0
def HotelUseItem(characterid, typeid):
    '''使用酒店物品
    @param characterid: int 角色id
    @param typeid: int #0魔法泡沫酒 1普通果汁酒 2神奇果汁酒
    '''
    import math
    player = PlayersManager().getPlayerByID(characterid)  #角色
    if typeid == 0:
        Hp = player.attribute.getMaxHp() - player.attribute._hp  #最大血量-当前血量
        Mp = player.attribute.getMaxMp() - player.attribute._mp  #最大魔法-当前魔法
        coin = int(math.ceil((Hp + Mp) / 5.0))
        if coin > player.finance.getCoin():
            return {'result': False, 'message': u'金币不足,无法恢复'}
        if player.attribute.getMaxHp(
        ) == player.attribute._hp and player.attribute.getMaxMp(
        ) == player.attribute._mp:
            return {'result': False, 'message': u'您很健康,不要来捣乱'}
        player.attribute.updateHp(player.attribute.getMaxHp())  #最大血量
        player.attribute.updateMp(player.attribute.getMaxMp())  #最大魔法
        if player.level.getLevel() >= 15:  #15级之前免费
            player.finance.updateCoin(player.finance.getCoin() - coin)  #修改金币
    elif typeid == 1:  #1普通果汁酒
        if player.attribute.getEnergy() >= 200:
            return {'result': False, 'message': u'您的活力充足,不需要补充,我很忙的,不要来捣乱!'}
        if 10 > player.finance.getGold():
            return {'result': False, 'message': u'钻不足,无法恢复'}
        if player.attribute.getEnergy() <= 200 - 8:
            player.attribute.updateEnergy(player.attribute.getEnergy() + 8)
        else:
            player.attribute.updateEnergy(200)
        count = dbDrinkery.getByTypeAndCharacterid(characterid, typeid + 1)
        if count >= 3:
            return {'result': False, 'message': u'普通果汁酒今天已经使用了 3次'}
        if count == 0:
            add(characterid, 2, 1)
        elif count < 3:
            dbDrinkery.updateByCharacteridAndtype(characterid, typeid + 1, 1)

        player.finance.updateGold(player.finance.getGold() - 10)
    elif typeid == 2:
        if player.attribute.getEnergy() >= 200:
            return {'result': False, 'message': u'您您的活力充足,不需要补充,我很忙的,不要来捣乱'}
        if 35 > player.finance.getGold():
            return {'result': False, 'message': u'钻不足,无法恢复'}
        if player.attribute.getEnergy() <= 200 - 30:
            player.attribute.updateEnergy(player.attribute.getEnergy() + 30)
        else:
            player.attribute.updateEnergy(200)

        player.finance.updateGold(player.finance.getGold() - 35)

        count = dbDrinkery.getByTypeAndCharacterid(characterid, typeid + 1)
        if count == 1:
            return {'result': False, 'message': u'普通果汁酒今天已经使用了 1次'}
        if count == 0:
            add(characterid, 3, 1)

    pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
    return {'result': True, 'message': Lg().g(166)}
 def pushTeamMemberInfo(self):
     '''推送队伍成员信息'''
     if self._teamId == -1:
         pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
         return
     team = TeamManager().getTeamByID(self._teamId)
     if team :
         team.pushTeamMemberInfo()
     else:
         self._owner.updatePlayerInfo()
 def pushTeamMemberInfo(self):
     '''推送队伍成员信息'''
     if self._teamId == -1:
         pushObjectNetInterface.pushUpdatePlayerInfo(
             self._owner.getDynamicId())
         return
     team = TeamManager().getTeamByID(self._teamId)
     if team:
         team.pushTeamMemberInfo()
     else:
         self._owner.updatePlayerInfo()
    def updateMorale(self,val,state=1):#设置斗气值
        if self._morale<val:
            msg = Lg().g(309)%abs(val-self._morale)
        else:
            msg = Lg().g(310)%abs(val-self._morale)
        self._morale=val
#        dbaccess.updateCharacter(self._owner.baseInfo.id, 'morale', val)
        pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
        if state:
            pushPromptedMessage( msg, [self._owner.getDynamicId()])
        else:
            self._owner.msgbox.putFightMsg(msg)#将消息加入战后消息处理中
 def updateMorale(self, val, state=1):  #设置斗气值
     if self._morale < val:
         msg = Lg().g(309) % abs(val - self._morale)
     else:
         msg = Lg().g(310) % abs(val - self._morale)
     self._morale = val
     #        dbaccess.updateCharacter(self._owner.baseInfo.id, 'morale', val)
     pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
     if state:
         pushPromptedMessage(msg, [self._owner.getDynamicId()])
     else:
         self._owner.msgbox.putFightMsg(msg)  #将消息加入战后消息处理中
    def updateAddMorale(self, val, state=False):  #添加斗气值
        '''添加斗气值
        @param val: int 添加的斗气数量
        @param state: bool  true战后提示,False马上提示
        '''
        msg = Lg().g(309) % abs(val)

        self._morale += val
        pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
        if state:
            pushPromptedMessage(msg, [self._owner.getDynamicId()])
        else:
            self._owner.msgbox.putFightMsg(msg)  #将消息加入战后消息处理中
 def updateAddMorale(self,val,state=False):#添加斗气值
     '''添加斗气值
     @param val: int 添加的斗气数量
     @param state: bool  true战后提示,False马上提示
     '''
     msg = Lg().g(309)%abs(val)
     
     self._morale+=val
     pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
     if state:
         pushPromptedMessage( msg, [self._owner.getDynamicId()])
     else:
         self._owner.msgbox.putFightMsg(msg)#将消息加入战后消息处理中
 def updateGold(self, gold, state=1):
     delta = self._gold - gold
     if not delta:
         return
     if delta < 0:
         msg = Lg().g(314) % abs(delta)
     else:
         msg = Lg().g(315) % abs(delta)
     if delta > 0:
         self._owner.quest.UseGold(delta)
     self._gold = gold
     dbaccess.updateCharacter(self._owner.baseInfo.id, 'gold', gold)
     pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
     if state:
         if msg:
             pushPromptedMessage(msg, [self._owner.getDynamicId()])
     else:
         self._owner.msgbox.putFightMsg(msg)  #将消息加入战后消息处理中
    def updateCoin(self, coin, state=1):
        if coin == self._coin:
            return
        if coin - self._coin > 0:
            msg = Lg().g(311) % abs(coin - self._coin)
        else:
            msg = Lg().g(312) % abs(coin - self._coin)
        if coin >= self.MAXCOIN:
            msg = msg.join(["\n", Lg().g(313)])
            self._coin = self.MAXCOIN
        else:
            self._coin = coin
#        dbaccess.updateCharacter(self._owner.baseInfo.id, 'coin', self._coin)
        pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
        if state:
            pushPromptedMessage(msg, [self._owner.getDynamicId()])
        else:
            self._owner.msgbox.putFightMsg(msg)  #将消息加入战后消息处理中
 def RepurchaseItem(self, itemId):
     '''回购物品'''
     if not dbShop.checkSellItem(itemId, self._owner.baseInfo.id):
         return {'result': False, 'message': Lg().g(469)}
     item = Item(id=itemId)
     price = int(item.baseInfo.getItemPrice() / 0.7) * item.pack.getStack()
     SurplusCoin = self._owner.finance.getCoin() - price
     if SurplusCoin < 0:
         return {'result': False, 'message': Lg().g(88)}
     result = self._owner.pack.putNewItemInPackage(item)
     if result == 1:
         return {'result': False, 'message': Lg().g(377)}
     self._owner.finance.updateCoin(SurplusCoin)
     pushUpdatePlayerInfo(self._owner.getDynamicId())
     dbShop.delSellItem(itemId)
     msg = Lg().g(195)
     pushPromptedMessage(msg, [self._owner.getDynamicId()])
     return {'result': True, 'message': Lg().g(195)}
 def RepurchaseItem(self,itemId):
     '''回购物品'''
     if  not dbShop.checkSellItem(itemId, self._owner.baseInfo.id):
         return {'result':False,'message':Lg().g(469)}
     item = Item(id = itemId)
     price = int(item.baseInfo.getItemPrice()/0.7)*item.pack.getStack()
     SurplusCoin = self._owner.finance.getCoin() - price
     if SurplusCoin<0:
         return {'result':False,'message':Lg().g(88)}
     result = self._owner.pack.putNewItemInPackage(item)
     if result==1:
         return {'result':False,'message':Lg().g(377)}
     self._owner.finance.updateCoin(SurplusCoin)
     pushUpdatePlayerInfo(self._owner.getDynamicId())
     dbShop.delSellItem(itemId)
     msg = Lg().g(195)
     pushPromptedMessage(msg, [self._owner.getDynamicId()])
     return {'result':True,'message':Lg().g(195)}
 def updateGold(self,gold,state=1):
     delta = self._gold - gold
     if not delta:
         return
     if delta<0:
         msg = Lg().g(314)%abs(delta)
     else:
         msg = Lg().g(315)%abs(delta)
     if delta>0:
         self._owner.quest.UseGold(delta)
     self._gold = gold
     dbaccess.updateCharacter(self._owner.baseInfo.id, 'gold', gold)
     pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
     if state:
         if msg:
             pushPromptedMessage(msg, [self._owner.getDynamicId()])
     else:
         self._owner.msgbox.putFightMsg(msg)#将消息加入战后消息处理中
    def updateCoin(self,coin,state=1):
        if coin ==self._coin:
            return
        if coin-self._coin>0:
            msg = Lg().g(311)%abs(coin-self._coin)
        else:
            msg = Lg().g(312)%abs(coin-self._coin)
        if coin>= self.MAXCOIN:
            msg = msg.join(["\n",Lg().g(313)])
            self._coin = self.MAXCOIN 
        else:
            self._coin = coin
#        dbaccess.updateCharacter(self._owner.baseInfo.id, 'coin', self._coin)
        pushObjectNetInterface.pushUpdatePlayerInfo(self._owner.getDynamicId())
        if state:
            pushPromptedMessage( msg, [self._owner.getDynamicId()])
        else:
            self._owner.msgbox.putFightMsg(msg)#将消息加入战后消息处理中
Exemple #23
0
def buyServicepack(player, mall_item, toid):
    """把物品放入包裹中并扣除角色钱
    @param player: object 购买者的实例
    @param mall_item: 商城中的物品信息
    @param isGold: bool  是否是钻支付  ture 钻支付   false 绑定钻支付
    @param toid: int 送给角色的id 0为没有赠送人
    """
    zhekou = player.attribute.getMallrebate()  # VIP折扣
    gold = int(mall_item["gold"] * 1.0 * zhekou)
    if mall_item["cx"] > 0:
        gold = mall_item["cx"]
    newitem = mall_item["templateid"]
    count = mall_item["count"]
    itemTemplateId = newitem
    value = player.finance.getGold() - gold

    if value < 0:
        data = {"recharge": True, "priceType": 1, "itemTemplateId": itemTemplateId, "count": count}
        return {"result": False, "message": Lg().g(190), "data": data}
    if toid > 0:
        result = PlayerCharacter(toid).pack.putNewItemsInPackage(newitem, count)
        if not result:
            data = {"recharge": False, "priceType": 1, "itemTemplateId": itemTemplateId, "count": count}
            return {"result": False, "message": Lg().g(191), "data": data}
    else:
        result = player.pack.putNewItemsInPackage(newitem, count)
    if not result:
        data = {"recharge": False, "priceType": 1, "itemTemplateId": itemTemplateId, "count": count}
        return {"result": False, "message": Lg().g(16), "data": data}
    player.finance.updateGold(value)
    player.finance.consGold(gold, 2, itemId=newitem)

    player.schedule.noticeSchedule(12, goal=gold)
    data = {"recharge": False, "priceType": 1, "itemTemplateId": itemTemplateId, "count": count}
    pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
    if toid > 0:
        return {"result": True, "message": Lg().g(192), "data": data}
    return {"result": True, "message": Lg().g(193), "data": data}
 def pushInfoChanged(self,statu=1):
     if statu:
         pushObjectNetInterface.pushUpdatePlayerInfo(self.dynamicId)
Exemple #25
0
 def pushInfoChanged(self, statu=1):
     if statu:
         pushObjectNetInterface.pushUpdatePlayerInfo(self.dynamicId)
Exemple #26
0
def HotelUseItem(characterid,typeid):
    '''使用酒店物品
    @param characterid: int 角色id
    @param typeid: int #0魔法泡沫酒 1普通果汁酒 2神奇果汁酒
    '''
    import math
    player=PlayersManager().getPlayerByID(characterid) #角色
    if typeid==0:
        Hp=player.attribute.getMaxHp()-player.attribute._hp #最大血量-当前血量
        Mp=player.attribute.getMaxMp()-player.attribute._mp #最大魔法-当前魔法
        coin=int(math.ceil((Hp+Mp)/5.0))
        if coin>player.finance.getCoin():
            return{'result':False,'message':u'金币不足,无法恢复'}
        if player.attribute.getMaxHp()==player.attribute._hp and player.attribute.getMaxMp()==player.attribute._mp:
            return {'result':False,'message':u'您很健康,不要来捣乱'}
        player.attribute.updateHp(player.attribute.getMaxHp()) #最大血量
        player.attribute.updateMp(player.attribute.getMaxMp()) #最大魔法
        if player.level.getLevel()>=15: #15级之前免费
            player.finance.updateCoin(player.finance.getCoin()-coin) #修改金币
    elif typeid==1:#1普通果汁酒
        if player.attribute.getEnergy()>=200:
            return {'result':False,'message':u'您的活力充足,不需要补充,我很忙的,不要来捣乱!'}
        if 10>player.finance.getGold():
            return{'result':False,'message':u'钻不足,无法恢复'}
        if player.attribute.getEnergy()<=200-8:
            player.attribute.updateEnergy(player.attribute.getEnergy()+8)
        else:
            player.attribute.updateEnergy(200)
        count=dbDrinkery.getByTypeAndCharacterid(characterid, typeid+1)
        if count>=3:
            return{'result':False,'message':u'普通果汁酒今天已经使用了 3次'}
        if count==0:
            add(characterid,2,1)
        elif count<3:
            dbDrinkery.updateByCharacteridAndtype(characterid, typeid+1, 1)        
        
        player.finance.updateGold(player.finance.getGold()-10)
    elif typeid==2:
        if player.attribute.getEnergy()>=200:
            return {'result':False,'message':u'您您的活力充足,不需要补充,我很忙的,不要来捣乱'}
        if 35>player.finance.getGold():
            return{'result':False,'message':u'钻不足,无法恢复'}
        if player.attribute.getEnergy()<=200-30:
            player.attribute.updateEnergy(player.attribute.getEnergy()+30)
        else:
            player.attribute.updateEnergy(200)
        
        player.finance.updateGold(player.finance.getGold()-35)
        
        
        count=dbDrinkery.getByTypeAndCharacterid(characterid, typeid+1)
        if count==1:
            return{'result':False,'message':u'普通果汁酒今天已经使用了 1次'}
        if count==0:
            add(characterid,3,1)
        
    pushObjectNetInterface.pushUpdatePlayerInfo(player.dynamicId)
    return{'result':True,'message':Lg().g(166)}