예제 #1
0
 def sendLevelReward(self, userId, oldLevel, newLevel):
     if not newLevel.rewardContent:
         return None
     items = newLevel.rewardContent.getItems()
     ftlog.info('GameSkillScore.sendLevelReward', 'userId=', userId,
                'oldLevel=', oldLevel.level, 'new_level=', newLevel.level,
                'items=', [(ci.assetKindId, ci.count) for ci in items])
     ua = hallitem.itemSystem.loadUserAssets(userId)
     aslist = ua.sendContentItemList(self.gameId, items, 1, True,
                                     pktimestamp.getCurrentTimestamp(),
                                     'TASK_MASTER_SCORE_UP_LEVEL_REWARD',
                                     newLevel.level)
     items = []
     for x in aslist:
         kindId = hallconf.translateAssetKindIdToOld(x[0].kindId)
         akind = hallitem.itemSystem.findAssetKind(x[0].kindId)
         items.append({
             'id': kindId,
             'count': x[1],
             'name': akind.displayName,
             'pic': akind.pic,
         })
     datachangenotify.sendDataChangeNotify(
         self.gameId, userId, TYAssetUtils.getChangeDataNames(aslist))
     return items
예제 #2
0
파일: match.py 프로젝트: luningcowboy/tuyoo
 def buildFees(cls, fees):
     ret = []
     for fee in fees:
         if fee.count > 0:
             name = hallconf.translateAssetKindIdToOld(fee.assetKindId)
             ret.append({'item':name, 'count':fee.count})
     return ret
예제 #3
0
파일: match.py 프로젝트: luningcowboy/tuyoo
 def buildRewards(cls, rankRewards):
     ret = []
     for r in rankRewards.rewards:
         if r['count'] > 0:
             name = hallconf.translateAssetKindIdToOld(r['itemId'])
             ret.append({'name':name or '', 'count':r['count']})
     return ret
예제 #4
0
def encodePaddings(paddings):
    ret = []
    for contentItem in paddings:
        rewardName = hallconf.translateAssetKindIdToOld(contentItem.assetKindId)
        if rewardName:
            ret.append((rewardName, contentItem.count))
    return ret
예제 #5
0
def encodeFlipCardMap(flipMap):
    ret = []
    for index, contentItem in flipMap.iteritems():
        rewardName = hallconf.translateAssetKindIdToOld(contentItem.assetKindId)
        if rewardName:
            ret.append((rewardName, contentItem.count, index)) 
    return ret
예제 #6
0
 def buildRewards(self, rankRewards):
     ret = []
     for r in rankRewards.rewards:
         if r.count > 0:
             name = hallconf.translateAssetKindIdToOld(r.assetKindId)
             ret.append({'name':name or '', 'count':r.count, 'itemId':r.assetKindId})
     return ret
예제 #7
0
def get_skill_level_reward(userId, old_level, new_level):
    rewards = dizhuconf.getSkillScoreReward().get(str(new_level),
                                                  {}).get('rewards', None)
    if not rewards:
        return None
    ftlog.debug('get_skill_level_reward->', userId, old_level, new_level,
                rewards)
    sitems = TYContentRegister.decodeFromDict(rewards).getItems()
    ua = hallitem.itemSystem.loadUserAssets(userId)
    aslist = ua.sendContentItemList(DIZHU_GAMEID, sitems, 1, True,
                                    timestamp.getCurrentTimestamp(),
                                    'TASK_MASTER_SCORE_UP_LEVEL_REWARD', 0)
    items = []
    for x in aslist:
        kindId = hallconf.translateAssetKindIdToOld(x[0].kindId)
        akind = hallitem.itemSystem.findAssetKind(x[0].kindId)
        items.append({
            'id': kindId,
            'count': x[1],
            'name': akind.displayName,
            'pic': akind.pic,
        })
    datachangenotify.sendDataChangeNotify(
        HALL_GAMEID, userId, TYAssetUtils.getChangeDataNames(aslist))
    return items
