Exemple #1
0
def checkin(userId, gameId, clientId, nowDate=None):
    '''
    用户签到
    @param userId: 用户ID
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)

    if not status.addCheckinDate(nowDate):
        raise AlreadyCheckinException()
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    _saveStatus(status)
    userToGetGift(userId, gameId, 0)

    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(
        MonthCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('checkin userId =', userId, 'gameId =', gameId, 'clientId =',
                clientId)
    return status
Exemple #2
0
def checkin(userId, gameId, clientId, nowDate=None):
    '''
    用户签到
    @param userId: 用户ID
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)

    if not status.addCheckinDate(nowDate):
        raise AlreadyCheckinException()
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    _saveStatus(status)
    userToGetGift(userId, gameId, 0)

    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(MonthCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('checkin userId =', userId
                , 'gameId =', gameId
                , 'clientId =', clientId)
    return status
Exemple #3
0
    def doUserBind_3_3(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId):
            return
        loc = ''
        isReconnect = False
        if isFirstuserInfo:
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
            isReconnect = self._isReconnect(userId, gameId, clientId, loc)
        # # 更新基本信息
        #         halluser.updateUserBaseInfo(userId, clientId, runcmd.getMsgPack())
        # 登录游戏处理
        isdayfirst, _ = halluser.loginGame(userId, gameId, clientId)
        # 发送udata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 0)
        # 发送gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 0, 1)
        # 发送响应消息
        if not isReconnect:
            self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
        # 标记游戏时长开始
        gamedata.incrPlayTime(userId, 0, gameId)
        # BI日志统计
        bireport.userBindUser(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_USER',
                                 userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId)

        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)
Exemple #4
0
def sendReward(gameId, userId, sharePoint):
    from hall.entity import hallitem
    if not sharePoint.reward or not sharePoint.reward.content:
        return None

    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    assetList = userAssets.sendContent(gameId, sharePoint.reward.content, 1, True,
                                       pktimestamp.getCurrentTimestamp(),
                                       'SHARE3_REWARD', sharePoint.pointId)
    ftlog.info('hall_share3.sendReward',
               'gameId=', gameId,
               'userId=', userId,
               'pointId=', sharePoint.pointId,
               'groupId=', sharePoint.groupId,
               'rewards=', [(atup[0].kindId, atup[1]) for atup in assetList])
    changedDataNames = TYAssetUtils.getChangeDataNames(assetList)
    datachangenotify.sendDataChangeNotify(gameId, userId, changedDataNames)
    for atup in assetList:
        if atup[0].kindId == 'user:coupon':
            # 广播事件
            from hall.game import TGHall
            TGHall.getEventBus().publishEvent(
                UserCouponReceiveEvent(HALL_GAMEID, userId, atup[1], user_coupon_details.USER_COUPON_SHARE3))

    return assetList
Exemple #5
0
 def registerListener(cls, ddzeventbus):
     ddzeventbus.subscribe(SkillScoreIncrEvent,
                           DumplingHandler.onSkillScoreIncrease)
     TGHall.getEventBus().subscribe(EventUserLogin,
                                    DumplingHandler.onUserLogin)
     TGHall.getEventBus().subscribe(ChargeNotifyEvent,
                                    DumplingHandler.onChargeNotify)
Exemple #6
0
def sendReward(userId, clientId, timestamp):
    from hall.game import TGHall
    
    for cond, rewardContent in _conf.rewards:
        if cond and not cond.check(HALL_GAMEID, userId, clientId, timestamp):
            continue
        
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        assetList = userAssets.sendContent(HALL_GAMEID,
                                           rewardContent,
                                           1,
                                           True,
                                           timestamp,
                                           'HALL_RP_REWARD',
                                           0)
        ftlog.info('hall_red_packet_main.sendReward',
                   'userId=', userId,
                   'assets=', [(atup[0].kindId, atup[1]) for atup in assetList])
        changed = TYAssetUtils.getChangeDataNames(assetList)
        datachangenotify.sendDataChangeNotify(HALL_GAMEID, userId, changed)
        count = TYAssetUtils.getAssetCount(assetList, hallitem.ASSET_COUPON_KIND_ID)
        if count > 0:
            TGHall.getEventBus().publishEvent(UserReceivedCouponEvent(HALL_GAMEID,
                                                                      userId,
                                                                      count,
                                                                      hall_red_packet_const.RP_SOURCE_RP_MAIN))
        return assetList
    return None
Exemple #7
0
    def registerEvents(cls, eventBus):
        ftlog.debug("choujiang360 register events")
        for event in cls.eventset:
            eventBus.subscribe(event, cls.handleEvent)

        from hall.game import TGHall
        TGHall.getEventBus().subscribe(EventUserLogin, cls.handleEvent)
def initBehaviourReward():
    from dizhu.game import TGDizhu
    TGDizhu.getEventBus().subscribe(UserTablePlayEvent,
                                    _sendUserBehaviourReward)

    from hall.game import TGHall
    TGHall.getEventBus().subscribe(EventUserLogin, _onUnExpectedUserLogin)
