當前位置: 首頁>>代碼示例>>Python>>正文


Python todotask.TodoTaskHelper類代碼示例

本文整理匯總了Python中hall.entity.todotask.TodoTaskHelper的典型用法代碼示例。如果您正苦於以下問題:Python TodoTaskHelper類的具體用法?Python TodoTaskHelper怎麽用?Python TodoTaskHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TodoTaskHelper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sendBenefits

    def sendBenefits(self, gameId, userId, timestamp=None):
        '''
        發放救濟金
        @return: isSend(True/False), TYUserBenefits
        '''
        if timestamp is None:
            timestamp = pktimestamp.getCurrentTimestamp()
        chip = pkuserchip.getUserChipAll(userId)
        if chip < self._minChip:
            # 用戶金幣低於指定數目時,發放救濟金
            userBenefits = self.loadUserBenefits(gameId, userId, timestamp)
            if not userBenefits.hasLeftTimes():  # 沒有剩餘次數,彈分享引導
                oldtime = gamedata.getGameAttr(userId, HALL_GAMEID, 'relief_share_date')
                if not oldtime or datetime.fromtimestamp(oldtime).date() < datetime.fromtimestamp(timestamp).date():
                    # 每天最多彈一次
                    gamedata.setGameAttr(userId, HALL_GAMEID, 'relief_share_date', timestamp)
                    shareId = hallshare.getShareId('Relieffund', userId, gameId)
                    share = hallshare.findShare(shareId)
                    if share:
                        task = share.buildTodotask(gameId, userId, 'Relieffund')
                        TodoTaskHelper.sendTodoTask(gameId, userId, task)
                return False, userBenefits

            # 發放救濟金
            userBenefits.times += 1
            self._benefitsDao.saveUserBenefitsData(userId, TYUserBenefitsData(userBenefits.times, timestamp))
            self._sendBenefits(gameId, userBenefits)
            # 通知用戶金幣刷新
            datachangenotify.sendDataChangeNotify(gameId, userId, ['udata'])
            return True, userBenefits
        return False, self.loadUserBenefits(gameId, userId, timestamp)
開發者ID:zhaozw,項目名稱:hall37,代碼行數:31,代碼來源:hallbenefits.py

示例2: buildFlipCardResponse

    def buildFlipCardResponse(cls, gameId, userId, roomId, flipIndex,
                              flippedCardList, benefitsSend, userBenefits):
        assert (flipIndex >= 0 and flipIndex <= len(flippedCardList))
        flippedCard = flippedCardList[flipIndex]
        mo = MsgPack()
        mo.setCmd('flip_card_luck')
        mo.setResult('action', 'flip')
        mo.setResult('index', flipIndex)
        mo.setResult('userId', userId)
        mo.setResult('gameId', gameId)

        mo.setResult('cards', cls.encodeFlippedCardList(flippedCardList, flipIndex))
        mo.setResult('desc', cls.getFlippedCardDesc(flippedCard))

        if isinstance(flippedCard, FlippedCardProduct):
            payOrder = TodoTaskPayOrder(flippedCard.product)
            mo.setResult('sub_action', payOrder.toDict())
            mo.setResult('sub_text', hallflipcardluck.getString('product.subText', '立即購買'))

            if benefitsSend:
                mo.setResult('sub_action_ext',
                             TodoTaskHelper.makeTodoTaskBenefitsInfo(benefitsSend, userBenefits).toDict())
            else:
                mo.setResult('sub_action_ext', TodoTaskNoop().toDict())
            mo.setResult('sub_text_ext', hallflipcardluck.getString('product.subTextExt', '取消'))
        elif isinstance(flippedCard, FlippedCardAsset):
            if benefitsSend:
                mo.setResult('sub_action', TodoTaskHelper.makeTodoTaskBenefitsInfo(benefitsSend, userBenefits).toDict())
            else:
                mo.setResult('sub_action', TodoTaskNoop().toStr())
            mo.setResult('sub_text', hallflipcardluck.getString('item.subText', '確定'))
        return mo
開發者ID:zhaozw,項目名稱:hall37,代碼行數:32,代碼來源:flipcardluck_handler.py

