def doSendFishGift(userId, clientId):
    """
    发送礼包消息
    """
    message = MsgPack()
    message.setCmd("fishGift")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    if not util.isVersionLimit(userId):  # 提审版本限制
        bankruptGift, tip = BankruptGift(userId,
                                         clientId).getGiftInfo()  # 破产礼包
        if bankruptGift:
            message.setResult("dailyGiftMode", util.getGiftDTestMode(userId))
            message.setResult("dailyGift", bankruptGift)  # 破产礼包
            message.setResult("dailyGiftTxt", tip)  # 提示信息
    alms = share_system.AlmsCoin(userId)  # 救济金分享
    gotTimes = alms.shareData[share_system.INDEX_FINISH_COUNT]
    # 今日领取救济金次数
    message.setResult("gotAlmsCoinTimes", gotTimes)
    enterFishPoolTimes = weakdata.getDayFishData(userId,
                                                 WeakData.enterFishPoolTimes,
                                                 0)
    # 今日进入渔场次数
    message.setResult("enterFishPoolTimes", enterFishPoolTimes)
    giftTestMode = config.getPublic("giftTestMode", None)  # b测试模式 b显示钻石 a显示元
    if giftTestMode is None:
        giftTestMode = "a"
    message.setResult("testMode", giftTestMode)  # 显示钻石或元测试
    router.sendToUser(message, userId)
Exemple #2
0
def _triggerChargeNotifyEvent(event):
    """
    充值发货事件
    """
    ftlog.info("user_system._triggerChargeNotifyEvent->",
               "userId =", event.userId,
               "gameId =", event.gameId,
               "rmbs =", event.rmbs,
               "productId =", event.productId,
               "clientId =", event.clientId,
               "isAddVipExp", getattr(event, "isAddVipExp", False))
    userId = event.userId
    productId = event.productId
    # 购买非代购券商品.
    if event.productId not in config.getPublic("notVipExpProductIds", []) and event.rmbs > 0:
        from newfish.entity import vip_system
        # # app充值
        # if util.isAppClient(userId):
        #     isAddVipExp = False
        # else: # 微信充值
        #     isAddVipExp = True
        isAddVipExp = getattr(event, "isAddVipExp", False)
        vip_system.addUserVipExp(event.gameId, userId, event.diamonds, "BUY_PRODUCT",
                                 pokerconf.productIdToNumber(productId), productId,
                                 rmbs=event.rmbs, isAddVipExp=isAddVipExp)
    def initConstData(self):
        """
        初始化常量数据
        """
        # 新手保护概率
        self.protectOdds = [1.0, 1.0, 1.3, 1.25, 1.1, 1.05, 1, 1]

        # 火炮-曲线低概率随机区间
        self.gunCurveLowSection = (0.25, 1.25)
        # 火炮-曲线高概率随机区间
        self.gunCurveHighSection = (0.3, 2.2)

        # 常规技能-曲线低概率随机区间
        self.norSkillCurveLowSection = (0.24, 1.5)
        # 常规技能-曲线高概率随机区间
        self.norSkillCurveHighSection = (0.5, 2.5)
        # 常规技能-非曲线概率随机区间
        self.norSkillNonCurveSection = (0.32, 1.55)

        # 汇能弹、激光炮、猎鱼机甲、格林机关枪
        self.spSkills = [5106, 5108, 5109, 5110]
        # 特殊技能-曲线低概率区间((概率系数, 出现概率))
        self.spSkillCurveLowSection = ((1.35, 0.05), (1.05, 0.65), (0.5, 0.3))
        # 特殊技能-曲线高概率区间((概率系数, 出现概率))
        self.spSkillCurveHighSection = ((3.9, 0.1), (1.5, 0.7), (0.8, 0.2))
        # 特殊技能-非曲线概率区间((概率系数, 出现概率))
        self.spSkillNonCurveSection = ((1.5, 0.1), (1.05, 0.7), (0.3, 0.2))

        # 黑名单概率
        self.banOddsList = config.getPublic("banOddsList", [])
        self.fireBanOdds = 0.5
        self.skillBanOdds = 0.5