Exemple #9
0
 def initialize(cls):
     from dizhu.game import TGDizhu
     TGDizhu.getEventBus().subscribe(MatchWinloseEvent, cls.onMatchWinlose)
     TGDizhu.getEventBus().subscribe(UserTableWinloseEvent, cls.onTableWinlose)
     TGHall.getEventBus().subscribe(TYOrderDeliveryEvent, cls.onOrderDelivery)
     pkeventbus.globalEventBus.subscribe(EventConfigure, cls._onConfChanged)
     cls._reloadConf()
Exemple #10
0
    def gainUserVipGift(self, gameId, userId, level):
        '''
        领取level级别vip的礼品
        @param userId: 要领取礼品的用户ID
        @param level: 要领取的礼品的vip级别
        @return: userVip, list<TYVipGiftState>, TYUserVipGotGiftResult
        '''
        userVip = self.getUserVip(userId)
        if level > userVip.vipLevel.level:
            raise TYVipLevelNotGotException(level, userVip.vipLevel.level)

        vipLevel = self._vipSystem.findVipLevelByLevel(level)
        if not vipLevel:
            raise TYVipLevelNotFoundException(level)

        if not vipLevel.giftContent:
            raise TYVipLevelNoGiftException(level)

        vipGiftStatus = self._loadUserVipGiftStatus(userId)
        giftState = vipGiftStatus.getGiftStateByLevel(level)
        if giftState and giftState.state == TYVipGiftState.STATE_GOT:
            raise TYVipLevelGiftAlreadyGotException(level)

        giftState = TYVipGiftState(vipLevel, TYVipGiftState.STATE_GOT)
        vipGiftStatus.setGiftState(giftState.level, giftState)
        self._saveVipGiftStates(userId, vipGiftStatus)

        # 发奖
        assetList = self._sendGiftContent(gameId, userVip, vipLevel)
        datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames(assetList))
        gotGiftResult = TYUserVipGotGiftResult(userVip, giftState, assetList)
        TGHall.getEventBus().publishEvent(TYUserVipGotGiftEvent(gameId, userId, gotGiftResult))
        return userVip, self._fillAndToList(userVip, vipGiftStatus), gotGiftResult
Exemple #11
0
    def doUserBind_3_3(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId):
            return
        loc = ''
        isReconnect = False
        if isFirstuserInfo:
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
            isReconnect = self._isReconnect(userId, gameId, clientId, loc)
        # # 更新基本信息
        #         halluser.updateUserBaseInfo(userId, clientId, runcmd.getMsgPack())
        # 登录游戏处理
        isdayfirst, _ = halluser.loginGame(userId, gameId, clientId)
        # 发送udata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 0)
        # 发送gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 0, 1)
        # 发送响应消息
        if not isReconnect:
            self.helper.sendTodoTaskResponse(userId, gameId, clientId,
                                             isdayfirst)
        # 标记游戏时长开始
        gamedata.incrPlayTime(userId, 0, gameId)
        # BI日志统计
        bireport.userBindUser(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_USER', userId, gameId, 0, 0, 0, 0, 0, 0,
                                 [], clientId)

        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)
    def _sendRewards(self, status, task, timestamp):
        from hall.game import TGHall

        userAssets = hallitem.itemSystem.loadUserAssets(status.userId)
        assetList = userAssets.sendContent(self.gameId,
                                           task.taskKind.rewardContent, 1,
                                           True, timestamp,
                                           'HALL_RP_TASK_REWARD', task.kindId)
        ftlog.info('RPTaskSystem._sendRewards', 'gameId=', self.gameId,
                   'userId=', status.userId, 'kindId=', task.kindId, 'assets=',
                   [(atup[0].kindId, atup[1]) for atup in assetList])
        changed = TYAssetUtils.getChangeDataNames(assetList)
        datachangenotify.sendDataChangeNotify(self.gameId, status.userId,
                                              changed)

        if task.taskKind.rewardMail:
            contents = TYAssetUtils.buildContentsString(assetList)
            mail = strutil.replaceParams(task.taskKind.rewardMail,
                                         {'rewardContent': contents})
            pkmessage.sendPrivate(HALL_GAMEID, status.userId, 0, mail)

        TGHall.getEventBus().publishEvent(
            UserRedPacketTaskRewardEvent(status.userId, HALL_GAMEID,
                                         task.taskKind, assetList))

        couponCount = TYAssetUtils.getAssetCount(assetList,
                                                 hallitem.ASSET_COUPON_KIND_ID)
        if couponCount > 0:
            TGHall.getEventBus().publishEvent(
                UserReceivedCouponEvent(
                    HALL_GAMEID, status.userId, couponCount,
                    hall_red_packet_const.RP_SOURCE_RP_TASK))
    def handleRequest(self, userId, clientId, action, msg):
        if action == self.ACTION_SHARE_CHARM_RANK_LIST:
            return self.getRankRewardList(userId)
        elif action == self.ACTION_SHARE_CHARM_REWARD:
            # 更改用户领奖状态
            issue = calculateLastIssue(self.settleDayOrWeek)
            realRank = getUserRealRank(userId, self.actId, issue)
            rankRewardItem = self.getUserRankRewardItem(userId, realRank)
            userData = UserShareCharmData(userId).loadUserData(self.actId)
            issueData = userData.getIssueData(issue)

            if not issueData:
                raise ActivityWxException(-6, '您没有参与%s活动哦~' % issue)

            if issueData.state == SHARE_CHARM_REWARD_STATE_GOT:
                raise ActivityWxException(-4, '您已领取奖励哦~')
            # 发奖
            if rankRewardItem:
                userData.updateState(self.actId, issue)
                rewards = rankRewardItem.rewards
                rewardsItems = TYContentItem.decodeList(rewards)
                dizhu_util.sendRewardItems(userId, rewardsItems, '',
                                           'ACT_WX_SHARE_CHARM', self.intActId)
                for reward in rewards:
                    if reward['itemId'] == 'user:coupon':
                        from hall.game import TGHall
                        TGHall.getEventBus().publishEvent(
                            UserCouponReceiveEvent(
                                HALL_GAMEID, userId, reward['count'],
                                user_coupon_details.USER_COUPON_SHARE_CHARM))
                return rewards
            raise ActivityWxException(-5, '您没有奖励可领取哦~')
        return None