示例3: _doChangeNameTry

 def _doChangeNameTry(self, userId, clientId, newName):
     #         renameConf = hallconf.getClientRenameConf(clientId)
     #         if (renameConf
     #             and not renameConf.get('containsSensitive', 1)
     #             and keywords.isContains(newName)):
     #             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
     #             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
     code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
     if ftlog.is_debug():
         ftlog.debug('hallrename._doChangeNameTry->', code, info)
     if code == -3:
         # name not changed !!
         pass
     elif code == -2:
         # 沒有改名卡
         info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
         if hallrename.payOrder:
             product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
             if product:
                 info.setSubCmd(TodoTaskPayOrder(product))
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
     elif code == 0:
         # 改名成功
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed))
     else:
         # SDK改名失敗
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
開發者ID:zhaozw,項目名稱:hall37,代碼行數:27,代碼來源:account_handler.py

示例4: enterFriendTable

def enterFriendTable(userId, gameId, clientId, ftId):
    """進入自建桌"""
    if ftlog.is_debug():
        ftlog.debug('hall_friend_table.enterFriendTable userId:', userId, ' pluginId:', gameId, ' clientId:', clientId,
                    ' ftId:', ftId)

    pluginId = queryFriendTable(ftId)
    if not pluginId:
        TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip('該房間不存在'))
        return

    if TYPlayer.isRobot(userId):
        isValidPluginId = True
    else:
        isValidPluginId = False
        from hall.entity import hallgamelist2
        template = hallgamelist2.getUITemplate(gameId, userId, clientId)
        for version in template.versionList:
            if pluginId == version.game.gameId:
                isValidPluginId = True
                break

    if not isValidPluginId:
        TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip('該安裝包不支持此房間號所對應的玩法'))
        return

    ftlog.info('hall_friend_table.enterFriendTable userId:', userId, ' lead to pluginId:', pluginId)
    pluginId = int(pluginId)
    TYGame(pluginId).enterFriendTable(userId, gameId, clientId, ftId)
開發者ID:zhaozw,項目名稱:hall37,代碼行數:29,代碼來源:hall_friend_table.py

示例5: encodePromote

 def encodePromote(cls, gameId, userId, clientId, promote):
     try:
         todotasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId, promote.promotion.todotasks)
         tempRedPoint = False
         timestamp = pktimestamp.getCurrentTimestamp()
         ftlog.debug('promote.promotion.redPoint =', promote.promotion.redPoint)
         for d in promote.promotion.redPoint:
             if d:
                 tempRedPoint = d.check(HALL_GAMEID, userId, clientId, timestamp)
         ret = {
             'id': promote.promotion.promotionId,
             'loc': promote.position.pos,
             'name': promote.promotion.displayName,
             'url': promote.promotion.url,
             'defaultRes': promote.promotion.defaultRes,
             'animate': promote.promotion.animate,
             'redPoint': tempRedPoint,
             'tasks': TodoTaskHelper.encodeTodoTasks(todotasks)
         }
         if promote.stopTime != -1:
             ret['endtime'] = datetime.fromtimestamp(promote.stopTime).strftime('%Y-%m-%d %H:%M:%S')
         return ret
     except:
         ftlog.error('PromotionHelper.encodePromote gameId=', gameId,
                     'userId=', userId,
                     'clientId=', clientId,
                     'promotionId=', promote.promotion.promotionId)
         return None
開發者ID:zhaozw,項目名稱:hall37,代碼行數:28,代碼來源:promotion_loc_handler.py

示例6: processInvitees

 def processInvitees(self, enterParam, note, invitees, userId, gameId):
     '''
     邀請好友牌桌遊戲
     invitees - 被邀請者
     '''
     if not invitees:
         return
     uds = userdata.getAttrs(userId, ['name'])
     # 檢查是否在線
     for invitee in invitees:
         # invitee - 被邀請者
         state = onlinedata.getOnlineState(invitee)
         if state:
             # 在線,則進行下一步操作
             ids = userdata.getAttrs(invitee, ['name'])
             _, clientVer, _, _ = sessiondata.getClientIdInfo(invitee)
             if clientVer < 3.77:
                 # 版本號小於3.77,則提示升級
                 TodoTaskHelper.sendTodoTask(gameId, invitee,
                                             TodoTaskPopTip(note + ' 請升級至新版本與好友 ' + uds[0] + ' 一起玩耍!'))
                 TodoTaskHelper.sendTodoTask(gameId, userId,
                                             TodoTaskPopTip('您的好友 ' + ids[0] + ' 版本較低,提醒他升級到最新版本一起玩耍吧!'))
             else:
                 # 判斷是否在同一牌桌上
                 if self.isInSameTable(userId, invitee):
                     TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskPopTip('您的好友 ' + ids[0] + ' 正在跟您一起遊戲呢'))
                 else:
                     # 版本號大於3.77,則發送邀請
                     TodoTaskHelper.sendTodoTask(gameId, invitee, TodoTaskInviteToGame(userId, note, enterParam))
         else:
             TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskPopTip('您的好友當前不在線'))
             ftlog.debug('您的好友當前不在線')
