def FormatMatrixInfoForWeixin(self):
     """格式化角色的阵法设置信息
     """
     matrix = []
     for index in range(1, 10):
         info = {}
         info['pos'] = index
         petId = self._matrixSetting.get('eyes_%d' % index)
         if petId == -1:
             continue
         elif petId == 0:
             info['chatype'] = 1
             info['chaid'] = self._owner.baseInfo.id
             info['tempid'] = self._owner.profession.getProfession()
         elif 3000000 <= petId:
             info['chatype'] = 3
             info['chaid'] = petId
             pet = self._owner.pet.getPets().get(petId)
             info['tempid'] = pet.templateId
         else:
             mcha = McharacterManager().getMCharacterById(petId)
             if not mcha:
                 continue
             info['chatype'] = 2
             info['chaid'] = petId
             info['tempid'] = mcha.get('profession')
         matrix.append(info)
     return {'matrix': matrix}
 def getGuYongList(self):
     """获取雇用列表
     """
     guyonglist = []
     for friend in self._guyong:
         info = {}
         mcha = McharacterManager().getMCharacterById(friend)
         if not mcha:
             continue
         info['chaid'] = friend
         info['chatype'] = 2
         info['tempid'] = mcha.get('profession')
         info['rolename'] = mcha.get('nickname')
         info['icon'] = mcha.get('profession')
         info['level'] = u'无'
         info['guanqia'] = u'无'
         info['skill'] = u'无'
         info['attack'] = 0
         info['fangyu'] = 0
         info['tili'] = 0
         info['minjie'] = 0
         info['price'] = mcha.get('level')*1000
         info['exp'] = 0
         guyonglist.append(info)
     return guyonglist
 def FormatMatrixInfoForWeixin(self):
     """格式化角色的阵法设置信息
     """
     matrix = []
     for index in range(1,10):
         info = {}
         info['pos'] = index
         petId = self._matrixSetting.get('eyes_%d'%index)
         if petId==-1:
             continue
         elif petId==0:
             info['chatype'] = 1
             info['chaid'] = self._owner.baseInfo.id
             info['tempid'] = self._owner.profession.getProfession()
         elif 3000000<=petId:
             info['chatype'] = 3
             info['chaid'] = petId
             pet  = self._owner.pet.getPets().get(petId)
             info['tempid'] = pet.templateId
         else:
             mcha = McharacterManager().getMCharacterById(petId)
             if not mcha:
                 continue
             info['chatype'] = 2
             info['chaid'] = petId
             info['tempid'] = mcha.get('profession')
         matrix.append(info)
     return {'matrix':matrix}
 def settleGuYong(self, friendid, result, zyid):
     '''雇用结算
     '''
     characterId = self._owner.baseInfo.id
     self._guyong.remove(friendid)
     dbFriend.UpdateGuYongState(characterId, friendid, 0)
     mcha = McharacterManager().getMCharacterById(friendid)
     rolename = mcha.get('nickname')
     zyinfo = dbZhanyi.ALL_ZHANGJIE_INFO.get(zyid)
     zyname = zyinfo.get('name', '')
     dbFriend.addGuyongRecord(characterId, rolename, zyname, zyid, result,
                              100, 1)
 def settleGuYong(self,friendid,result,zyid):
     """雇用结算
     """
     characterId = self._owner.baseInfo.id
     self._guyong.remove(friendid)
     dbFriend.UpdateGuYongState(characterId, friendid, 0)
     mcha = McharacterManager().getMCharacterById(friendid)
     rolename = mcha.get('nickname')
     zyinfo = dbZhanyi.ALL_ZHANGJIE_INFO.get(zyid)
     zyname = zyinfo.get('name','')
     dbFriend.addGuyongRecord(characterId, rolename, zyname,
                               zyid, result, 100, 1)
 def GuYongHaoYou(self, tid):
     '''雇用好友
     '''
     characterId = self._owner.baseInfo.id
     if tid == characterId:
         return {'result': False, 'messge': u'不能雇用自己'}
     mcha = McharacterManager().getMCharacterById(tid)
     if not mcha:
         return {'result': False, 'messge': u'好友信息不存在'}
     characterId = self._owner.baseInfo.id
     self.addFriend(characterId, tid)
     if tid in self._guyong:
         return {'result': False, 'messge': u'已经被雇用'}
     from app.game.core.PlayersManager import PlayersManager
     from app.game.core.character.PlayerCharacter import PlayerCharacter
     toplayer = PlayersManager().getPlayerByID(tid)
     if not toplayer:
         toplayer = PlayerCharacter(tid)
     price = toplayer.level.getLevel() * 1000
     if self._owner.finance.getCoin() < price:
         return {'result': False, 'messge': u'资金不足无法雇用'}
     self._guyong.add(tid)  #添加到雇用列表
     characterId = self._owner.baseInfo.id
     self._owner.finance.addCoin(-price)
     dbFriend.UpdateGuYongState(characterId, tid, 1)
     return {'result': True, 'messge': u'雇用成功'}
 def getGuYongList(self):
     '''获取雇用列表
     '''
     guyonglist = []
     for friend in self._guyong:
         info = {}
         mcha = McharacterManager().getMCharacterById(friend)
         if not mcha:
             continue
         info['chaid'] = friend
         info['chatype'] = 2
         info['tempid'] = mcha.get('profession')
         info['rolename'] = mcha.get('nickname')
         info['icon'] = mcha.get('profession')
         info['level'] = u'无'
         info['guanqia'] = u'无'
         info['skill'] = u'无'
         info['attack'] = 0
         info['fangyu'] = 0
         info['tili'] = 0
         info['minjie'] = 0
         info['price'] = mcha.get('level') * 1000
         info['exp'] = 0
         guyonglist.append(info)
     return guyonglist
예제 #8
0
def initData():
    """载入角色初始数据
    """
    McharacterManager().initData()