Exemple #14
0
    def doGetInviteRewardAll(cls, userId):
        status = loadStatus(userId)
        inviteeRewardList = status.inviteeRewardList
        rewardsList = []
        bigReward = None
        save = False
        for index, rewardState in enumerate(inviteeRewardList):
            if rewardState.rewardState == REWARD_STATE_IDEAL:
                rewardState.rewardState = REWARD_STATE_RECEIVED
                save = True
                r = getSimpleInviteRewardByIndex(index)
                if r:
                    rewardsList.append(r)
        if rewardsList:
            contentItems = TYContentItem.decodeList(rewardsList)
            assetList = dizhu_util.sendRewardItems(userId, contentItems, '', 'DIZHU_QIANDAO_REWARD', 0)

        if len(inviteeRewardList) >= len(getSimpleInviteRewardsConf()):
            bigReward = getSimpleInviteBigReward(userId)
            if bigReward:
                contentItems = TYContentItem.decodeList([bigReward])
                assetList = dizhu_util.sendRewardItems(userId, contentItems, '', 'DIZHU_QIANDAO_REWARD', 0)
                if bigReward.get('itemId') == 'user:coupon':
                    TGHall.getEventBus().publishEvent(UserCouponReceiveEvent(9999, userId, bigReward['count'],
                                                                         user_coupon_details.USER_COUPON_INVITE))
                status.bigRewardState = REWARD_STATE_RECEIVED
                save = True
                conf = getSimpleInviteConf()
                if conf.get('switch'):
                    gamedata.setGameAttr(userId, DIZHU_GAMEID, 'firstBigRewards', 1)
        if save:
            saveStatus(status)
        return rewardsList, bigReward
def initialize():
    ftlog.info("newfish chest_system initialize begin")
    global _inited
    if not _inited:
        _inited = True
        from hall.game import TGHall
        TGHall.getEventBus().subscribe(TYOpenItemEvent, _triggerTYOpenItemEvent)
    ftlog.info("newfish chest_system initialize end")