예제 #8
0
def buildRewards(rankRewards):
    ret = []
    for r in rankRewards.rewards:
        if r['count'] > 0:
            name = hallconf.translateAssetKindIdToOld(r['itemId'])
            assetKind = hallitem.itemSystem.findAssetKind(r['itemId'])
            ret.append({'name':name or '', 'count':r['count'], 'url': assetKind.pic if assetKind else ''})
    return ret
예제 #9
0
 def sendGameStartRes(self):
     mo = self.createMsgPackRes('table_call', 'game_start')
     mo.setResult('action', 'game_start')
     mo.setResult('stat', self.table.status.toInfoDict())
     # 发送每个座位的tbc,tbt
     seatTBBoxInfoList = []
     bigRoomId = self.table.bigRoomId
     for p in self.table.players:
         itemId, itemCount = treasurebox.getTreasureRewardItem(bigRoomId)
         if itemId:
             itemId = hallconf.translateAssetKindIdToOld(itemId)
         seatTBBoxInfoList.append({
             'tbc': p.datas['tbc'],
             'tbt': p.datas['tbt'],
             'item': itemId,
             'count': itemCount
         })
     mo.setResult('seattb', seatTBBoxInfoList)
     for p in self.table.players:
         mo.setResult('myCardNote', self.buildCardNote(p.seatIndex))
         router.sendToUser(mo, p.userId)
예제 #10
0
    def buildGameStartResForSeat(self, seat):
        mp = self.buildTableMsgRes('table_call', 'game_start')
        mp.setResult('stat', self.buildTableStatusInfoForSeat(seat))
        seatTBBoxInfoList = []
        for tseat in self.table.seats:
            if tseat.player:
                itemId, itemCount = treasurebox.getTreasureRewardItem(
                    self.gameId, tseat.player.mixConf.get('roomId'))
                if itemId:
                    itemId = hallconf.translateAssetKindIdToOld(itemId)
                tempTbc = tseat.player.datas.get('tbc', 0)
                tempTbt = tseat.player.datas.get('tbt', 0)
                seatTBBoxInfoList.append({
                    'tbc': tempTbc,
                    'tbt': tempTbt,
                    'item': itemId,
                    'count': itemCount
                })

        mp.setResult('seattb', seatTBBoxInfoList)
        mp.setResult('myCardNote', self.buildTableCardNote(seat))
        return mp
예제 #11
0
def doTreasureBox(userId, bigRoomId):
    ftlog.debug('doTreasureBox userId=', userId, 'bigRoomId=', bigRoomId)
    # 判定房间配置
    tbconfiger = dizhuconf.getTreasureBoxInfo(bigRoomId)
    if not tbconfiger or not tbconfiger.get('reward', None):
        ftlog.debug('doTreasureBox->userIds=', userId, 'bigRoomId=', bigRoomId,
                    'not tbox room !')
        return {'ok': 0, 'info': '本房间不支持宝箱,请进入高倍房再使用'}
    # 判定是否可以领取
    tbplaytimes, tblasttime, datas = getUserTbInfo(userId, bigRoomId)
    tbplaycount = tbconfiger['playCount']
    if tblasttime <= 0 or tbplaytimes < tbplaycount:
        ftlog.debug('doTreasureBox->userIds=', userId, 'bigRoomId=', bigRoomId,
                    'can not tbox !')
        return {
            'ok': 0,
            'tbt': min(tbplaytimes, tbplaycount),
            'tbc': tbplaycount,
            'info': tbconfiger['desc']
        }
    # 更新宝箱状态
    datas['tblasttime'] = int(time.time())
    datas['tbplaytimes'] = 0
    _setTbData(userId, datas)

    rewards = tbconfiger['reward']
    content = TYContentRegister.decodeFromDict(rewards)
    sitems = content.getItems()
    # 活动加成
    ditems = _getDoubleInfos(bigRoomId)
    if ditems:
        for si in sitems:
            kindId = si.assetKindId
            mutil = ditems.get(kindId, 0)
            if mutil and mutil > 0:
                si.count = int(si.count * mutil)
    # 发送道具
    # ua = hallitem.itemSystem.loadUserAssets(userId)
    # aslist = ua.sendContentItemList(DIZHU_GAMEID, sitems, 1, True,
    #                                 timestamp.getCurrentTimestamp(), 'TASK_OPEN_TBOX_REWARD', bigRoomId)
    aslist = dizhu_util.sendRewardItems(userId, sitems, '',
                                        'TASK_OPEN_TBOX_REWARD', bigRoomId)
    addmsg = TYAssetUtils.buildContentsString(aslist)
    items = []
    for x in aslist:
        kindId = hallconf.translateAssetKindIdToOld(x[0].kindId)
        items.append({'item': kindId, 'count': x[1], 'total': x[2]})
        if kindId in ['user:coupon', 'COUPON']:
            # 广播事件
            from hall.game import TGHall
            TGHall.getEventBus().publishEvent(
                UserCouponReceiveEvent(
                    HALL_GAMEID, userId, x[1],
                    user_coupon_details.USER_COUPON_TABLE_TBBOX))

    from dizhu.game import TGDizhu
    TGDizhu.getEventBus().publishEvent(
        UserTBoxLotteryEvent(DIZHU_GAMEID, userId))
    datas = {
        'ok': 1,
        'tbt': 0,
        'tbc': tbplaycount,
        'info': '开启宝箱,获得' + addmsg,
        'items': items
    }
    ftlog.debug('doTreasureBox->userIds=', userId, 'bigRoomId=', bigRoomId,
                datas)
    return datas