Exemple #4
0
 def _addCouponFishGroup(self, userId):
     """
     添加红包券鱼
     """
     if ftlog.is_debug():
         ftlog.debug("_addCouponFishGroup", userId, self.table.tableId)
     player = self.table.getPlayer(userId)
     catchCouponFishCount = gamedata.getGameAttrInt(
         userId, FISH_GAMEID, GameData.catchCouponFishCount)
     if player and player.taskSystemUser and player.taskSystemUser.curTask:
         if catchCouponFishCount < 10 or player.taskSystemUser.curTask.taskConfig[
                 "type"] == TaskType.CatchRedPacketFishNum:
             taskId = player.taskSystemUser.getCurMainTaskId()
             newbieFishGroupConf = config.getPublic("newbieFishGroupConf",
                                                    {})
             couponFishGroups = newbieFishGroupConf.get(
                 str(taskId), {}).get("couponFishGroups", [])
             data = self._playerCouponTimerDict.get(userId)
             if couponFishGroups and (not data
                                      or data[1].getTimeOut() <= 0):
                 group = self.table.insertFishGroup(
                     random.choice(couponFishGroups),
                     userId=userId,
                     sendUserId=userId)
                 timer = FTLoopTimer(group.totalTime, 0,
                                     self._addCouponFishGroup, userId)
                 timer.start()
                 self._playerCouponTimerDict[userId] = [group, timer]
Exemple #5
0
def canSendToUser(userId, clientId, led, userlang):
    """
    是否能发送给玩家
    """
    # led内容赋值 代码搜索[0, gameId, msgDict, scope, clientIds, isStopServer]
    isStopServer = led[5] if len(led) > 5 else False
    msgLang = dict(led[2]).get("lang", "zh")
    if userlang != msgLang:
        if ftlog.is_debug():
            ftlog.debug("led.canSendToUser LangFilter", "userId=", userId,
                        "clientId=", clientId, "led=", led, "userlang=",
                        userlang, "msgLang=", msgLang)
        return False

    if not isStopServer and clientId in config.getPublic(
            "closeLedClientIds", []):
        if ftlog.is_debug():
            ftlog.debug("led.canSendToUser ClientIdClosed", "userId=", userId,
                        "clientId=", clientId, "led=", led)
        return False

    clientIdFilter = led[4]
    if clientIdFilter and clientId in clientIdFilter:
        if ftlog.is_debug():
            ftlog.debug("led.canSendToUser ClientIdFilter", "userId=", userId,
                        "clientId=", clientId, "led=", led)
        return False

    return True
Exemple #6
0
 def _addNormalFishGroup(self):
     """
     add_group消息默认是下一个鱼阵开始前60s左右发送,每次调用add_group方法耗费时间一般为0.5s以内(包含对象创建和定时器延迟)
     长此以往会导致add_group消息在当前鱼阵结束后没有及时发送,需要修正时间
     """
     taskIds = []
     newbieFishGroupConf = config.getPublic("newbieFishGroupConf", {})
     for player in self.table.players:
         if player and player.taskSystemUser:
             taskIds.append(str(
                 player.taskSystemUser.getCurMainTaskId()))  # 获取当前主线任务Id
     taskIds.sort()
     if taskIds:
         taskId = taskIds[-1]
         if taskId in newbieFishGroupConf and int(taskId) > self._taskId:
             self._taskId = int(taskId)
             self._allNormalGroupIds = newbieFishGroupConf[str(taskId)].get(
                 "normalFishGroups", [])
             self._allMultipleGroupIds = newbieFishGroupConf[str(
                 taskId)].get("multipleFishGroups", [])
             self._allBombGroupIds = newbieFishGroupConf[str(taskId)].get(
                 "bombFishGroups", [])
             self._allRainbowGroupIds = newbieFishGroupConf[str(
                 taskId)].get("rainbowFishGroups", [])
     if ftlog.is_debug():
         ftlog.debug("_addNormalFishGroup->", taskIds, self._taskId,
                     self._allNormalGroupIds)
     randomGroupIds = list(
         set(self._allNormalGroupIds) - set(self._appearedNormalGroupIds))
     if not randomGroupIds:
         randomGroupIds = self._allNormalGroupIds
         self._appearedNormalGroupIds = []
     selectGroupIds = random.sample(randomGroupIds, self._generateNumOnce)
     self._appearedNormalGroupIds.extend(selectGroupIds)
     enterTime = self.table.getNextGroupEnterTime()
     correctValue = 0
     if enterTime > 0 > self.table.startTime + enterTime - time.time():
         correctValue = abs(self.table.startTime + enterTime - time.time())
     self.table.addNormalFishGroups(selectGroupIds)
     nextAddGroupInterval = round(
         self._getNextAddGroupInterval() - correctValue, 2)
     if nextAddGroupInterval < 1:
         nextAddGroupInterval = 1
     if self._normalFishGroupTimer:
         self._normalFishGroupTimer.cancel()
     self._normalFishGroupTimer = FTLoopTimer(nextAddGroupInterval, 0,
                                              self._nextNormalFishGroup)
     self._normalFishGroupTimer.start()
     self._nextMultipleFishGroup()
     self._nextBombFishGroup()
     self._nextRainbowFishGroup()
     if ftlog.is_debug():
         ftlog.debug("_addNormalFishGroup->nextAddGroupInterval =",
                     nextAddGroupInterval, "nextGroupEnterTimeInterval =",
                     self.table.startTime + enterTime - time.time(),
                     "tableId =", self.table.tableId,
                     "self.table.startTime =", self.table.startTime,
                     "enterTime =", enterTime, "nowTime =", time.time(),
                     "correctValue =", correctValue)