開發者ID:zhaozw,項目名稱:hall37,代碼行數:32,代碼來源:friend_handler.py

示例7: doGetTaskReward

    def doGetTaskReward(self, gameId, userId, taskId):
        '''
        獲取活動獎勵
        '''
        try:
            timestamp = pktimestamp.getCurrentTimestamp()
            taskModel = neituiguangtask.newUserTaskSystem.loadTaskModel(userId, timestamp)
            task = taskModel.userTaskUnit.findTask(taskId)
            if not task:
                raise TYBizException(-1, '未知的任務:%s' % (taskId))
            expiresTime = self.calcTaskExpires(userId)
            if timestamp >= expiresTime:
                raise TYBizException(-1, '任務已經過期')
            if not userdata.getAttr(userId, 'bindMobile'):
                conf = neituiguang.getConf()
                TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskBindPhone(conf.pleaseBindPhone, ''))
                return
            assetList = neituiguangtask.newUserTaskSystem.getTaskReward(task, timestamp, 'PROMOTE_TASK', taskId)
            router.sendToUser(self.buildTaskInfoResponse(userId), userId)

            rewardStr = TYAssetUtils.buildContentsString(assetList)
            mo = MsgPack()
            mo.setCmd('promote_info')
            mo.setResult('action', 'get_task_reward')
            mo.setResult('code', 0)
            mo.setResult('info', '恭喜您獲得了%s' % rewardStr)
            router.sendToUser(mo, userId)
        except TYBizException, e:
            router.sendToUser(self.makeErrorResponse('get_task_reward', e.errorCode, e.message), userId)
開發者ID:zhaozw,項目名稱:hall37,代碼行數:29,代碼來源:neituiguang_new_handler.py

示例8: on_praise_friend

    def on_praise_friend(cls, gameId, uid, clientId, mo):
        code = mo.getResult('code', 0)
        # vip = mo.getResult('vip')
        if code == 0:
            friend_uid = int(mo.getResult('friend_uid'))
            nick_name = mo.getResult('nick_name')
            friend_nick_name = mo.getResult('friend_nick_name')
            my_add_charm = mo.getResult('my_add_charm')
            friend_add_charm = mo.getResult('friend_add_charm')
            my_charm = mo.getResult('my_charm')
            friend_charm = mo.getResult('friend_charm')

            msg1 = '給"' + friend_nick_name + '"點讚獲得' + str(my_add_charm) + '個魅力值'
            msg2 = '"' + nick_name + '"給您點讚獲得' + str(friend_add_charm) + '個魅力值'
            from poker.entity.biz.message import message
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(uid), msg1)
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(friend_uid), msg2)
            ftlog.debug('on praise friend.... ' + msg1)
            ftlog.debug('on praise friend.... ' + msg2)

            datachangenotify.sendDataChangeNotify(gameId, uid, 'charm')

            from hall.entity.hallranking import rankingSystem, TYRankingInputTypes
            timestamp = pktimestamp.getCurrentTimestamp()
            rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM,
                                             uid, my_charm, timestamp)
            rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM,
                                             friend_uid, friend_charm, timestamp)
            # 曆史獲讚次數
            history_praised_num = gamedata.incrGameAttr(friend_uid, gameId, 'history_praised_num', 1)
            mo.setResult('friend_history_praised_num', history_praised_num)

        if code != 2:
            return

        from hall.entity.todotask import TodoTaskPayOrder, TodoTaskShowInfo
        from hall.entity.todotask import TodoTaskHelper
        from hall.entity import hallvip, hallitem

        user_vip = hallvip.userVipSystem.getUserVip(uid)
        delta_exp = user_vip.deltaExpToNextLevel()

        product, _ = hallstore.findProductByContains(gameId, uid, clientId,
                                                     ['coin'], None,
                                                     hallitem.ASSET_CHIP_KIND_ID,
                                                     delta_exp * 1000)

        pay_order = TodoTaskPayOrder(product)
        if user_vip == 0:
            msg = '點讚次數已達今日上限,開通VIP可提高點讚次數上限獲得更多福利哦~'
            btnTxt = '開通VIP'
        else:
            msg = '點讚次數已達今日上限,升級VIP等級可提高點讚次數上限獲得更多福利哦~'
            btnTxt = '升級VIP'
        dialog_task = TodoTaskShowInfo(msg, True)
        dialog_task.setSubCmd(pay_order)
        dialog_task.setSubText(btnTxt)
        TodoTaskHelper.sendTodoTask(gameId, uid, [dialog_task])