예제 #12
0
def doTreasureBox(gameId, userId, bigRoomId):
    data = _getTbData(gameId, userId)
    bigRoomId = data['tbroomid']
    if ftlog.is_debug():
        ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId, 'userId=',
                    userId, 'bigRoomId=', bigRoomId)
    # 判定房间配置
    tbconfiger = getTreasureBoxConf(gameId, bigRoomId)
    if not tbconfiger or not tbconfiger.get('reward', None):
        if ftlog.is_debug():
            ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId,
                        'userId=', userId, 'err=', 'NotTBoxRoom')
        return {'ok': 0, 'info': '本房间不支持宝箱,请进入高倍房再使用'}
    # 判定是否可以领取
    tbplaytimes, tblasttime, datas = getUserTbInfo(gameId, userId, bigRoomId)
    tbplaycount = tbconfiger['playCount']
    if tblasttime <= 0 or tbplaytimes < tbplaycount:
        if ftlog.is_debug():
            ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId,
                        'userId=', userId, 'err=', 'CanNotTBox')
        return {
            'ok': 0,
            'tbt': min(tbplaytimes, tbplaycount),
            'tbc': tbplaycount,
            'info': tbconfiger['desc']
        }
    # 更新宝箱状态
    datas['tblasttime'] = int(time.time())
    datas['tbplaytimes'] = 0
    _setTbData(gameId, userId, datas)

    rewards = tbconfiger['reward']
    content = TYContentRegister.decodeFromDict(rewards)
    sitems = content.getItems()
    # 活动加成
    ditems = _getDoubleInfos(gameId, bigRoomId)
    if ditems:
        for si in sitems:
            kindId = si.assetKindId
            mutil = ditems.get(kindId, 0)
            if mutil and mutil > 0:
                si.count = int(si.count * mutil)
    # 发送道具
    ua = hallitem.itemSystem.loadUserAssets(userId)
    aslist = ua.sendContentItemList(gameId, sitems, 1, True,
                                    timestamp.getCurrentTimestamp(),
                                    'TASK_OPEN_TBOX_REWARD', bigRoomId)
    addmsg = TYAssetUtils.buildContentsString(aslist)
    items = []
    for x in aslist:
        kindId = hallconf.translateAssetKindIdToOld(x[0].kindId)
        items.append({'item': kindId, 'count': x[1], 'total': x[2]})

    TYGame(gameId).getEventBus().publishEvent(
        UserTBoxLotteryEvent(gameId, userId))
    data = {
        'ok': 1,
        'tbt': 0,
        'tbc': tbplaycount,
        'info': '开启宝箱,获得' + addmsg,
        'items': items
    }
    if ftlog.is_debug():
        ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId, 'userId=',
                    userId, 'data=', data)
    return data