def _getMailExpireTime(mailSenderType):
    """
    获取邮件过期时间
    """
    mailExpireKey = "system" if mailSenderType == MailSenderType.MT_SYS else "user"
    mailExpireDay = config.getPublic("mailExpireDay", {})
    expireDay = mailExpireDay.get(mailExpireKey, 7)
    return int(expireDay) * 86400
 def _getActivityTideAppearConf(self, confName):
     """获取活动配置"""
     atideAppearConf = config.getPublic(confName)                # atideAppearConf
     if atideAppearConf:
         startTime = util.getTimestampFromStr(atideAppearConf[0][0])
         endTime = util.getTimestampFromStr(atideAppearConf[0][1])
         if startTime <= int(time.time()) <= endTime:
             return atideAppearConf[1], atideAppearConf[2]       # 出现的整点、索引
     return [], []
def _main():
    gunLevel = gunLevel_m = 2100 + level
    gunLevel = min(gunLevel, config.getMaxGunLevel(0))
    gunLevel_m = min(gunLevel_m, config.getMaxGunLevel(1))
    userGuideStep = json.dumps(config.getPublic("allGuideIds", []))
    gamedata.setGameAttrs(userId, 44, ["level", "exp", "gunLevel", "gunLevel_m", "userGuideStep", "redState"],
                          [level, exp, gunLevel, gunLevel_m, userGuideStep, 1])
    for skillId in config.getAllSkillId():
        skillInfo = [5, 20, 20, 0, 0]
        skill_system.setSkill(userId, skillId, skillInfo)
Exemple #10
0
 def _isAppear(self, name):
     """
     是否出现鱼阵
     """
     atideAppearConf = config.getPublic(name)
     if atideAppearConf:
         startTime = util.getTimestampFromStr(atideAppearConf[0])
         endTime = util.getTimestampFromStr(atideAppearConf[1])
         if startTime <= int(time.time()) <= endTime:
             return True
     return False
Exemple #11
0
def refreshUserData(userId):
    """
    刷新用户是否存在地区限制
    """
    location = config.getPublic("locationLimit", [])
    requestUrl = "http://iploc.ywdier.com/api/iploc5/search/city"
    postData = {"ip": sessiondata.getClientIp(userId)}
    result = util.doHttpQuery(requestUrl, postData, timeout=3)
    isLocationLimit = 0
    if not result or set(location) & set(result.get("loc", [])):
        isLocationLimit = 1
    gamedata.setGameAttr(userId, FISH_GAMEID, GameData.isLocationLimit, isLocationLimit)
Exemple #12
0
    def initConstData(self):
        """
        初始化常量数据
        """
        # 新手保护概率
        self.protectOdds = [1.0, 1.0, 1.3, 1.25, 1.1, 1.05, 1, 1]

        # 普通火炮概率系数((出现概率, 概率系数随机区间))
        self.gunOddsSection = ((0.7, (1, 1)), (0.15, (1.6, 1.6)), (0.15, (0,
                                                                          0)))
        # 技能概率系数((出现概率, 概率系数随机区间))
        self.skillOddsSection = ((0.1, (1.1, 2.4)), (0.7, (0.9, 1.2)),
                                 (0.2, (0, 0.4)))

        # 黑名单概率
        self.banOddsList = config.getPublic("banOddsList", [])
        self.fireBanOdds = 0.5
        self.skillBanOdds = 0.5