開發者ID:zhaozw,項目名稱:hall37,代碼行數:58,代碼來源:httpgame.py

示例9: doAssistanceGet

 def doAssistanceGet(self, gameId, userId):
     try:
         _consumeCount, finalCount, sendChip = hallvip.userVipSystem.gainAssistance(gameId, userId)
         if sendChip > 0:
             datachangenotify.sendDataChangeNotify(gameId, userId, 'udata')
         todotask = TodoTaskGoldRain(VipHelper.buildGotAssistanceDesc(finalCount, sendChip))
         TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
     except TYAssistanceChipTooMuchException, e:
         ftlog.warn('ERROR, doAssistanceGet', gameId, userId, e.chip, e.upperChipLimit, e.errorCode, e.message)
開發者ID:zhaozw,項目名稱:hall37,代碼行數:9,代碼來源:vip_handler.py

示例10: onUserVipLevelUp

 def onUserVipLevelUp(self, event):
     if ftlog.is_debug():
         ftlog.debug('VipHandlerImpl.onUserVipLevelUp userId=', event.userId,
                     'gameId=', event.gameId,
                     'oldLevel=', event.oldVipLevel.level,
                     'newLevel=', event.userVip.vipLevel.level)
     todotask = TodoTaskVipLevelUp(VipHelper.buildVipInfo(event.userVip),
                                   self.buildVipLevelUpDesc(event.userId, event.oldVipLevel, event.userVip))
     TodoTaskHelper.sendTodoTask(event.gameId, event.userId, todotask)
開發者ID:zhaozw,項目名稱:hall37,代碼行數:9,代碼來源:vip_handler.py

示例11: doBuyProduct

 def doBuyProduct(self, gameId, userId, prodId):
     try:
         clientId = sessiondata.getClientId(userId)
         orderId = self._makeOrderId(gameId, userId, prodId)
         orderDeliveryResult = hallstore.exchangeProduct(gameId, userId, clientId, orderId, prodId, 1)
         mo = StoreHelper.makeProductDeliveryResponse(userId, orderDeliveryResult)
         router.sendToUser(mo, userId)
     except TYBizException, e:
         TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(e.message))
開發者ID:zhaozw,項目名稱:hall37,代碼行數:9,代碼來源:store_handler.py

