Exemplo n.º 1
0
def packageArrange(dynamicId,characterId,packageType):
    '''包裹整理'''
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result':False,'message':Lg().g(18)}
    player.pack.packageArrange(packageType)
    pushPromptedMessage(Lg().g(158),[player.getDynamicId()])
    return {'result':True,'message':Lg().g(158)}
Exemplo n.º 2
0
def LeaveGuild(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': Lg().g(18)}
    data = player.guild.leaveGuild()
    if data.get('result', False):
        pushPromptedMessage(Lg().g(89), [dynamicId])
    return data
Exemplo n.º 3
0
def LeaveGuild(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':Lg().g(18)}
    data = player.guild.leaveGuild()
    if data.get('result',False):
        pushPromptedMessage(Lg().g(89), [dynamicId])
    return data
 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 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 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 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 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 buyItemInMyshop(self,imteTemplateID,buyNum,npcId):
     '''购买商店物品'''
     shop = ShopManager().getShopByID(npcId)
     if not shop:
         return {'result':False,'message':Lg().g(468)}
     itemInfo = shop.getShopItemsById(imteTemplateID)
     if not itemInfo:
         return {'result':False,'message':Lg().g(189)}
     SurplusCoin = self._owner.finance.getCoin() - itemInfo['item'].baseInfo.getItemFinalyPrice()*buyNum
     if SurplusCoin<0:
         return {'result':False,'message':Lg().g(88)}
     result = self._owner.pack.putNewItemsInPackage(imteTemplateID,buyNum)
     if not result:
         return {'result':False,'message':Lg().g(16)}
     self._owner.finance.updateCoin(SurplusCoin)
     self._owner.updatePlayerInfo()
     msg = Lg().g(193)
     pushPromptedMessage(msg, [self._owner.getDynamicId()])
     return {'result':True,'message':Lg().g(193)}
 def buyItemInMyshop(self, imteTemplateID, buyNum, npcId):
     '''购买商店物品'''
     shop = ShopManager().getShopByID(npcId)
     if not shop:
         return {'result': False, 'message': Lg().g(468)}
     itemInfo = shop.getShopItemsById(imteTemplateID)
     if not itemInfo:
         return {'result': False, 'message': Lg().g(189)}
     SurplusCoin = self._owner.finance.getCoin(
     ) - itemInfo['item'].baseInfo.getItemFinalyPrice() * buyNum
     if SurplusCoin < 0:
         return {'result': False, 'message': Lg().g(88)}
     result = self._owner.pack.putNewItemsInPackage(imteTemplateID, buyNum)
     if not result:
         return {'result': False, 'message': Lg().g(16)}
     self._owner.finance.updateCoin(SurplusCoin)
     self._owner.updatePlayerInfo()
     msg = Lg().g(193)
     pushPromptedMessage(msg, [self._owner.getDynamicId()])
     return {'result': True, 'message': Lg().g(193)}
Exemplo n.º 16
0
 def packageExpansion(self,position):
     '''包裹扩充'''
     package = self.pack
     PurposeSize = position +1
     start = package.getSize()-self.INITSIZE
     if start<0:
         return {'result':False,'message':u'坑爹呢!'}
     end = PurposeSize - package.getSize()
     cost = 0
     while end>0:
         start += 1
         cost += start*2
         end -=1
     if self._owner.finance.getGold()<cost:
         return {'result':False,'message':Lg().g(190)}
     self._owner.finance.updateGold(self._owner.finance.getGold()-cost)
     self._owner.updatePlayerInfo()
     package.setSize(PurposeSize)
     dbaccess.updatePlayerInfo(self._owner.baseInfo.id, {'famPackSize':PurposeSize})
     pushPromptedMessage(Lg().g(352)%cost,[self._owner.getDynamicId()])
     return {'result':True,'message':Lg().g(352)%cost}
 def putNewItemInPackage(self, item, position=-2, state=1, turned=0):
     '''放置一个新的物品到包裹栏中
     @param item: Item object 物品实例
     @param position: int 物品的位置
     @param packageType: int 包裹的类型
     @param state: int 是否及时的推送获取物品消息
     @param turned: int 是否是反牌子获取的
     '''
     packType = 1
     if item.baseInfo.getItemPageType() == 4:
         packType = 2
     package = self._package.getPackageByType(packType)
     if position == -2:
         position = package.findSparePositionForItem()
     if position == -1:
         return 1
     nowItem = package.getItemByPosition(position)
     if nowItem:  #当所在的位置存在物品时
         return 1
     spacecnt = package.findSparePositionNum()
     if spacecnt <= 5:
         recCharacterId = self._owner.baseInfo.id
         tishiStr = Lg().g(377)
         contentStr = Lg().g(378)
         caozuoStr = Lg().g(379)
         pushCorpsApplication(recCharacterId, 7, tishiStr, contentStr,
                              caozuoStr)
         _msg = Lg().g(380)
         pushPromptedMessage(_msg, [self._owner.getDynamicId()])
     msg = Lg().g(381) % (item.baseInfo.getRichName(), item.pack.getStack())
     maxstack = item.baseInfo.getItemTemplateInfo().get('maxstack', 1)
     nowstack = item.pack.getStack()
     templateId = item.baseInfo.getItemTemplateId()
     if self._owner.pet.collectNotice(templateId, nowstack):
         if state:
             pushPromptedMessage(msg, [self._owner.getDynamicId()])
         else:
             self._owner.msgbox.putFightMsg(msg)
         return 2
     #先合并能合并的
     for _item in package.getItems():
         if _item['itemComponent'].baseInfo.getItemTemplateId()==templateId \
                                 and _item['itemComponent'].pack.getStack()<=maxstack:
             if _item['itemComponent'].pack.getStack(
             ) + nowstack <= maxstack:
                 _item['itemComponent'].pack.updateStack(
                     _item['itemComponent'].pack.getStack() + nowstack)
                 nowstack = 0
                 break
     if nowstack:
         if item.baseInfo.getId() == 0:
             item.InsertItemIntoDB(characterId=self._owner.baseInfo.id)
         package.putItemInstanceInPackDB(item, position,
                                         self._owner.baseInfo.getId())
     if state:
         pushPromptedMessage(msg, [self._owner.getDynamicId()])
     else:
         self._owner.msgbox.putFightMsg(msg)
     return 2
 def useItem(self,position,fromPackCategory):
     '''使用物品
     @param packageType: int 包裹分页类型 1 全部 2
     @param position: int 物品所在包裹位置
     '''
     package = self._package.getPackageByType(fromPackCategory)
     item = package.getItemByPosition(position)
     if not item:
         return {'result':False,'message':Lg().g(189)}
     script = item.baseInfo.getUseScript()#物品使用的脚本
     if not script:
         pushPromptedMessage(Lg().g(403),[self._owner.getDynamicId()])
         return {'result':False,'message':Lg().g(403)}
     professionRequired = item.baseInfo.getItemProfession()
     if professionRequired!=self._owner.profession.getProfession() and professionRequired!=0:
         return {'result':False,'message':Lg().g(404)}
     if item.baseInfo.getLevelRequired()> self._owner.level.getLevel():
         return {'result':False,'message':Lg().g(405)}
     nowstack = item.pack.getStack()
     try:
         exec(script)#执行任务脚本
     except Exception,e:
         return {'result':False,'message':e.message}
 def packageExpansion(self,packageType,curpage,position):
     '''包裹扩充'''
     package = self._package.getPackageByType(packageType)
     PurposeSize = (curpage-1)*self._package.LIMIT + position +1
     start = package.getSize()-24
     if start<0:
         return {'result':False,'message':u'坑爹呢!'}
     end = PurposeSize - package.getSize()
     if end<0:
         return {'result':False,'message':u'坑爹呢!'}
     cost = 0
     while end>0:
         start += 1
         cost += start*2
         end -=1
     if self._owner.finance.getGold()<cost:
         return {'result':False,'message':Lg().g(190)}
     self._owner.finance.updateGold(self._owner.finance.getGold()-cost)
     self._owner.updatePlayerInfo()
     package.setSize(PurposeSize)
     dbaccess.updatePlayerInfo(self._owner.baseInfo.id, {'packageSize':PurposeSize})
     pushPromptedMessage(Lg().g(352)%cost,[self._owner.getDynamicId()])
     return {'result':True,'message':Lg().g(352)%cost}
Exemplo n.º 20
0
    def leaveGuild(self, operator):
        '''离开行会'''
        from app.scense.core.instance.ColonizeManage import ColonizeManage
        if self.getPresident() == operator:
            newPresident = self.findNewPresident()
            if not newPresident:
                return {'result': False, 'message': Lg().g(550)}
            else:
                dbGuild.updateCharacterGuildInfo(newPresident, {'post': 4})
                self.president = newPresident
#        if operator in eval("["+self.guildinfo['veterans']+"]"):
#            newstaffOfficers = str(eval("["+self.guildinfo['veterans']+"]").remove(operator))[1:-1]
#            self.update('veterans', newstaffOfficers)
#        if operator in eval("["+self.guildinfo['staffOfficers']+"]"):
#            newveterans = str(eval("["+self.guildinfo['staffOfficers']+"]").remove(operator))[1:-1]
#            self.update('staffOfficers', newveterans)
#        if operator in eval("["+self.guildinfo['senators']+"]"):
#            newsenators = str(eval("["+self.guildinfo['senators']+"]").remove(operator))[1:-1]
#            self.update('senators', newsenators)
        result = dbGuild.deleteCharacterGuildRelation(operator)
        if result:
            postdict = dbGuild.updateGuildPost(self.id)
            self.veterans = postdict.veterans
            self.staffOfficers = postdict.staffOfficers
            self.senators = postdict.senators
            player = PlayersManager().getPlayerByID(operator)
            player.updatePlayerInfo()
            playerList = dbGuild.getGuildCharacterIdList(self.id)
            msg = Lg().g(551) % player.baseInfo.getName()
            sendList = [PlayersManager().getPlayerByID(p[0]).getDynamicId()\
                         for p in playerList \
                        if PlayersManager().getPlayerByID(p[0]) and \
                        PlayersManager().getPlayerByID(p[0]).getDynamicId()]
            pushPromptedMessage(msg, sendList)
            ColonizeManage().updateGuild(operator, 0, Lg().g(143))
            return {'result': True, 'message': Lg().g(552)}  #开除成功
        return {'result': False, 'message': Lg().g(553)}  #开除失败
Exemplo n.º 21
0
    def leaveGuild(self,operator):
        '''离开行会'''
        from app.scense.core.instance.ColonizeManage import ColonizeManage
        if self.getPresident() == operator:
            newPresident =  self.findNewPresident()
            if not newPresident:
                return {'result':False,'message':Lg().g(550)}
            else:
                dbGuild.updateCharacterGuildInfo(newPresident, {'post':4})
                self.president=newPresident
#        if operator in eval("["+self.guildinfo['veterans']+"]"):
#            newstaffOfficers = str(eval("["+self.guildinfo['veterans']+"]").remove(operator))[1:-1]
#            self.update('veterans', newstaffOfficers)
#        if operator in eval("["+self.guildinfo['staffOfficers']+"]"):
#            newveterans = str(eval("["+self.guildinfo['staffOfficers']+"]").remove(operator))[1:-1]
#            self.update('staffOfficers', newveterans)
#        if operator in eval("["+self.guildinfo['senators']+"]"):
#            newsenators = str(eval("["+self.guildinfo['senators']+"]").remove(operator))[1:-1]
#            self.update('senators', newsenators)
        result = dbGuild.deleteCharacterGuildRelation(operator)
        if result:
            postdict = dbGuild.updateGuildPost(self.id)
            self.veterans=postdict.veterans
            self.staffOfficers=postdict.staffOfficers
            self.senators=postdict.senators
            player = PlayersManager().getPlayerByID(operator)
            player.updatePlayerInfo()
            playerList = dbGuild.getGuildCharacterIdList(self.id)
            msg = Lg().g(551)%player.baseInfo.getName()
            sendList = [PlayersManager().getPlayerByID(p[0]).getDynamicId()\
                         for p in playerList \
                        if PlayersManager().getPlayerByID(p[0]) and \
                        PlayersManager().getPlayerByID(p[0]).getDynamicId()]
            pushPromptedMessage(msg, sendList)
            ColonizeManage().updateGuild(operator, 0, Lg().g(143))
            return {'result':True,'message':Lg().g(552)}#开除成功
        return {'result':False,'message':Lg().g(553)}#开除失败
 def useItem(self, position, fromPackCategory):
     '''使用物品
     @param packageType: int 包裹分页类型 1 全部 2
     @param position: int 物品所在包裹位置
     '''
     package = self._package.getPackageByType(fromPackCategory)
     item = package.getItemByPosition(position)
     if not item:
         return {'result': False, 'message': Lg().g(189)}
     script = item.baseInfo.getUseScript()  #物品使用的脚本
     if not script:
         pushPromptedMessage(Lg().g(403), [self._owner.getDynamicId()])
         return {'result': False, 'message': Lg().g(403)}
     professionRequired = item.baseInfo.getItemProfession()
     if professionRequired != self._owner.profession.getProfession(
     ) and professionRequired != 0:
         return {'result': False, 'message': Lg().g(404)}
     if item.baseInfo.getLevelRequired() > self._owner.level.getLevel():
         return {'result': False, 'message': Lg().g(405)}
     nowstack = item.pack.getStack()
     try:
         exec(script)  #执行任务脚本
     except Exception, e:
         return {'result': False, 'message': e.message}
 def packageExpansion(self, packageType, curpage, position):
     '''包裹扩充'''
     package = self._package.getPackageByType(packageType)
     PurposeSize = (curpage - 1) * self._package.LIMIT + position + 1
     start = package.getSize() - 24
     if start < 0:
         return {'result': False, 'message': u'坑爹呢!'}
     end = PurposeSize - package.getSize()
     if end < 0:
         return {'result': False, 'message': u'坑爹呢!'}
     cost = 0
     while end > 0:
         start += 1
         cost += start * 2
         end -= 1
     if self._owner.finance.getGold() < cost:
         return {'result': False, 'message': Lg().g(190)}
     self._owner.finance.updateGold(self._owner.finance.getGold() - cost)
     self._owner.updatePlayerInfo()
     package.setSize(PurposeSize)
     dbaccess.updatePlayerInfo(self._owner.baseInfo.id,
                               {'packageSize': PurposeSize})
     pushPromptedMessage(Lg().g(352) % cost, [self._owner.getDynamicId()])
     return {'result': True, 'message': Lg().g(352) % cost}
 def putNewItemInPackage(self,item,position=-2,state = 1,turned = 0):
     '''放置一个新的物品到包裹栏中
     @param item: Item object 物品实例
     @param position: int 物品的位置
     @param packageType: int 包裹的类型
     @param state: int 是否及时的推送获取物品消息
     @param turned: int 是否是反牌子获取的
     '''
     packType = 1
     if item.baseInfo.getItemPageType()==4:
         packType = 2
     package = self._package.getPackageByType(packType)
     if position ==-2:
         position = package.findSparePositionForItem()
     if position==-1:
         return 1
     nowItem = package.getItemByPosition(position)
     if nowItem:#当所在的位置存在物品时
         return 1
     spacecnt = package.findSparePositionNum()
     if spacecnt<=5 :
         recCharacterId = self._owner.baseInfo.id
         tishiStr = Lg().g(377)
         contentStr = Lg().g(378)
         caozuoStr = Lg().g(379)
         pushCorpsApplication(recCharacterId, 7, tishiStr, contentStr, caozuoStr)
         _msg = Lg().g(380)
         pushPromptedMessage(_msg, [self._owner.getDynamicId()])
     msg = Lg().g(381)%(item.baseInfo.getRichName(),item.pack.getStack())
     maxstack = item.baseInfo.getItemTemplateInfo().get('maxstack',1)
     nowstack = item.pack.getStack()
     templateId = item.baseInfo.getItemTemplateId()
     if self._owner.pet.collectNotice(templateId,nowstack):
         if state:
             pushPromptedMessage(msg, [self._owner.getDynamicId()])
         else:
             self._owner.msgbox.putFightMsg(msg)
         return 2
     #先合并能合并的
     for _item in package.getItems():
         if _item['itemComponent'].baseInfo.getItemTemplateId()==templateId \
                                 and _item['itemComponent'].pack.getStack()<=maxstack:
             if _item['itemComponent'].pack.getStack()+nowstack<= maxstack:
                 _item['itemComponent'].pack.updateStack(_item['itemComponent'].pack.getStack()+nowstack)
                 nowstack = 0
                 break
     if nowstack:
         if item.baseInfo.getId()==0:
             item.InsertItemIntoDB(characterId = self._owner.baseInfo.id)
         package.putItemInstanceInPackDB(item, position, self._owner.baseInfo.getId())
     if state:
         pushPromptedMessage(msg, [self._owner.getDynamicId()])
     else:
         self._owner.msgbox.putFightMsg(msg)
     return 2
Exemplo n.º 25
0
 def fireMember(self,operator,memberId):
     '''开除行会成员
     @param operator: 操作者的id
     @param memberID: int 成员的id 角色id
     '''
     from app.scense.core.instance.ColonizeManage import ColonizeManage
     president = self.getPresident()
     veteranList = eval('['+self.guildinfo['veterans']+']')
     staffList = eval('['+self.guildinfo['staffOfficers']+']')
     senatorsList = eval('['+self.guildinfo['senators']+']')
     #获取操作者的权限
     if operator==president:
         operatorpost =4
     elif operator in veteranList:
         operatorpost = 3
     elif operator in staffList:
         operatorpost = 2
     elif operator in senatorsList:
         operatorpost = 1
     else:
         operatorpost = 0
     #获取被操作者的权限
     if memberId==president:
         memberpost =4
     elif memberId in veteranList:
         memberpost = 3
     elif memberId in staffList:
         memberpost = 2
     elif memberId in senatorsList:
         memberpost = 1
     else:
         memberpost = 0
         
     if operator ==memberId:
         return {'result':False,'message':Lg().g(523)}#权限不够
     if operatorpost<= memberpost:
         return {'result':False,'message':Lg().g(515)}#权限不够
     if not dbGuild.checkCharacterInGuild(memberId, self.id):
         return {'result':False,'message':Lg().g(524)}
     result = dbGuild.deleteCharacterGuildRelation(memberId)
     if result:
         postdict = dbGuild.updateGuildPost(self.id)
         self.veterans=postdict.veterans
         self.staffOfficers=postdict.staffOfficers
         self.senators=postdict.senators
         content = Lg().g(525)%(self.guildinfo.get('nickname',''),\
                                   self.guildinfo.get('name',''))
         title = Lg().g(526)
         m = Mail( title=title,type =0, senderId =-1, receiverId=memberId,\
                         sender = Lg().g(128),content=content)
         m.mailIntoDB()
         player = PlayersManager().getPlayerByID(memberId)
         if player:
             player.guild.updateID(0)
             chatnoderemote.callRemote('updateGuild',memberId,self.id,0)#同步聊天角色中的行会
             playerList = dbGuild.getGuildCharacterIdList(self.id)
             msg = Lg().g(527)%(player.baseInfo.getName(),self.getGuildName())
             sendList = [PlayersManager().getPlayerByID(p[0]).getDynamicId()\
                      for p in playerList \
                     if PlayersManager().getPlayerByID(p[0]) and \
                     PlayersManager().getPlayerByID(p[0]).getDynamicId()]
             pushPromptedMessage(msg, sendList)
             player.updatePlayerInfo()
         ColonizeManage().updateGuild(memberId, 0, u'')
         return {'result':True,'message':Lg().g(528)}#开除成功
     return {'result':False,'message':Lg().g(529)}#开除失败
Exemplo n.º 26
0
    def fireMember(self, operator, memberId):
        '''开除行会成员
        @param operator: 操作者的id
        @param memberID: int 成员的id 角色id
        '''
        from app.scense.core.instance.ColonizeManage import ColonizeManage
        president = self.getPresident()
        veteranList = eval('[' + self.guildinfo['veterans'] + ']')
        staffList = eval('[' + self.guildinfo['staffOfficers'] + ']')
        senatorsList = eval('[' + self.guildinfo['senators'] + ']')
        #获取操作者的权限
        if operator == president:
            operatorpost = 4
        elif operator in veteranList:
            operatorpost = 3
        elif operator in staffList:
            operatorpost = 2
        elif operator in senatorsList:
            operatorpost = 1
        else:
            operatorpost = 0
        #获取被操作者的权限
        if memberId == president:
            memberpost = 4
        elif memberId in veteranList:
            memberpost = 3
        elif memberId in staffList:
            memberpost = 2
        elif memberId in senatorsList:
            memberpost = 1
        else:
            memberpost = 0

        if operator == memberId:
            return {'result': False, 'message': Lg().g(523)}  #权限不够
        if operatorpost <= memberpost:
            return {'result': False, 'message': Lg().g(515)}  #权限不够
        if not dbGuild.checkCharacterInGuild(memberId, self.id):
            return {'result': False, 'message': Lg().g(524)}
        result = dbGuild.deleteCharacterGuildRelation(memberId)
        if result:
            postdict = dbGuild.updateGuildPost(self.id)
            self.veterans = postdict.veterans
            self.staffOfficers = postdict.staffOfficers
            self.senators = postdict.senators
            content = Lg().g(525)%(self.guildinfo.get('nickname',''),\
                                      self.guildinfo.get('name',''))
            title = Lg().g(526)
            m = Mail( title=title,type =0, senderId =-1, receiverId=memberId,\
                            sender = Lg().g(128),content=content)
            m.mailIntoDB()
            player = PlayersManager().getPlayerByID(memberId)
            if player:
                player.guild.updateID(0)
                chatnoderemote.callRemote('updateGuild', memberId, self.id,
                                          0)  #同步聊天角色中的行会
                playerList = dbGuild.getGuildCharacterIdList(self.id)
                msg = Lg().g(527) % (player.baseInfo.getName(),
                                     self.getGuildName())
                sendList = [PlayersManager().getPlayerByID(p[0]).getDynamicId()\
                         for p in playerList \
                        if PlayersManager().getPlayerByID(p[0]) and \
                        PlayersManager().getPlayerByID(p[0]).getDynamicId()]
                pushPromptedMessage(msg, sendList)
                player.updatePlayerInfo()
            ColonizeManage().updateGuild(memberId, 0, u'')
            return {'result': True, 'message': Lg().g(528)}  #开除成功
        return {'result': False, 'message': Lg().g(529)}  #开除失败
 def pushAutoUnloadCatch(self):
     '''推送自动卸载了抓宠技能的消息'''
     msg = u"<font color = '#FFFF00'>背包中缺少封印石,请及时补充</font>"
     pushPromptedMessage(msg, [self._owner.getDynamicId()])
Exemplo n.º 28
0
 def FightInScene(self,monsterId,now_X,playerId):
     '''副本战斗
     @param monsterId: int 怪物的id
     @param now_X: int 碰撞点的x坐标
     '''
     from app.scense.core.fight.fight_new import Fight
     if not self._monsters:
         return {'result':False,'message':u'不存在怪物实例'}
     fightInfo = {}
     fightType = 1
     sendList = self.getSendList()
     players = [PlayersManager().getPlayerByID(playerId) for playerId in self._playerlist]
     monster = self._monsters.get(monsterId,None)
     deffen = []
     if not monster:
         return {'result':False,'message':u'不存在怪物实例'}
     msgsendList = []
     for pp in players:#如果有抓宠技能则消耗相应的道具
         pp.skill.autoUnloadCatch()
         if pp.skill.checkHasEquipCatchSkill():
             level = pp.skill.getCatchPetLevel()
             itemTemplateID = pp.skill.CATCHCONSUME.get(level,0)
             msgsendList.append(pp.getDynamicId())
             if itemTemplateID:
                 pp.pack.delItemByTemplateId(itemTemplateID,1)
     
     if monster.formatInfo['difficulty']==5 and msgsendList:
         msg = Lg().g(574)
         pushPromptedMessage(msg, msgsendList)
     challengers = BattleSide(players)
     matrixId = monster.getMatrixId()
     ruleInfo = monster.getRule()
     if not ruleInfo:
         deffen.append(monster)
         defenders = BattleSide(deffen)
     else:
         temlist,rule = ruleInfo
         for tem in temlist:
             _monser = self.createMonster(tem)
             deffen.append(_monser)
         defenders = BattleSide(deffen,state = 0)
         defenders.setMatrixPositionBatch(rule)
     #获取战场中心位置
     realcenter = self._width/2
     data = Fight( challengers, defenders, realcenter)
     data.DoFight()
     
     #战后处理
     if data.battleResult == 1:
         self.dropMonster(monsterId)
     elif data.battleResult == 3:
         fightType = 3
         monster = self._monsters[monsterId]
         for player in self._playerlist:
             pl = PlayersManager().getPlayerByID(player)
             pl.baseInfo.initPosition(self.getInitPosition())
         monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
     elif data.battleResult == 2:
         fightType = 2
         monster = self._monsters[monsterId]
         for player in self._playerlist:
             pl = PlayersManager().getPlayerByID(player)
             pl.baseInfo.initPosition(self.getInitPosition())
             self.pushFightFailHelp(pl)
         monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
     if not self._monsters and self._type ==2:
         fightType = 4
         #print '通关副本'
     settlementData = []
     dropoutid = monster.formatInfo['dropoutid']
     for player in data.fighters.values():
         if player['characterType']==3:#宠物
             pet = PlayersManager().getPlayerByID(playerId).pet._pets.get(player['chaId'])
             pet.attribute.updateHp(int(player['chaCurrentHp']))#更新宠物的血量
             if data.battleResult == 1:
                 exp = monster.formatInfo.get('expbound',100)*len(deffen)
                 pet.level.addExp(exp)
             continue
         if player['characterType']==1:
             pp = PlayersManager().getPlayerByID(player['chaId'])
             if data.battleResult == 1:
                 dropoutIitem = dropout.getDropByid(dropoutid)
                 info = {}
                 info['id'] = player['chaId']
                 info['name'] = player['chaName']
                 info['profession'] = player['figureType']
                 info['expBonus'] = monster.formatInfo.get('expbound',100)*len(deffen)
                 info['coinBonus'] = 0
                 info['goldBonus'] = 0
                 info['itemsBonus'] = dropoutIitem#None#getDropByid(1)
                 info['popularity'] = 0
                 info['attackGoal'] = 0
                 info['defenseGoal'] = 0
                 info['slayGoal'] = 0
                 settlementData.append(info)
                 expEff = pp.attribute.getExpEff()#经验加成
                 pp.level.updateExp(pp.level.getExp()+info['expBonus']*expEff,state = 0)
                 pp.finance.updateCoin(pp.finance.getCoin()+info['coinBonus'],state = 0)
                 pp.finance.updateGold(pp.finance.getGold()+info['goldBonus'],state = 0)
                 if info['itemsBonus']:
                     pp.pack.putNewItemInPackage(info['itemsBonus'],state=0)
                 for monster in deffen:
                     pp.quest.killMonster(monster.templateId)
             pp.attribute.updateHp(int(player['chaCurrentHp']),state = 0)
             pp.effect.doEffectHot()#执行效果战后处理
         
     fightInfo['fightType'] = fightType
     fightInfo['battle'] = data
     fightInfo['sendList'] = sendList
     fightInfo['centerX'] = realcenter
     fightInfo['setData'] = settlementData
     fightInfo['centerY'] = HEIGHT
     
     return {'result':True,'data':fightInfo}
Exemplo n.º 29
0
    def FightInScene(self, monsterId, now_X, playerId):
        '''副本战斗
        @param monsterId: int 怪物的id
        @param now_X: int 碰撞点的x坐标
        '''
        from app.scense.core.fight.fight_new import Fight
        if not self._monsters:
            return {'result': False, 'message': u'不存在怪物实例'}
        fightInfo = {}
        fightType = 1
        sendList = self.getSendList()
        players = [
            PlayersManager().getPlayerByID(playerId)
            for playerId in self._playerlist
        ]
        monster = self._monsters.get(monsterId, None)
        deffen = []
        if not monster:
            return {'result': False, 'message': u'不存在怪物实例'}
        msgsendList = []
        for pp in players:  #如果有抓宠技能则消耗相应的道具
            pp.skill.autoUnloadCatch()
            if pp.skill.checkHasEquipCatchSkill():
                level = pp.skill.getCatchPetLevel()
                itemTemplateID = pp.skill.CATCHCONSUME.get(level, 0)
                msgsendList.append(pp.getDynamicId())
                if itemTemplateID:
                    pp.pack.delItemByTemplateId(itemTemplateID, 1)

        if monster.formatInfo['difficulty'] == 5 and msgsendList:
            msg = Lg().g(574)
            pushPromptedMessage(msg, msgsendList)
        challengers = BattleSide(players)
        matrixId = monster.getMatrixId()
        ruleInfo = monster.getRule()
        if not ruleInfo:
            deffen.append(monster)
            defenders = BattleSide(deffen)
        else:
            temlist, rule = ruleInfo
            for tem in temlist:
                _monser = self.createMonster(tem)
                deffen.append(_monser)
            defenders = BattleSide(deffen, state=0)
            defenders.setMatrixPositionBatch(rule)
        #获取战场中心位置
        realcenter = self._width / 2
        data = Fight(challengers, defenders, realcenter)
        data.DoFight()

        #战后处理
        if data.battleResult == 1:
            self.dropMonster(monsterId)
        elif data.battleResult == 3:
            fightType = 3
            monster = self._monsters[monsterId]
            for player in self._playerlist:
                pl = PlayersManager().getPlayerByID(player)
                pl.baseInfo.initPosition(self.getInitPosition())
            monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
        elif data.battleResult == 2:
            fightType = 2
            monster = self._monsters[monsterId]
            for player in self._playerlist:
                pl = PlayersManager().getPlayerByID(player)
                pl.baseInfo.initPosition(self.getInitPosition())
                self.pushFightFailHelp(pl)
            monster.baseInfo.initPosition(monster.baseInfo.getStaticPosition())
        if not self._monsters and self._type == 2:
            fightType = 4
            #print '通关副本'
        settlementData = []
        dropoutid = monster.formatInfo['dropoutid']
        for player in data.fighters.values():
            if player['characterType'] == 3:  #宠物
                pet = PlayersManager().getPlayerByID(playerId).pet._pets.get(
                    player['chaId'])
                pet.attribute.updateHp(int(player['chaCurrentHp']))  #更新宠物的血量
                if data.battleResult == 1:
                    exp = monster.formatInfo.get('expbound', 100) * len(deffen)
                    pet.level.addExp(exp)
                continue
            if player['characterType'] == 1:
                pp = PlayersManager().getPlayerByID(player['chaId'])
                if data.battleResult == 1:
                    dropoutIitem = dropout.getDropByid(dropoutid)
                    info = {}
                    info['id'] = player['chaId']
                    info['name'] = player['chaName']
                    info['profession'] = player['figureType']
                    info['expBonus'] = monster.formatInfo.get(
                        'expbound', 100) * len(deffen)
                    info['coinBonus'] = 0
                    info['goldBonus'] = 0
                    info['itemsBonus'] = dropoutIitem  #None#getDropByid(1)
                    info['popularity'] = 0
                    info['attackGoal'] = 0
                    info['defenseGoal'] = 0
                    info['slayGoal'] = 0
                    settlementData.append(info)
                    expEff = pp.attribute.getExpEff()  #经验加成
                    pp.level.updateExp(pp.level.getExp() +
                                       info['expBonus'] * expEff,
                                       state=0)
                    pp.finance.updateCoin(pp.finance.getCoin() +
                                          info['coinBonus'],
                                          state=0)
                    pp.finance.updateGold(pp.finance.getGold() +
                                          info['goldBonus'],
                                          state=0)
                    if info['itemsBonus']:
                        pp.pack.putNewItemInPackage(info['itemsBonus'],
                                                    state=0)
                    for monster in deffen:
                        pp.quest.killMonster(monster.templateId)
                pp.attribute.updateHp(int(player['chaCurrentHp']), state=0)
                pp.effect.doEffectHot()  #执行效果战后处理

        fightInfo['fightType'] = fightType
        fightInfo['battle'] = data
        fightInfo['sendList'] = sendList
        fightInfo['centerX'] = realcenter
        fightInfo['setData'] = settlementData
        fightInfo['centerY'] = HEIGHT

        return {'result': True, 'data': fightInfo}
 def updateCoupon(self,coupon):
     self._coupon = coupon
     msg = u'消耗礼券%d'%(coupon-self._coin)
     dbaccess.updateCharacter(self._owner.baseInfo.id, 'coupon', coupon)
     pushPromptedMessage(msg, [self._owner.getDynamicId()])
 def pushAutoUnloadCatch(self):
     '''推送自动卸载了抓宠技能的消息'''
     msg = u"<font color = '#FFFF00'>背包中缺少封印石,请及时补充</font>"
     pushPromptedMessage(msg, [self._owner.getDynamicId()])
 def updateCoupon(self, coupon):
     self._coupon = coupon
     msg = u'消耗礼券%d' % (coupon - self._coin)
     dbaccess.updateCharacter(self._owner.baseInfo.id, 'coupon', coupon)
     pushPromptedMessage(msg, [self._owner.getDynamicId()])