Exemple #13
0
def sendVersionUpdateTipsMsg(userId, clientId, clientVersion):
    """
    发送版本更新提示消息
    """
    clientIdNum = util.getClientIdNum(userId, clientId)
    versionUpdateConf = config.getPublic("versionUpdateConf", {}).get(str(clientIdNum), {})
    for version in sorted(versionUpdateConf.keys()):
        if StrictVersion(str(clientVersion)) < StrictVersion(str(version)):
            lang = util.getLanguage(userId, clientId)
            conf = versionUpdateConf[version]
            mo = MsgPack()
            mo.setCmd("fishTips")
            mo.setResult("gameId", FISH_GAMEID)
            mo.setResult("info", config.getMultiLangTextConf(conf["info"], lang=lang))
            mo.setResult("desc", config.getMultiLangTextConf(conf["desc"], lang=lang))
            mo.setResult("type", conf["type"])
            mo.setResult("tipsUrl", conf["tipsUrl"])
            router.sendToUser(mo, userId)
            break
Exemple #14
0
 def _addTerrorFishGroup(self, userId):
     """
     添加Terror鱼
     """
     if ftlog.is_debug():
         ftlog.debug("_addTerrorFishGroup", userId, self.table.tableId)
     player = self.table.getPlayer(userId)
     if player and player.taskSystemUser:
         taskId = player.taskSystemUser.getCurMainTaskId()
         newbieFishGroupConf = config.getPublic("newbieFishGroupConf", {})
         terrorFishGroups = newbieFishGroupConf.get(str(taskId), {}).get(
             "terrorFishGroups", [])
         data = self._playerTerrorTimerDict.get(userId)
         if terrorFishGroups and (not data or data[1].getTimeOut() <= 0):
             group = self.table.insertFishGroup(
                 random.choice(terrorFishGroups),
                 userId=userId,
                 sendUserId=userId)
             timer = FTLoopTimer(120, 0, self._addTerrorFishGroup, userId)
             timer.start()
             self._playerTerrorTimerDict[userId] = [group, timer]
Exemple #15
0
 def _takeGiftReward(self, msg, userId, seatId):
     """
     领取礼包奖励
     """
     productId = msg.getParam("productId", "")
     # 转运礼包购买后一定概率转运,当玩家购买任意转运礼包后,如果玩家当前房间所在曲线为6~10,则强制重置当前房间曲线,随机范围1~10
     if productId not in config.getPublic("luckyGiftProductIds", []):
         return
     player = self.getPlayer(userId)
     if player is None or not hasattr(player, "dynamicOdds"):
         return
     waveId = 0
     waveList = [
         wave["waveId"] for wave in player.dynamicOdds.getWaveList("low")
     ]
     if player.dynamicOdds.waveId in waveList:
         waveId = player.dynamicOdds.getWaveId()
         if waveId:
             player.dynamicOdds.resetOdds(waveId)
     if ftlog.is_debug():
         ftlog.debug("_takeGiftReward", userId, self.bigRoomId, waveList,
                     waveId)
Exemple #16
0
    def _fetchAllRoomInfos(self, userId, gameId):
        """
        获取所有房间信息
        """
        lang = util.getLanguage(userId)
        testMode = util.getNewbieABCTestMode(userId)
        recommendRoomId, reason = FishQuickStart._chooseRoom(userId, gameId)
        if reason != FishQuickStart.ENTER_ROOM_REASON_OK:
            recommendRoomId = 0
        re_roomConf = None
        if recommendRoomId != 0:
            re_roomConf = gdata.roomIdDefineMap()[recommendRoomId]
            if re_roomConf:
                re_roomConf = re_roomConf.configure

        ctrlRoomIds = [bigRoomId * 10000 + 1000 for bigRoomId in gdata.gameIdBigRoomidsMap()[gameId]]
        ctrlRoomIds.sort()
        ftlog.debug("_fetchAllRoomInfos", userId, gameId, ctrlRoomIds, recommendRoomId, re_roomConf)
        normalRoomInfos = []
        friendRoomInfos = []
        matchRoomInfos = []
        pointMatchRoomInfos = []
        robberyRoomInfos = []
        grandPrixRoomInfos = []
        poseidonRoomInfos = []

        isLimitedVer = util.isVersionLimit(userId)
        newbieRoomListMode = gamedata.getGameAttr(userId, FISH_GAMEID, ABTestData.newbieRoomListMode)   # 新手房间列表模式
        isFinishAllRedTask = util.isFinishAllRedTask(userId)
        clientVersion = gamedata.getGameAttr(userId, FISH_GAMEID, GameData.clientVersion)
        fpMultipleTestMode = config.getPublic("fpMultipleTestMode") or gamedata.getGameAttr(userId, FISH_GAMEID,
                                                                                            ABTestData.fpMultipleTestMode)  # 渔场倍率AB测试
        for ctlRoomId in ctrlRoomIds:
            pass


        return normalRoomInfos, friendRoomInfos, matchRoomInfos, robberyRoomInfos, \
               pointMatchRoomInfos, grandPrixRoomInfos, poseidonRoomInfos