示例12: onRoomCreateCustomTable

    def onRoomCreateCustomTable(self, gameId, msg):
        '''在GR處理自建桌邏輯
        '''
        if ftlog.is_debug():
            ftlog.debug("<< |msg", msg, caller=self)

        userId = msg.getParam("userId")
        selectedRoomOptions = msg.getParam("selectedRoomOptions")
        if not selectedRoomOptions:
            return
        customConfVer = msg.getParam("customConfVer")
        if customConfVer != difangConf.getCustomRoomConf(gameId, 'ver'):
            ftlog.warn("onRoomCreateCustomTable confVer error! |msg:", msg, caller=self)
            return
        gameRoundN = selectedRoomOptions.get("gameRoundN")
        if not gameRoundN:
            return
        roomId = msg.getParam("roomId")
        room = gdata.rooms()[roomId]
        clientId = msg.getParam("clientId")

        needRoomCardN = difangConf.getCustomRoomConf(gameId, 'roomCardNCost').get(str(gameRoundN), -1)
        if needRoomCardN == -1:
            tips = difangConf.getCustomRoomConf(difangConf.GAME_ID, 'err_tips')
            tip = tips[self.CREATE_CUSTOM_TABLE_ERR_NO_NOT_ALLOW]
            TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(tip, True))
            ftlog.warn("onRoomCreateCustomTable get needRoomCardN error! |msg:", msg, caller=self)
            self.sendGameCreateCustomTableRes(0, userId)
            return

        if ftlog.is_debug():
            ftlog.debug("|userId, gameId, customConfVer, gameRoundN, needRoomCardN:",
                        userId, gameId, customConfVer, gameRoundN, needRoomCardN, caller=self)

        if needRoomCardN > 0 and not self.isCardEnough(gameId, userId, needRoomCardN, clientId):
            tips = difangConf.getCustomRoomConf(difangConf.GAME_ID, 'err_tips')
            tip = tips[self.CREATE_CUSTOM_TABLE_ERR_NO_NOT_ENOUGH]
            TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(tip, True))
            self.sendGameCreateCustomTableRes(0, userId)
            return

        tableId = room.getIdleTableId()
        if not tableId:
            ftlog.error("there are no idle tables!", "|userId, roomId:", userId, room.roomId)
            return

        ftId = self.assignFriendTableId(gameId, tableId)

        ftlog.info("onRoomCreateCustomTable |userId, tableId, ftId:", userId, tableId, ftId, caller=self)
        self.sendGameCreateCustomTableRes(ftId, userId)
        gamedata.setGameAttr(userId, gameId, "selectedRoomOptions", json.dumps(selectedRoomOptions))
        gamedata.setGameAttr(userId, gameId, "customConfVer", customConfVer)

        shadowRoomId = tableId / 10000
        room.querySitReq(userId, shadowRoomId, tableId, clientId,
                         extParams={"selectedRoomOptions": selectedRoomOptions, "ftId": ftId})
開發者ID:zhaozw,項目名稱:hall37,代碼行數:56,代碼來源:custom_room_plugin.py

示例13: on_ready_invite_friend

 def on_ready_invite_friend(cls, gameId, uid, clientId, mo):
     from hall.entity.todotask import TodoTaskHelper
     code = mo.getResult('code', 0)
     if code != 1:
         return
     from hall.entity.todotask import TodoTaskBindPhoneFriend
     info_ = '請綁定手機,成為正式賬號即可與朋友一起玩!'
     task = TodoTaskBindPhoneFriend(info_, 0)
     task.setSubText('綁定手機')
     TodoTaskHelper.sendTodoTask(gameId, uid, [task])
開發者ID:zhaozw,項目名稱:hall37,代碼行數:10,代碼來源:httpgame.py

示例14: doGameGetMemberReward

 def doGameGetMemberReward(self, userId, gameId, clientId):
     userAssets = hallitem.itemSystem.loadUserAssets(userId)
     userBag = userAssets.getUserBag()
     memberCardItem = userBag.getItemByKindId(hallitem.ITEM_MEMBER_NEW_KIND_ID)
     timestamp = pktimestamp.getCurrentTimestamp()
     if memberCardItem and memberCardItem.canCheckin(timestamp):
         checkinAction = memberCardItem.itemKind.findActionByName('checkin')
         checkinAction.doAction(gameId, userAssets, memberCardItem, timestamp, {})
         datachangenotify.sendDataChangeNotify(gameId, userId, 'free')
         TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskGoldRain('恭喜您領取了今天的會員福利'))
開發者ID:zhaozw,項目名稱:hall37,代碼行數:10,代碼來源:game_handler.py

示例15: sendTodoTaskResponse

 def sendTodoTaskResponse(self, userId, gameId, clientId, isdayfirst):
     '''
     發送當前用戶的TODOtask列表消息
     '''
     ftlog.debug('UtilHelper.sendTodoTaskResponse userId=', userId,
                 'gameId=', gameId,
                 'clientId=', clientId,
                 'isdayfirst=', isdayfirst)
     todotasks = TYGame(gameId).getTodoTasksAfterLogin(userId, gameId, clientId, isdayfirst)
     if todotasks:
         TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
開發者ID:zhaozw,項目名稱:hall37,代碼行數:11,代碼來源:util_helper.py


注:本文中的hall.entity.todotask.TodoTaskHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。