Exemple #16
0
def supplementCheckin(userId, gameId, clientId, supplementDate=None, nowDate=None):
    '''
    用户补签
    @param userId: 用户ID
    @param supDate: 补签日期,如果为None则表示补签最近一天
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    # 检查最大补签数
    if status.supplementCheckinCount >= getConf().get("maxSupplementCheckinCount"):
        raise SupplementOverException()

    if supplementDate:
        if not pktimestamp.isSameMonth(supplementDate, status.curDate):
            raise InvalidSupplementDateException()
    else:
        holeDateList = status._getHoleDateList()
        if not holeDateList:
            raise AlreadyCheckinException()
        supplementDate = holeDateList[0]

    if not status.addSupplementCheckinDate(supplementDate):
        raise AlreadyCheckinException()

    # 减少抽奖卡,消耗成功之后,发放奖励。
    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    timestamp = pktimestamp.getCurrentTimestamp()

    _, consumeCount, _final = userAssets.consumeAsset(gameId, 'item:4168', 1,
                                                      timestamp, 'HALL_CHECKIN', 0)
    if consumeCount < 1:
        result = {}
        result["lessCard"] = "您的补签卡不足"
        return 1, result
    datachangenotify.sendDataChangeNotify(gameId, userId, 'item')
    _saveStatus(status)

    userToGetGift(userId, gameId, state=0)
    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(MonthSupCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('supplementCheckin userId =', userId
                , 'gameId =', gameId
                , 'clientId =', clientId
                , 'noeDate =', nowDate)
    return 0, status
Exemple #17
0
def _initialize():
    ftlog.debug('neituiguang initialize begin')
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(EventUserLogin, _onUserLogin)
    ftlog.debug('neituiguang initialize end')
Exemple #18
0
def _initialize():
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(EventUserLogin, _onUserLogin)
        TGHall.getEventBus().subscribe(UserRedPacketTaskRewardEvent,
                                       _onUserRedPacketTaskReward)
def _initialize():
    global _inited
    if not _inited:
        _inited = True
        TGHall.getEventBus().subscribe(
            EventUserLogin, DizhuSegmentRewardsHelper.processEnterGame)
        if ftlog.is_debug():
            ftlog.debug(
                'DizhuSegmentRewardsHelper.processUserTableRewards inited ok.')
Exemple #20
0
def _initialize():
    ftlog.debug('neituiguang initialize begin')
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(EventUserLogin, _onUserLogin)
    ftlog.debug('neituiguang initialize end')
Exemple #21
0
def sendModuleTipEvent(userId, gameId, moduleName, count):
    '''
    推送勋章状态变更事件
    @param count:当前用户未领取勋章数 
    '''

    tip = ModuleTipEvent(userId, gameId, moduleName, count)
    TGHall.getEventBus().publishEvent(tip)
    ftlog.debug('sendModuleTipEvent name=', moduleName, 'gameId=', gameId, 'userId=', userId, 'count=', count)
def initialize():
    ftlog.info("newfish invite_system initialize begin")
    global _inited
    if not _inited:
        _inited = True
        from hall.entity.hallevent import EventAfterUserLogin
        from hall.game import TGHall
        TGHall.getEventBus().subscribe(EventAfterUserLogin, _triggerUserLoginEvent)
    ftlog.info("newfish invite_system initialize end")
Exemple #23
0
def sendModuleTipEvent(userId, gameId, moduleName, count):
    '''
    推送勋章状态变更事件
    @param count:当前用户未领取勋章数 
    '''

    tip = ModuleTipEvent(userId, gameId, moduleName, count)
    TGHall.getEventBus().publishEvent(tip)
    ftlog.debug('sendModuleTipEvent name=', moduleName,  'gameId=', gameId, 'userId=', userId, 'count=', count)
Exemple #24
0
def _initialize():
    ftlog.debug('hallcoupon initialize begin')
    from hall.game import TGHall
    global _inited
    global flipCard
    if not _inited:
        _inited = True
        TGHall.getEventBus().subscribe(EventUserLogin, couponService.onUserLogin)
        _reloadConf()
    ftlog.debug('hallcoupon initialize end')
Exemple #25
0
def _initialize():
    ftlog.debug('hallpromote initialize begin')
    from hall.game import TGHall
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(TYOrderDeliveryEvent, _onOrderDelivery)
    ftlog.debug('hallpromote initialize end')
Exemple #26
0
 def doGameEnter(self, userId, gameId, clientId):
     isdayfirst, iscreate = halluser.loginGame(userId, gameId, clientId)
     self.helper.sendUserInfoResponse(userId, gameId, clientId, '', 0, 1)
     self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
     # BI日志统计
     bireport.userGameEnter(gameId, userId, clientId)
     bireport.reportGameEvent('BIND_GAME',
                              userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId, iscreate)
     evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
     TGHall.getEventBus().publishEvent(evt)
Exemple #27
0
def _initialize():
    ftlog.debug('hallmoduletip initialize begin')
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        pkeventbus.globalEventBus.subscribe(ModuleTipEvent, handleEvent)
        TGHall.getEventBus().subscribe(ModuleTipEvent, handleEvent)
    ftlog.debug('hallmoduletip initialize end')
Exemple #28
0
def _initialize():
    ftlog.debug('hallmoduletip initialize begin')
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        pkeventbus.globalEventBus.subscribe(ModuleTipEvent, handleEvent)
        TGHall.getEventBus().subscribe(ModuleTipEvent, handleEvent)
    ftlog.debug('hallmoduletip initialize end')
Exemple #29
0
 def doChargeNotify(self, gameId, userId, prodId, rmbs, diamonds, clientId):
     if diamonds > 0:
         hallvip.userVipSystem.addUserVipExp(gameId, userId, diamonds, 'BUY_PRODUCT',
                                             pokerconf.productIdToNumber(prodId))
     TGHall.getEventBus().publishEvent(ChargeNotifyEvent(userId, gameId, rmbs, diamonds, prodId, clientId))
     mo = MsgPack()
     mo.setCmd('charge_notify')
     mo.setResult('userId', userId)
     mo.setResult('gameId', gameId)
     return mo
Exemple #30
0
def _initialize():
    from hall.game import TGHall
    ftlog.debug('buy_send_gift initialize begin')
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        TGHall.getEventBus().subscribe(TYOrderDeliveryEvent, _onOrderDelivery)
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
    ftlog.debug('buy_send_gift initialize end')
Exemple #31
0
def _onChargeNotify(event):
    ftlog.info('hallstore._onChargeNotify gameId=', event.gameId,
               'userId=', event.userId,
               'diamonds=', event.diamonds,
               'rmbs=', event.rmbs,
               'firstRechargeThreshold=', storeSystem.firstRechargeThreshold)
    if event.diamonds >= storeSystem.firstRechargeThreshold:
        count = pkgamedata.incrGameAttr(event.userId, HALL_GAMEID, 'first_recharge', 1)
        if count == 1:
            TGHall.getEventBus().publishEvent(UserFirstRecharedEvent(HALL_GAMEID, event.userId))
            datachangenotify.sendDataChangeNotify(HALL_GAMEID, event.userId, 'promotion_loc')
Exemple #32
0
def _initialize():
    ftlog.debug('activity initialize begin')
    global activitySystem
    global _inited
    if not _inited:
        _inited = True
        _registerClasses()
        activitySystem = TYActivitySystemImpl(TYActivityDaoImpl())
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(OnLineGameChangedEvent, handleActivityStateChangedEvent)
    ftlog.debug('activity initialize end')
Exemple #33
0
def _onChargeNotify(event):
    ftlog.info('hallstore._onChargeNotify gameId=', event.gameId, 'userId=',
               event.userId, 'diamonds=', event.diamonds, 'rmbs=', event.rmbs,
               'firstRechargeThreshold=', storeSystem.firstRechargeThreshold)
    if event.diamonds >= storeSystem.firstRechargeThreshold:
        count = pkgamedata.incrGameAttr(event.userId, HALL_GAMEID,
                                        'first_recharge', 1)
        if count == 1:
            TGHall.getEventBus().publishEvent(
                UserFirstRecharedEvent(HALL_GAMEID, event.userId))
            datachangenotify.sendDataChangeNotify(HALL_GAMEID, event.userId,
                                                  'promotion_loc')
def _initialize():
    from hall.game import TGHall
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(UserReceivedCouponEvent,
                                       _onUserReceivedCouponEvent)

        if ftlog.is_debug():
            ftlog.debug('hall_red_packet_exchange._initialized ok')
Exemple #35
0
 def doChargeNotify(self, gameId, userId, prodId, rmbs, diamonds, clientId):
     if diamonds > 0:
         hallvip.userVipSystem.addUserVipExp(
             gameId, userId, diamonds, 'BUY_PRODUCT',
             pokerconf.productIdToNumber(prodId))
     TGHall.getEventBus().publishEvent(
         ChargeNotifyEvent(userId, gameId, rmbs, diamonds, prodId,
                           clientId))
     mo = MsgPack()
     mo.setCmd('charge_notify')
     mo.setResult('userId', userId)
     mo.setResult('gameId', gameId)
     return mo
Exemple #36
0
def _initialize():
    ftlog.debug('activity initialize begin')
    global activitySystem
    global _inited
    if not _inited:
        _inited = True
        _registerClasses()
        activitySystem = TYActivitySystemImpl(TYActivityDaoImpl())
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(OnLineGameChangedEvent,
                                       handleActivityStateChangedEvent)
    ftlog.debug('activity initialize end')
Exemple #37
0
    def onMatchWinlose(cls, event):
        ftlog.debug("DdzMatchScore.onMatchWinlose: event=", event)
        if cls.isOutdate():
            return ftlog.debug("DdzMatchScore.onMatchWinlose: isOutdate=True")

        userId = event.userId
        roomId = event.matchId
        clientId = sessiondata.getClientId(event.userId)
        # ftlog.debug("DdzMatchScore.onMatchWinlose: event=", event, "event.matchId=", event.matchId, "event.userId=", event.userId, "score=", score)

        gameover = GameOverEvent(userId, DIZHU_GAMEID, clientId, roomId, 0, 0, 0)
        TGHall.getEventBus().publishEvent(gameover)
        ftlog.debug("DdzMatchScore.onMatchWinlose: userId=", event.userId, "gameoverevent=", gameover.__dict__)
Exemple #38
0
def addUserVipExp(gameId,
                  userId,
                  toAddExp,
                  eventId,
                  intEventParam,
                  productId,
                  rmbs=-1,
                  isAddVipExp=True):
    """
    增加VIP经验值
    """
    rmbs = int(rmbs)
    if rmbs == -1 and toAddExp >= 10:
        rmbs = toAddExp / 10
    if isAddVipExp:
        hallvip.userVipSystem.addUserVipExp(gameId, userId, toAddExp, eventId,
                                            intEventParam)
    else:  # 自己处理vip升级事件.
        from hall.game import TGHall
        from hall.entity.hallvip import TYUserVipLevelUpEvent
        vipExp = hallvip.userVipSystem.getUserVip(userId).vipExp
        oldVipLevel = hallvip.vipSystem.findVipLevelByVipExp(vipExp - toAddExp)
        userVip = hallvip.userVipSystem.getUserVip(userId)
        if oldVipLevel.level != userVip.vipLevel.level:
            lv_event = TYUserVipLevelUpEvent(FISH_GAMEID, userId, oldVipLevel,
                                             userVip, [], 0, 0)
            TGHall.getEventBus().publishEvent(lv_event)
    # vip经验发生变化.
    from newfish.game import TGFish
    event = UserVipExpChangeEvent(userId, gameId, toAddExp)
    TGFish.getEventBus().publishEvent(event)
    if ftlog.is_debug():
        ftlog.debug("addUserVipExp----->event", gameId, userId, toAddExp,
                    eventId, intEventParam, rmbs, isAddVipExp)
    # 上报购买商品事件.
    loginDays = gamedata.getGameAttrInt(userId, FISH_GAMEID,
                                        GameData.loginDays)
    userLevel = gamedata.getGameAttrInt(userId, FISH_GAMEID, GameData.level)
    isIn, roomId, tableId, _ = util.isInFishTable(userId)
    if isIn:
        from newfish.servers.table.rpc import table_remote
        table_remote.buyProduct(roomId, tableId, userId, intEventParam,
                                userLevel, loginDays)
    else:
        from poker.entity.biz import bireport
        userChip = userchip.getUserChipAll(userId)
        bireport.reportGameEvent("BI_NFISH_BUY_PRODUCT", userId, FISH_GAMEID,
                                 roomId, intEventParam, userLevel, 0, 0, 0, [],
                                 util.getClientId(userId), loginDays, userChip)
        # ftlog.debug("BI_NFISH_BUY_PRODUCT", userId, roomId, intEventParam, userLevel, util.getClientId(userId), userChip)
    updateUserDataByRecharge(userId, productId, rmbs)
Exemple #39
0
 def testEvents(self):
     events = [
               [EventUserLogin(self.userId, self.gameId, True, True, self.clientId), 1],
               #[GameOverEvent(self.userId, 6, self.clientId, 60011001, 600110010001, 0, 0, 0, 0), 10]
             ]
     for event, count in events:
         for _ in xrange(count):
             TGHall.getEventBus().publishEvent(event)
     
     self.assertEqual(hall_yyb_gifts.gainUserGift(self.userId, 99990006, self.timestamp)[0], hall_yyb_gifts.STATE_GAIN)
     self.assertEqual(hall_yyb_gifts.gainUserGift(self.userId, 99990006, self.timestamp)[0], hall_yyb_gifts.STATE_ALREADY_GAIN)
     
     self.assertEqual(hall_yyb_gifts.gainUserGift(self.userId, 99990010, self.timestamp)[0], hall_yyb_gifts.STATE_GAIN)
     self.assertEqual(hall_yyb_gifts.gainUserGift(self.userId, 99990010, self.timestamp)[0], hall_yyb_gifts.STATE_ALREADY_GAIN)
Exemple #40
0
def initialize():
    ftlog.debug("newfish daily_gift initialize begin")
    global _inited
    if not _inited:
        _inited = True
        from poker.entity.events.tyevent import ChargeNotifyEvent
        from hall.game import TGHall
        from newfish.game import TGFish
        from newfish.entity.event import NFChargeNotifyEvent
        TGHall.getEventBus().subscribe(ChargeNotifyEvent,
                                       _triggerChargeNotifyEvent)
        TGFish.getEventBus().subscribe(NFChargeNotifyEvent,
                                       _triggerChargeNotifyEvent)
    ftlog.debug("newfish daily_gift initialize end")
def _initialize(isCenter):
    ftlog.debug('dizhu_score_ranking._initialize begin')
    global _inited
    if not _inited:
        _inited = True
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        subscribeScoreRankList()
        TGHall.getEventBus().subscribe(TYOpenItemEvent, _onOpenItemEvent)
        if isCenter:
            from poker.entity.events.tyeventbus import globalEventBus
            globalEventBus.subscribe(EventHeartBeat, onTimer)

    ftlog.debug('dizhu_score_ranking._initialize end')
Exemple #42
0
def doGoldLottery(userId, gameId, clientId, number):
    '''
        金盘抽奖
    '''
    if number <= 0 or number > 50:
        ftlog.error('doGoldLottery number best be > 0 or <= 50, the msg is fake')
        return

    if ftlog.is_debug():
        ftlog.debug('hallroulette.doGoldLottery userId:', userId,
                    ' gameId:', gameId,
                    ' clientId:', clientId,
                    ' number:', number
                    )

    # 减少钻石
    result = {}
    count = -(number * 20)
    trueDelta, _finalCount = userchip.incrDiamond(userId, gameId, count, daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                  'HALL_ROULETTE', 0, 0)
    if not trueDelta:
        # 消费失败 
        return toShop()
    # 将抽奖数进行存储,满足bigRewardNumber,使用大奖概率,否则使用小奖概率
    addBigRewardToPool(userId, gameId, clientId, number)
    # 抽奖
    items = []
    for _num in range(0, number):
        items.append(doRouletteLottery(userId, gameId, clientId))

    result['items'] = items
    # 对抽奖进行修改,连抽的话进行统一的数据库操作
    sendGiftsToUser(userId, gameId, clientId, items)
    # 更新钻石
    datachangenotify.sendDataChangeNotify(gameId, userId, ['udata'])
    # 抽奖成功,进行小兵的下发
    for _ in range(0, number):
        daobase.executeMixCmd('RPUSH', CURKEY, userId)

    # 统计需求
    ftlog.hinfo('doGoldLottery.userId=', userId,
                'gameId=', gameId,
                'clientId=', clientId,
                'number=', number,
                'rouletteType=', 2,
                'rewardItem=', items)
    TGHall.getEventBus().publishEvent(TYEventRouletteDiamond(userId, gameId, number))
    return result
Exemple #43
0
def _initialize():
    ftlog.debug('store initialize begin')
    from hall.entity.hallusercond import UserConditionRegister
    global storeSystem
    global _inited
    if not _inited:
        _inited = True
        storeSystem = TYStoreSystemImpl(hallitem.itemSystem, TYOrderDaoImpl(),
                                        TYClientStoreConfImpl(), TGHall.getEventBus(),
                                        UserConditionRegister)
        _registerClasses()
        _reloadConf()
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)
        TGHall.getEventBus().subscribe(ChargeNotifyEvent, _onChargeNotify)
        TGHall.getEventBus().subscribe(TYOrderDeliveryEvent, _onOrderDelivery)
    ftlog.debug('store initialize end')
Exemple #44
0
def setInviter(status, inviter):
    '''
    设置userId的推荐人
    @param userId: 被推荐人
    @param inviterUserId: 推荐人是谁
    @return: status
    '''
    # 确认能成为被推荐人
    ensureCanBeInvitee(status, inviter)

    status._setInviter(inviter)
    _saveStatus(status)

    # 设置好inviter后需要设置新手任务
    ftlog.info('neituiguang.setInviter userId=', status.userId,
               'inviter=', inviter)
    TGHall.getEventBus().publishEvent(NeituiguangSetInviterEvent(HALL_GAMEID, status.userId, inviter))
Exemple #45
0
def _initialize(isCenter):
    from hall.game import TGHall
    ftlog.debug('Ranking initialize begin', isCenter)
    global rankingSystem
    global _inited
    if not _inited:
        _inited = True
        rankingSystem = TYRankingSystemImpl(TYRankingUserScoreInfoDaoImpl(), TYRankingDaoImpl(), RankRewardSender())
        _registerClasses()
        _reloadConf()
        TGHall.getEventBus().subscribe(EventUserLogin, _onUserLogin)
        pkeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged)

        if isCenter:
            from poker.entity.events.tyeventbus import globalEventBus
            globalEventBus.subscribe(EventHeartBeat, onTimer)

    ftlog.debug('Ranking initialize end')
Exemple #46
0
def sendReward(gameId, userId, share, shareLoc):
    from hall.entity import hallitem
    if not share.rewardContent:
        return None

    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    assetList = userAssets.sendContent(gameId, share.rewardContent, 1, True,
                                       pktimestamp.getCurrentTimestamp(),
                                       'SHARE_REWARD', share.shareId)
    ftlog.info('hallshare.sendReward gameId=', gameId,
               'userId=', userId,
               'shareId=', share.shareId,
               'shareLoc=', shareLoc,
               'rewards=', [(atup[0].kindId, atup[1]) for atup in assetList])
    changedDataNames = TYAssetUtils.getChangeDataNames(assetList)
    datachangenotify.sendDataChangeNotify(gameId, userId, changedDataNames)
    TGHall.getEventBus().publishEvent(HallShareGetRewardEvent(gameId, userId, assetList))

    return assetList
Exemple #47
0
 def dosendChipToUser(self, userId, gameId, clientId):
     # 添加绑定
     nowBindPone = gamedata.getGameAttr(userId, gameId, 'bindReward1')
     if not nowBindPone or nowBindPone < 1:
         gamedata.setGameAttr(userId, gameId, 'bindReward1', 1)
     else:
         from poker.entity.biz.exceptions import TYBizException
         raise TYBizException(-1, '重复绑定')
     # 发金币
     ftlog.info('cmd game action bindPhone userId =', userId)
     from poker.entity.dao import userchip, daoconst
     userchip.incrChip(userId, gameId, 10000, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'BIND_PHONE', 0, clientId)
     datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
     # 消息推送
     from poker.entity.biz.message import message
     msg = '恭喜您绑定手机成功,赠送您10000金币'
     message.send(gameId, message.MESSAGE_TYPE_PRIVATE, userId, msg)
     # 更新小红点
     datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc'])
     TGHall.getEventBus().publishEvent(UserBindPhoneEvent(userId, gameId))
Exemple #48
0
    def addUserVipExp(self, gameId, userId, toAddExp, eventId, intEventParam):
        '''
        增加vip经验值
        @param gameId: 在那个gameId中增加的经验值,用于统计 
        @param toAddExp: 要增加的经验值
        @param eventId: 导致经验值增加的事件ID
        @param intEventParam: eventId相关参数
        @return: TYUserVip
        '''
        assert (toAddExp >= 0)
        vipExp = self._vipDao.incrVipExp(userId, toAddExp)
        oldVipExp = vipExp - toAddExp
        oldVipLevel = self._vipSystem.findVipLevelByVipExp(oldVipExp)
        newVipLevel = self._vipSystem.findVipLevelByVipExp(vipExp)

        ftlog.debug('TYUserVipSystemImpl.addUserVipExp gameId=', gameId, 'userId=', userId,
                    'oldExp=', oldVipExp, 'newExp=', vipExp,
                    'oldLevel=', oldVipLevel.level, 'newLevel=', newVipLevel.level)

        userVip = TYUserVip(userId, vipExp, newVipLevel)
        if oldVipLevel.level != newVipLevel.level:
            nextVipLevel = oldVipLevel.nextVipLevel
            assetList = []
            while (nextVipLevel and nextVipLevel.level <= newVipLevel.level):
                subContentList = self._sendRewardContent(gameId, userVip, nextVipLevel)
                if subContentList:
                    assetList.extend(subContentList)
                nextVipLevel = nextVipLevel.nextVipLevel
            changeDataNames = TYAssetUtils.getChangeDataNames(assetList)
            changeDataNames.add('vip')
            changeDataNames.add('decoration')
            datachangenotify.sendDataChangeNotify(gameId, userId, changeDataNames)
            TGHall.getEventBus().publishEvent(TYUserVipLevelUpEvent(gameId, userId, oldVipLevel,
                                                                    userVip, assetList,
                                                                    eventId, intEventParam))
        else:
            datachangenotify.sendDataChangeNotify(gameId, userId, 'vip')
            TGHall.getEventBus().publishEvent(TYUserVipExpChangedEvent(gameId, userId, userVip, oldVipExp))
        return userVip
Exemple #49
0
def addInvitee(status, invitee, accepted):
    '''
    给userId的推荐列表增加inviteeUserId
    @param userId: 给哪个用户增加
    @param inviteeUserId: 被推荐人
    @return: status
    '''
    # 确认可以成为推荐人
    ensureCanBeInviter(status, invitee)
    if status.inviteeCount + 1 > MAX_INVITEE:
        ftlog.info('neituiguang.addInvitee overCountLimit userId=', status.userId,
                   'invitee=', invitee,
                   'inviteeCount=', status.inviteeCount,
                   'MAX_INVITEE=', MAX_INVITEE)
        return
    # 添加被推荐人
    status._addInvitee(invitee, accepted)
    _saveStatus(status)
    ftlog.info('neituiguang.addInvitee userId=', status.userId,
               'invitee=', invitee,
               'accepted=', accepted)
    TGHall.getEventBus().publishEvent(NeituiguangAddInviteeEvent(HALL_GAMEID, status.userId, invitee))
Exemple #50
0
    def gainCheckinReward(self, gameId, userId, timestamp=None, actionType=0):
        if timestamp is None:
            timestamp = pktimestamp.getCurrentTimestamp()
        checkinOk, checkinDays = self.checkin(gameId, userId, timestamp)
        if ftlog.is_debug():
            ftlog.debug('TYDailyCheckin.gainCheckinReward gameId=', gameId,
                        'userId=', userId,
                        'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'),
                        'checkinOk=', checkinOk,
                        'checkinDays=', checkinDays)

        if not checkinOk:
            return checkinOk, [], checkinDays
        # 发送奖励
        rewardContent = self.getRewardContent(checkinDays)

        ebus = TGHall.getEventBus()
        ebus.publishEvent(TYDailyCheckinRewardEvent(gameId, userId, rewardContent, actionType))

        if not rewardContent:
            return checkinOk, [], checkinDays

        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        assetList = userAssets.sendContent(gameId, rewardContent, 1, True,
                                           timestamp, 'NSLOGIN_REWARD2', checkinDays)
        contents = TYAssetUtils.buildContentsString(assetList)
        if self._mail:
            mail = strutil.replaceParams(self._mail, {'rewardContent': contents})
            pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId, mail)
            datachangenotify.sendDataChangeNotify(gameId, userId, 'message')

        ftlog.debug('TYDailyCheckin.gainCheckinReward gameId=', gameId,
                    'userId=', userId,
                    'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'),
                    'reward=', contents)
        return checkinOk, assetList, checkinDays
 def cleanup(self):
     TGHall.getEventBus().unsubscribe(MonthSupCheckinOkEvent, self.handle_event)
 def __init__(self):
     super(CreditSourceGamePlay, self).__init__()
     self.gameid = None
     self.play_result = None
     self.room2credit = None
     TGHall.getEventBus().subscribe(GameOverEvent, self.handle_event)
 def cleanup(self):
     TGHall.getEventBus().unsubscribe(GameOverEvent, self.handle_event)
 def cleanup(self):
     TGHall.getEventBus().unsubscribe(BetOnEvent, self.handle_event)
 def __init__(self):
     super(CreditSourceBet, self).__init__()
     self.amount = None
     TGHall.getEventBus().subscribe(BetOnEvent, self.handle_event)
 def __init__(self):
     super(CreditSourceCharge, self).__init__()
     self.credit = None
     TGHall.getEventBus().subscribe(ChargeNotifyEvent, self.handle_event)
 def __init__(self):
     super(CreditSourceSupplementCheckin, self).__init__()
     self.credit = None
     TGHall.getEventBus().subscribe(MonthSupCheckinOkEvent, self.handle_event)
 def cleanup(self):
     TGHall.getEventBus().unsubscribe(ChargeNotifyEvent, self.handle_event)