Exemple #17
0
 def _addSharkFishGroup(self, userId):
     """
     添加大白鲨
     """
     player = self.table.getPlayer(userId)
     if player and player.taskSystemUser:
         taskId = player.taskSystemUser.getCurMainTaskId()
         if ftlog.is_debug():
             ftlog.debug("_addSharkFishGroup", userId, self.table.tableId,
                         taskId)
         newbieFishGroupConf = config.getPublic("newbieFishGroupConf", {})
         sharkFishGroups = newbieFishGroupConf.get(str(taskId), {}).get(
             "sharkFishGroups", [])
         data = self._playerSharkTimerDict.get(userId)
         if sharkFishGroups and (not data or data[1].getTimeOut() <= 0):
             group = self.table.insertFishGroup(
                 random.choice(sharkFishGroups),
                 userId=userId,
                 sendUserId=userId)
             timer = FTLoopTimer(group.totalTime + 1, 0,
                                 self._addSharkFishGroup, userId)
             timer.start()
             self._playerSharkTimerDict[userId] = [group, timer]
Exemple #18
0
def doSendGift(userId, clientId):
    """
    获取礼包数据
    """
    message = MsgPack()
    message.setCmd("fishDailyGift")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    vipLevel = hallvip.userVipSystem.getVipInfo(userId).get("level", 0)
    dailyGiftConf = config.getDailyGiftConf(clientId)
    lang = util.getLanguage(userId, clientId)
    giftInfo = []
    if not util.isVersionLimit(userId) and not util.isPurchaseLimit(
            userId) and util.isFinishAllNewbieTask(userId):
        for id, giftConf in dailyGiftConf.iteritems():
            vipRange = giftConf.get("vipRange", [0, 0])
            if vipRange[0] <= vipLevel <= vipRange[1]:
                hasBought = _isBought(userId, id)
                continuousDay = _getContinuousDay(userId, id)
                if continuousDay < len(giftConf.get("giftInfo", [])):
                    hasBought = 0
                dayIdx = _getGiftDayIdx(clientId, id, continuousDay)
                giftInfo.append(
                    getGiftDetail(giftConf, hasBought, dayIdx, lang))
                if ftlog.is_debug():
                    ftlog.debug("doSendGift", userId, id, hasBought,
                                continuousDay, dayIdx)
    message.setResult("btnVisible", bool(len(giftInfo) > 0))
    message.setResult("giftInfo", giftInfo)
    giftTestMode = config.getPublic("giftTestMode", None)
    if giftTestMode is None:
        giftTestMode = "a" if userId % 2 == 0 else "b"
    message.setResult("testMode", giftTestMode)
    router.sendToUser(message, userId)
    if ftlog.is_debug():
        ftlog.debug("doSendGift===>", userId, giftInfo)
Exemple #19
0
def doGetUserInfo(userId, otherUserId, kindId):
    """
    :param kindId: 赠送的道具ID
    """
    userdata.checkUserData(otherUserId)
    name = util.getNickname(otherUserId)
    sex, purl, charm = userdata.getAttrs(otherUserId, ["sex", "purl", "charm"])
    vipLv = util.getVipShowLevel(otherUserId)
    level = util.getUserValidCheckLevel(otherUserId)
    honors = honor_system.getHonorList(otherUserId)
    _, leftReceiveCount = _isCanReceiveFromOther(otherUserId, kindId)
    code = 0
    if name is None or name == "" or not level or level == 0:
        code = 1
    if otherUserId in config.getPublic("banGiftList", []):
        code = 1
    name = str(name) if name else ""
    message = MsgPack()
    message.setCmd("fishUserInfo")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    if code == 0:
        userInfos = {
            "userId": otherUserId,
            "name": name,
            "sex": sex,
            "purl": purl,
            "level": level,
            "vipLv": vipLv,
            "charm": charm,
            "honors": honors,
            "leftReceiveCount": leftReceiveCount
        }
        message.setResult("userInfos", userInfos)
    message.setResult("code", code)
    router.sendToUser(message, userId)