Пример #1
0
 def _sortedFishes(self, fIds, extends=None):
     count = extends[0]
     fishesDict = {}
     fishesHPDict = {}
     for fId in fIds:
         isOK = self.table.findFish(fId)
         if not isOK:
             continue
         fishInfo = self.table.fishMap[fId]
         originHP = fishInfo["HP"]
         fishType = fishInfo["fishType"]
         fishConf = config.getFishConf(fishType, self.table.typeName,
                                       self.fpMultiple)
         fishHP = int(originHP - self.deductionHP)
         fishHP = self.table.dealFishHP(fId, fishHP)
         fishesDict[fId] = self._getFishProbbRadix(fishInfo, fishConf)
         if originHP != fishHP:
             fishesHPDict[fId] = originHP
     if count <= 2:
         fishes = sorted(fishesDict.iteritems(), key=lambda d: d[1])
     else:
         fishes = sorted(fishesDict.iteritems(),
                         key=lambda d: d[1],
                         reverse=True)
     if ftlog.is_debug():
         ftlog.debug("_sortedFishes->", fishes, fishesHPDict, fIds)
     return fishes, fishesHPDict
Пример #2
0
 def _sortedFishes(self, fIds, extends=None):
     """
     按照鱼的捕获概率排序
     """
     fishesDict = {}
     fishesHPDict = {}
     for fId in fIds:
         isOK = self.table.findFish(fId)
         if not isOK:
             continue
         fishInfo = self.table.fishMap[fId]
         originHP = fishInfo["HP"]
         fishType = fishInfo["fishType"]
         fishConf = config.getFishConf(fishType, self.table.typeName,
                                       self.fpMultiple)
         fishHP = int(originHP - self.deductionHP)
         fishHP = self.table.dealFishHP(fId, fishHP)
         fishesDict[fId] = self._getFishProbbRadix(fishInfo, fishConf)
         if originHP != fishHP:
             fishesHPDict[fId] = originHP
     # 网中的鱼数量大于5时从小到大排序;反之从大到小.
     fishes = sorted(fishesDict.iteritems(),
                     key=lambda d: d[1],
                     reverse=(len(fishesDict) <= 5))
     if ftlog.is_debug():
         ftlog.debug(self.skillId, ", _sortedFishes->", fishes,
                     fishesHPDict, fIds)
     return fishes, fishesHPDict
Пример #3
0
    def catchFish(self, kindId, fIds=None, lockFid=0):
        """
        处理技能道具效果
        """
        data = self.player.skills_item_slots
        if kindId not in data:
            return
        item_data = data[kindId]
        addTimeGroups = []
        frozenFishes = []
        duration = item_data["conf"]["duration"]  # 冰冻时间
        endTime = time.time() + duration
        frozenBuffer = [5104, endTime, self.userId, 1, 1, duration, 0]
        frozenNum = 0
        for fId in fIds:
            isOK = self.table.findFish(fId)
            if not isOK:
                continue
            bufferEffect = [
                1 for buffer in self.table.fishMap[fId]["buffer"]
                if buffer[0] == 5104 and time.time() < buffer[1]
            ]
            if len(bufferEffect) > 0 and lockFid != fId:
                frozenNum += 1
                continue
            fishConf = config.getFishConf(self.table.fishMap[fId]["fishType"],
                                          self.table.typeName,
                                          self.table.runConfig.multiple)
            # 计算能否冰冻
            isCoverFrozen, lastFrozenTime, frozenTime, _ = self.table.checkCoverFrozen(
                fId, duration, endTime)
            if isCoverFrozen:
                isCoverFrozen = random.randint(
                    1, 10000) <= config.getCommonValueByKey(
                        "freezeProbb", 6500)
            if isCoverFrozen:
                frozenFishes.append(
                    [fId, lastFrozenTime, frozenTime, fishConf["probb2"]])

        if SkillItem.FREEZE_NUM - frozenNum > 0:
            if len(frozenFishes) >= SkillItem.FREEZE_NUM - frozenNum:
                frozenFishes.sort(key=lambda x: x[-1], reverse=True)
                frozenFishes = frozenFishes[:SkillItem.FREEZE_NUM - frozenNum]
            frozenNewFishes = []
            for frozenInfo in frozenFishes:
                self.table.frozenFish(frozenInfo[0], frozenBuffer,
                                      frozenInfo[1], frozenInfo[2],
                                      addTimeGroups)
                frozenNewFishes.append(frozenInfo[0])
            if frozenNewFishes:  # 广播新处于冰冻状态的鱼
                self.table.broadcastSkillEffect(self.player,
                                                endTime,
                                                frozenNewFishes,
                                                5104,
                                                isSkillItem=True)
        self.player.end_skill_item(kindId)
Пример #4
0
 def dealCatch(self,
               bulletId,
               wpId,
               player,
               catch,
               gain,
               gainChip,
               exp,
               fpMultiple,
               extends=None,
               skillId=0,
               stageId=0,
               isFraud=False,
               skillType=0):
     """处理捕获"""
     if self._matchState == MatchState.END:
         return
     self._retVerifyCatch(player,
                          bulletId,
                          catch,
                          gain,
                          extends,
                          skillId,
                          stageId,
                          fpMultiple,
                          isFraud=isFraud,
                          skillType=skillType)
     gainCoupon = 0
     items = []
     for gainMap in gain:
         fishConf = config.getFishConf(gainMap["fishType"], self.typeName,
                                       fpMultiple)
         if fishConf["type"] in config.BUFFER_FISH_TYPE:
             player.addOneBufferId(gainMap["itemId"])
         if fishConf["type"] in config.LOG_OUTPUT_FISH_TYPE:
             ftlog.info("dealCatch->fishType", "userId =", player.userId,
                        "fishType =", fishConf["type"], "wpId =", wpId,
                        "gainMap =", gainMap, "gainChip =", gainChip)
     player.catchBudget(gainChip, gainCoupon, items, wpId=wpId)
     self._afterCatch(bulletId,
                      wpId,
                      player,
                      catch,
                      gain,
                      gainChip,
                      fpMultiple,
                      extends,
                      skillType=skillType)
Пример #5
0
def triggerCatchEvent(event):
    """
    捕获鱼事件
    """
    userId = event.userId
    fishTypes = event.fishTypes
    roomId = event.roomId
    typeName = util.getRoomTypeName(roomId)
    if util.isNewbieRoom(typeName):
        return
    gainChip = event.gainChip
    for fishType in fishTypes:
        fishConf = config.getFishConf(fishType, typeName)
        questType = None
        if fishConf["type"] in config.MULTIPLE_FISH_TYPE:  # 倍率鱼
            questType = QuestType.CatchMultipleFish
        elif fishConf["type"] in config.BOMB_FISH_TYPE:  # 炸弹鱼|炸弹蟹
            questType = QuestType.CatchBombFish
        elif fishConf["type"] in config.DRILL_FISH_TYPE:  # 钻头鱼
            questType = QuestType.CatchDrillFish
        elif fishConf["type"] in config.PLATTER_FISH_TYPE:  # 大盘鱼
            questType = QuestType.CatchPlatterFish
        elif fishConf["type"] in config.SUPER_BOSS_FISH_TYPE:  # 超级boss
            questType = QuestType.CatchSuperBossFish

        if questType:
            incrQuestTypeData(userId, questType, 1)

        if fishConf["type"] in config.TERROR_FISH_TYPE:  # 特殊鱼
            incrQuestTypeData(userId, QuestType.CatchTerrorFish, 1)
        if fishConf["type"] in config.COlOR_GOLD_FISH_TYPE:  # 捕获彩金鱼
            incrQuestTypeData(userId, QuestType.CatchColorGoldFish, 1)
        if fishConf["type"] in config.BOSS_FISH_TYPE:  # Boss
            incrQuestTypeData(userId, QuestType.CatchBossFish, 1)

        tmpQuestType = None
        for qt, fishTp in TaskTypeFishTypeMap.items():  # 具体的鱼
            if fishConf["fishType"] in fishTp:
                tmpQuestType = qt
                break
        if tmpQuestType:
            incrQuestTypeData(userId, tmpQuestType, 1)
    if gainChip:
        incrQuestTypeData(userId, QuestType.CatchGotChip, gainChip)
    if len(fishTypes):
        incrQuestTypeData(userId, QuestType.CatchFishNum, len(fishTypes))
Пример #6
0
def triggerCatchEvent(event):
    """捕获事件"""
    bigRoomId, _ = util.getBigRoomId(event.roomId)
    typeName = util.getRoomTypeName(event.roomId)
    fishPool = util.getFishPoolByBigRoomId(bigRoomId)
    fpMultiple = event.fpMultiple if hasattr(event, "fpMultiple") else 0
    userId = event.userId
    fishTypes = event.fishTypes
    gain_chip = event.gainChip
    resetTime = event.resetTime
    gunX = event.gunX * event.gunSkinMul

    fish_boss_num = 0
    fish_multiple_num = 0
    terror_num = 0

    all_fish_num = len(fishTypes)
    for fishType in fishTypes:
        fishConf = config.getFishConf(fishType, typeName)
        if fishConf["type"] in config.BOSS_FISH_TYPE:                   # Boss
            fish_boss_num += 1
        elif fishConf["type"] in config.ROBBERY_BOSS_FISH_TYPE:         # 招财Boss
            fish_boss_num += 1
            all_fish_num -= 1
        elif fishConf["type"] in config.MULTIPLE_FISH_TYPE:             # 倍率鱼
            fish_multiple_num += 1
        elif fishConf["type"] in config.ROBBERY_MULTIPLE_FISH_TYPE:     # 招财倍率鱼
            fish_multiple_num += 1
            all_fish_num -= 1
        if fishConf["type"] in config.TERROR_FISH_TYPE:                 # 特殊鱼
            terror_num += 1
    if fish_boss_num:
        _incQuestValue(userId, TaskType.GunYBossFishNum, fish_boss_num, resetTime, fishPool=fishPool, fpMultiple=fpMultiple, gunX=gunX)
    if fish_multiple_num:
        _incQuestValue(userId, TaskType.GunYMultipleFishNum, fish_multiple_num, resetTime, fishPool=fishPool, fpMultiple=fpMultiple, gunX=gunX)
    if all_fish_num:
        _incQuestValue(userId, TaskType.GunYFishNum, all_fish_num, resetTime, fishPool=fishPool, fpMultiple=fpMultiple, gunX=gunX)
        _incQuestValue(userId, TaskType.FishNum, all_fish_num, resetTime, fishPool=fishPool, fpMultiple=fpMultiple)
    if gain_chip:
        _incQuestValue(userId, TaskType.CoinNum, gain_chip, resetTime, fishPool=fishPool, fpMultiple=fpMultiple)
    if terror_num:
        _incQuestValue(userId, TaskType.GunYTerrorFishNum, terror_num, resetTime, fishPool=fishPool, fpMultiple=fpMultiple, gunX=gunX)
        _incQuestValue(userId, TaskType.TerrorFishNum, terror_num, resetTime, fishPool=fishPool, fpMultiple=fpMultiple)
Пример #7
0
 def _sortedFishes(self, fIds, extends=None):
     fishesDict = {}
     fishesHPDict = {}
     for fId in fIds:
         isOK = self.table.findFish(fId)
         if not isOK:
             continue
         fishInfo = self.table.fishMap[fId]
         originHP = fishInfo["HP"]
         fishType = fishInfo["fishType"]
         fishConf = config.getFishConf(fishType, self.table.typeName,
                                       self.fpMultiple)
         fatal = self.table.dealIceConeEffect(fId, fishConf)
         fishHP = int(originHP - self.deductionHP)
         fishHP = self.table.dealFishHP(fId, fishHP, fatal)
         fishesDict[fId] = self._getFishProbbRadix(fishInfo, fishConf)
         if originHP != fishHP:
             fishesHPDict[fId] = originHP
     # 从大到小排序.
     fishes = sorted(fishesDict.iteritems(),
                     key=lambda d: d[1],
                     reverse=True)
     return fishes, fishesHPDict
Пример #8
0
    def dealCatchEvent(self, event, tableMultiple, coinAddition, playersNum):
        """
        处理捕鱼事件
        :param event: 捕获事件详情
        :param tableMultiple: 房间倍率
        :param coinAddition: 当处于累计捕获金币任务时的进度加成
        :param playersNum: 当前桌内玩家数量
        :return:
        """
        if self.taskConfig["type"] in [TaskType.UseSkillNum, TaskType.ComboNum]:
           return
        if self.taskData["state"] != TaskState.Update:
            return
        isMe = event.userId == self.userId
        fishTypes = event.fishTypes  # 鱼种类
        wpId = event.wpId
        gunSkinMul = event.gunSkinMul
        target = self.taskConfig["target"]
        progress = 0
        isTargetAddition = False
        if self.taskConfig["type"] in [TaskType.CatchFishCoin, TaskType.UseSkillCatchFishCoin]:
            progress = coinAddition
        elif self.taskConfig["type"] in [TaskType.CatchFishNum, TaskType.CatchBossNum,
                                         TaskType.FishNumCoinHigh, TaskType.BetFishNum,
                                         TaskType.CatchRainbowFishNum, TaskType.CatchRedPacketFishNum]:
            friendHelpPlayerMultiple = config.getCommonValueByKey("friendHelpPlayerMultiple", {}).get(str(playersNum - 1), 0)
            probb = (friendHelpPlayerMultiple * (self.taskData["targetNum"] + 5) / self.taskData["targetNum"]) * 10000
            randInt = random.randint(1, 10000)
            if randInt <= probb:
                isTargetAddition = True
        if self.taskConfig["type"] == TaskType.CatchFishCoin:  # 1捕获xx鱼达金币数
            totalCoin, fishCoins, _ = self._getCatchFishCoin(event)
            if target:
                self._addProgress(fishCoins.get(str(target), 0), isMe, progress=progress, isTargetAddition=isTargetAddition)
            else:
                self._addProgress(totalCoin, isMe, progress=progress, isTargetAddition=isTargetAddition)

        elif self.taskConfig["type"] == TaskType.CatchFishNum:  # 2捕获鱼个数
            if target:
                betTarget = 14000 + int(target) % 11000
                fishNum = fishTypes.count(target) + fishTypes.count(betTarget)
                self._addProgress(fishNum, isMe, progress=progress, isTargetAddition=isTargetAddition)
            else:
                self._addProgress(len(fishTypes), isMe, progress=progress, isTargetAddition=isTargetAddition)
            return
        elif self.taskConfig["type"] == TaskType.CatchBossNum:  # 3捕获boss个数
            bossNum = 0  # boss个数
            for fishType in fishTypes:
                fishConf = config.getFishConf(fishType, self.taskSystem.table.typeName, tableMultiple)
                if fishConf["type"] in config.BOSS_FISH_TYPE:
                    bossNum += 1
            self._addProgress(bossNum, isMe, progress=progress, isTargetAddition=isTargetAddition)
            return

        elif self.taskConfig["type"] == TaskType.FishNumCoinHigh:  # 4多少金币以上的鱼
            _, _, num = self._getCatchFishCoin(event, target)
            self._addProgress(num, isMe, progress=progress, isTargetAddition=isTargetAddition)
            return
        elif self.taskConfig["type"] == TaskType.BetFishNum: # 5--多少只倍率鱼
            betFishMap = {}
            for gainMap in event.gain:
                fishConf = config.getFishConf(gainMap["fishType"], self.taskSystem.table.typeName, tableMultiple)
                itemId = gainMap["itemId"]
                itemCount = gainMap["count"]

                if fishConf["type"] in config.MULTIPLE_FISH_TYPE:
                    if itemId == config.CHIP_KINDID:  # 金币
                        bet = itemCount / fishConf["score"] / tableMultiple / gunSkinMul
                        betFishMap[str(bet)] = betFishMap.get(str(bet), 0) + 1
            betNum = 0
            for bet in betFishMap:
                if int(bet) >= target:
                    betNum += betFishMap[bet]
            self._addProgress(betNum, isMe, progress=progress, isTargetAddition=isTargetAddition)

        elif self.taskConfig["type"] == TaskType.UseSkillCatchFishNum:  # 8 使用技能捕获鱼数
            wpType = util.getWeaponType(wpId)
            if wpType in [config.SKILL_WEAPON_TYPE,
                          config.RB_FIRE_WEAPON_TYPE,
                          config.RB_BOMB_WEAPON_TYPE]:
                if target:
                    self._addProgress(fishTypes.count(target), isMe, progress=progress, isTargetAddition=isTargetAddition)
                else:
                    self._addProgress(len(fishTypes), isMe, progress=progress, isTargetAddition=isTargetAddition)

        elif self.taskConfig["type"] == TaskType.UseSkillCatchFishCoin:  # 9 使用技能捕获XX金币类型的鱼数
            totalCoin, fishCoins, _ = self._getCatchFishCoin(event)  # 总金币数不包括招财珠
            wpType = util.getWeaponType(wpId)
            if wpType in [config.SKILL_WEAPON_TYPE,
                          config.RB_FIRE_WEAPON_TYPE,
                          config.RB_BOMB_WEAPON_TYPE]:
                if target:
                    self._addProgress(fishCoins.get(str(target), 0), isMe, progress=progress, isTargetAddition=isTargetAddition)
                else:
                    self._addProgress(totalCoin, isMe, progress=progress, isTargetAddition=isTargetAddition)
        elif self.taskConfig["type"] == TaskType.CatchFishNumByOneFire:  # 10 1网捕获多少鱼
            if len(fishTypes) >= target:
                value = 1
                if not isMe:
                    return
                self._addProgress(value, isMe, progress=progress, isTargetAddition=isTargetAddition)
        elif self.taskConfig["type"] == TaskType.CatchRainbowFishNum:   # 捕获彩虹鱼
            rainbowNum = 0
            for fishType in fishTypes:
                fishConf = config.getFishConf(fishType, self.taskSystem.table.typeName, tableMultiple)
                if fishConf["type"] in config.RAINBOW_FISH_TYPE:
                    rainbowNum += 1
            self._addProgress(rainbowNum, isMe, progress=progress, isTargetAddition=isTargetAddition)
        elif self.taskConfig["type"] == TaskType.CatchRedPacketFishNum: # 捕获红包券鱼
            redPacketNum = 0
            for fishType in fishTypes:
                fishConf = config.getFishConf(fishType, self.taskSystem.table.typeName, tableMultiple)
                if fishConf["type"] == 4:
                    redPacketNum += 1
            self._addProgress(redPacketNum, isMe, progress=progress, isTargetAddition=isTargetAddition)
Пример #9
0
    def dealCatchEvent(self, event):
        """
        处理捕获事件
        """
        if self.state != 2:
            return
        uid = event.userId
        fishTypes = event.fishTypes
        if uid not in self.userIds:
            return

        fpMultiple = self.getEventFpMultiple(event)
        score = 0
        player = self.table.getPlayer(uid)
        usersData = self.usersData.get(uid)
        taskType = usersData["task"]["taskType"]
        targets = usersData["task"]["targets"]
        target1 = targets.get("target1", 0)
        target2 = targets.get("target2", 0)
        multipleTarget1 = 14000 + target1 % 11000
        multipleTarget2 = 14000 + target2 % 11000
        number1 = targets.get("number1", 999)
        number2 = targets.get("number2", 999)

        if taskType != 1 and "progress" not in usersData["results"]:
            usersData["results"]["progress"] = 0
        if taskType == 1:  # 指定数量特定鱼
            if target1 not in fishTypes and target2 not in fishTypes and multipleTarget1 not in fishTypes and multipleTarget2 not in fishTypes:
                return
            if (target1 in fishTypes or multipleTarget1
                    in fishTypes) and target1 not in usersData["results"]:
                usersData["results"][target1] = 0
            if (target2 in fishTypes or multipleTarget2
                    in fishTypes) and target2 not in usersData["results"]:
                usersData["results"][target2] = 0
            if self._checkFinished(usersData):
                return
            if player and player.currentTask:
                if target1 in fishTypes or multipleTarget1 in fishTypes:
                    target1Score = fishTypes.count(target1) + fishTypes.count(
                        multipleTarget1)
                    if usersData["results"][target1] + target1Score >= number1:
                        score += (number1 - usersData["results"][target1])
                        usersData["results"][target1] = number1
                        if player.currentTask[3].has_key("target1"):
                            player.currentTask[3].pop("target1")
                    else:
                        score += target1Score
                        usersData["results"][target1] += target1Score
                if target2 in fishTypes or multipleTarget2 in fishTypes:
                    target2Score = fishTypes.count(target2) + fishTypes.count(
                        multipleTarget2)
                    if usersData["results"][target2] + target2Score >= number2:
                        score += (number2 - usersData["results"][target2])
                        usersData["results"][target2] = number2
                        if player.currentTask[3].has_key("target2"):
                            player.currentTask[3].pop("target2")
                    else:
                        score += target2Score
                        usersData["results"][target2] += target2Score
        elif taskType == 2:  # 指定分数
            for fishType in fishTypes:
                fishConf = config.getFishConf(fishType, self.table.typeName,
                                              fpMultiple)
                if fishConf.get("itemId", 0) in config.BULLET_KINDIDS:
                    score += (
                        fishConf.get("score", 0) *
                        config.BULLET_KINDIDS[fishConf.get("itemId", 0)] /
                        fpMultiple)
                else:
                    score += fishConf.get("score", 0)
            usersData["results"]["progress"] += score

        usersData["score"] += score
        if score == 0:
            return
        usersData["lastCatchId"] = self.catchId
        self.catchId -= 1
        self._sendRanksInfo()
        if self._checkFinished(usersData):
            self.endTimer.cancel()
            self.taskEnd(ranks=self._getRanks())
            return
Пример #10
0
 def addNormalFishGroups(self, groupNames):
     """
     普通鱼群(单个鱼群时长一般为1分钟左右,鱼群中含有多条鱼且可以延迟出现)
     """
     groupName = None
     fishType = None
     try:
         nowTableTime = time.time() - self.table.startTime
         allGroups = self.table.runConfig.fishGroups
         fixedMultipleFish = config.getFixedMultipleFishConf(
             self.table.runConfig.fishPool)
         newGroups = []
         for _, groupName in enumerate(groupNames):
             groupConf = allGroups[groupName]
             enterTime = self.table.getNextGroupEnterTime()
             enterTime = enterTime if enterTime > nowTableTime else nowTableTime + 1
             startFishId = self._getNewFishId(len(groupConf["fishes"]))
             group = FishGroup(groupConf, enterTime, self._getNewGroupId(),
                               startFishId)
             if ftlog.is_debug():
                 ftlog.debug("addNormalFishGroups new group:", group.desc(),
                             self.table.tableId, nowTableTime)
             for i in xrange(group.fishCount):
                 conf = group.fishes[i]
                 fishType = conf.get("fishType")
                 multiple = 1
                 if fixedMultipleFish:  # 随机生成固定倍率鱼(目前只在比赛场使用)
                     if fishType in fixedMultipleFish["range"]:
                         if random.randint(
                                 1, 10000) <= fixedMultipleFish["probb"]:
                             randInt = random.randint(1, 10000)
                             for _, multipleMap in enumerate(
                                     fixedMultipleFish["multiples"]):
                                 probb = multipleMap["probb"]
                                 if probb[0] <= randInt <= probb[1]:
                                     multiple = multipleMap["multiple"]
                                     break
                 fishConf = config.getFishConf(
                     fishType, self.table.typeName,
                     self.table.runConfig.multiple)
                 self.table.fishMap[startFishId + i] = {
                     "group": group,
                     "conf": conf,
                     "HP": fishConf["HP"],
                     "buffer": [],
                     "multiple": multiple,
                     "alive": True,
                     "owner": None,
                     "score": None,
                     "fishType": fishType,
                     "type": fishConf["type"],
                 }
                 self.table.fishCountMap[
                     fishType] = self.table.fishCountMap.setdefault(
                         fishType, 0) + 1
             self.table.normalFishGroups[group.serverGroupId] = group
             newGroups.append(group)
             if ftlog.is_debug():
                 ftlog.debug(
                     "addNormalFishGroups group info:", self.table.tableId,
                     groupName, group.serverGroupId,
                     self.table.startTime + group.enterTime,
                     self.table.startTime + group.exitTime + group.addTime)
         self.deleteFishGroups(self.table.normalFishGroups, len(newGroups))
         self.broadcastAddGroup(newGroups)
     except:
         ftlog.error("addNormalFishGroups error", self.table.tableId,
                     groupName, fishType)
Пример #11
0
 def insertFishGroup(self,
                     groupNames,
                     position=None,
                     HP=None,
                     buffer=None,
                     userId=None,
                     score=None,
                     sendUserId=None,
                     gameResolution=None):
     """
     召唤鱼群(调用后立即出现的鱼群)
     :param groupNames: 鱼阵文件名称
     :param position: 出现位置
     :param HP: 鱼群中鱼的血量
     :param buffer: 鱼群中鱼的buffer
     :param userId: 归属玩家
     :param score: 指定鱼群中鱼的分数
     :param sendUserId: 指定该鱼群的可见玩家
     :param gameResolution: 召唤该鱼群的玩家的游戏分辨率
     :param isBroadcast: 是否需要广播通知
     """
     buffer = [buffer] if buffer else []
     groupNames = groupNames if isinstance(groupNames,
                                           list) else [groupNames]
     allGroups = self.table.runConfig.fishGroups
     newGroups = []
     groupName = None
     fishType = None
     try:
         for _, groupName in enumerate(groupNames):
             if groupName not in allGroups:
                 ftlog.error("invalid fish groupType", groupName)
                 return None
             groupConf = allGroups[groupName]
             enterTime = time.time() - self.table.startTime
             startFishId = self._getNewFishId(len(groupConf["fishes"]))
             group = FishGroup(groupConf,
                               enterTime,
                               self._getNewGroupId(),
                               startFishId,
                               position,
                               gameResolution,
                               deadCallback=self.setFishGroupDied)
             if ftlog.is_debug():
                 ftlog.debug("insertFishGroup:", group.desc(),
                             self.table.tableId, enterTime)
             for i in xrange(group.fishCount):
                 conf = group.fishes[i]
                 fishType = conf.get("fishType")
                 fishConf = config.getFishConf(
                     fishType, self.table.typeName,
                     self.table.runConfig.multiple)
                 self.table.fishMap[startFishId + i] = {
                     "group":
                     group,
                     "conf":
                     conf,
                     "HP":
                     HP if HP else fishConf["HP"],
                     "buffer":
                     deepcopy(buffer),
                     "multiple":
                     1,
                     "alive":
                     True,
                     "owner":
                     userId,
                     "score":
                     score,
                     "fishType":
                     fishType,
                     "type":
                     fishConf["type"],
                     "sendUsersList":
                     sendUserId if isinstance(sendUserId, list) else None
                 }
                 self.table.fishCountMap[
                     fishType] = self.table.fishCountMap.setdefault(
                         fishType, 0) + 1
             self.table.callFishGroups[group.serverGroupId] = group
             newGroups.append(group)
     except:
         ftlog.error("insertFishGroup error", self.table.tableId, groupName,
                     fishType)
     self.broadcastAddGroup(newGroups, sendUserId)
     return newGroups[0] if len(newGroups) == 1 else newGroups
Пример #12
0
    def triggerCatchFishEvent(self, event):
        """捕获鱼"""
        if self.table.typeName not in config.NORMAL_ROOM_TYPE:
            return
        if not self.player or self.player.userId <= 0:
            return
        if self.player.level < config.getCommonValueByKey(
                "achievementOpenLevel"):
            return
        if not self.achieveTasks:
            self.achieveTasks = self._initPlayerAchieveTasks(
                self.player.userId)
        if hasattr(event, "fpMultiple"):
            fpMultiple = event.fpMultiple
        else:
            fpMultiple = self.table.runConfig.multiple
        fishIds = event.fishTypes  # 鱼种类
        fTypes = []
        betFishMap = {}  # 计算倍率鱼 个数
        bossNum = 0  # boss个数
        for fishType in fishIds:
            fishConf = config.getFishConf(fishType, self.table.typeName,
                                          self.player.fpMultiple)
            if fishConf["type"] in config.BOSS_FISH_TYPE:
                bossNum += 1
            fTypes.append(fishConf["type"])

        for gainMap in event.gain:
            fishConf = config.getFishConf(gainMap["fishType"],
                                          self.table.typeName,
                                          self.player.fpMultiple)
            itemId = gainMap["itemId"]
            itemCount = gainMap["count"]
            if fishConf["type"] not in config.MULTIPLE_FISH_TYPE:
                continue
            if itemId == config.CHIP_KINDID:  # 金币
                bet = itemCount / fishConf["score"] / fpMultiple
                if str(bet) not in betFishMap:
                    betFishMap[str(bet)] = 1
                else:
                    betFishMap[str(bet)] += 1

        tipHonorIds = []
        for taskClass in self.achieveTasks:
            hasComplete = False
            taskConf = taskClass.getTaskConf()
            if taskConf["type"] == AchieveType.CatchFishNum:  # 捕获鱼多少条
                count = len(fishIds)
                fishTypes = taskConf["target"].get("fishType")
                if fishTypes:
                    count = sum([fTypes.count(type_) for type_ in fishTypes])
                hasComplete = taskClass.addProgress(count, inTable=True)
            elif taskConf["type"] == AchieveType.CatchBetFishNum:  # 捕获倍率鱼总数
                betNum = 0
                targetBet = taskConf["target"]["condition"]
                for bet in betFishMap:
                    if int(bet) >= targetBet:
                        betNum += betFishMap[bet]
                hasComplete = taskClass.addProgress(betNum, inTable=True)
            elif taskConf["type"] == AchieveType.CatchBossNum and (
                    taskConf["target"].get("condition",
                                           self.table.runConfig.multiple)
                    == self.table.runConfig.multiple):  # 捕获boss个数
                hasComplete = taskClass.addProgress(bossNum, inTable=True)
            # 添加小红点
            if hasComplete and taskClass.getHonorId() not in tipHonorIds:
                tipHonorIds.append(taskClass.getHonorId())
        if tipHonorIds:
            module_tip.addModuleTipEvent(self.player.userId, "achievement",
                                         tipHonorIds)
Пример #13
0
    def dealCatchEvent(self, event):
        """
        处理捕获事件
        """
        uid = event.userId
        fishTypes = event.fishTypes
        catch = event.catch
        catchFishMultiple = event.catchFishMultiple
        if uid not in self.userIds:
            return
        usersData = self.usersData.get(uid, {})
        if not usersData:
            return
        if usersData["state"] != TaskState.TS_Start:
            return
        score = 0
        for catchMap in catch:
            fId = catchMap["fId"]
            fishType = self.table.fishMap[fId]["fishType"]
            fishConf = config.getFishConf(fishType, self.table.typeName,
                                          self.fpMultiple)
            fishMultiple = 1
            if catchFishMultiple and catchFishMultiple.get(fId):
                fishMultiple = catchFishMultiple.get(fId)
            if fishConf.get("itemId", 0) in config.BULLET_KINDIDS:
                score += (fishConf.get("score", 0) *
                          config.BULLET_KINDIDS[fishConf.get("itemId", 0)] /
                          self.fpMultiple)
            else:
                score += fishConf.get("score", 0) * fishMultiple

        player = self.table.getPlayer(uid)
        targets = usersData["task"]["targets"]
        target = targets.get("target", 0)
        number = targets.get("number", 999)
        _isUserDataUpdate = False
        taskType = usersData["task"]["taskType"]
        if taskType != 1 and "progress" not in usersData["results"]:
            usersData["results"]["progress"] = 0
            _isUserDataUpdate = True
        if taskType == 1:  # 指定数量特定鱼
            if target not in fishTypes:
                return
            if target in fishTypes and target not in usersData["results"]:
                usersData["results"][target] = 0
            if self._checkFinished(usersData):
                return
            if target in fishTypes:
                num = fishTypes.count(target)
                usersData["results"][target] += num
                _isUserDataUpdate = True
            if player and player.currentTask:
                if target in fishTypes and usersData["results"][
                        target] >= number:
                    usersData["results"][target] = number
                    _isUserDataUpdate = True
        elif taskType == 2:  # 指定数量任意鱼
            usersData["results"]["progress"] += len(fishTypes)
            _isUserDataUpdate = True
        elif taskType == 3:  # 指定分数
            usersData["results"]["progress"] += score
            _isUserDataUpdate = True
        if _isUserDataUpdate:
            self._sendRanksInfo(uid)
        if self._checkFinished(usersData):
            self.taskEnd(uid)
Пример #14
0
    def dealCatchEvent(self, event):
        """
        处理捕获事件
        """
        fpMultiple = self.getEventFpMultiple(event)
        uid = event.userId
        fishTypes = event.fishTypes
        if uid not in self.userIds:
            return
        usersData = self.usersData.get(uid, {})
        if usersData and usersData["state"] != TaskState.TS_Start:
            return
        score = 0
        for fishType in fishTypes:
            fishConf = config.getFishConf(fishType, self.table.typeName,
                                          fpMultiple)
            if fishConf.get("itemId", 0) in config.BULLET_KINDIDS:
                score += (fishConf.get("score", 0) *
                          config.BULLET_KINDIDS[fishConf.get("itemId", 0)] /
                          fpMultiple)
            else:
                score += fishConf.get("score", 0)

        taskType = usersData["task"]["taskType"]
        player = self.table.getPlayer(uid)
        targets = usersData["task"]["targets"]
        target1 = targets.get("target1", 0)
        multipleTarget1 = 14000 + target1 % 11000
        target2 = targets.get("target2", 0)
        multipleTarget2 = 14000 + target2 % 11000
        number1 = targets.get("number1", 999)
        number2 = targets.get("number2", 999)

        _isUserDataUpdate = False
        if taskType != 1 and "progress" not in usersData["results"]:
            usersData["results"]["progress"] = 0
            _isUserDataUpdate = True
        if taskType == 1:  # 指定数量特定鱼
            if target1 not in fishTypes and target2 not in fishTypes and multipleTarget1 not in fishTypes and multipleTarget2 not in fishTypes:
                return
            if (target1 in fishTypes or multipleTarget1
                    in fishTypes) and target1 not in usersData["results"]:
                usersData["results"][target1] = 0
            if (target2 in fishTypes or multipleTarget2
                    in fishTypes) and target2 not in usersData["results"]:
                usersData["results"][target2] = 0
            if self._checkFinished(usersData):
                return
            if target1 in fishTypes or multipleTarget1 in fishTypes:
                score = fishTypes.count(target1) + fishTypes.count(
                    multipleTarget1)
                usersData["results"][target1] += score
                _isUserDataUpdate = True
            if target2 in fishTypes or multipleTarget2 in fishTypes:
                score = fishTypes.count(target2) + fishTypes.count(
                    multipleTarget2)
                usersData["results"][target2] += score
                _isUserDataUpdate = True
            if player and player.currentTask:
                if (target1 in fishTypes or multipleTarget1 in fishTypes
                    ) and usersData["results"][target1] >= number1:
                    usersData["results"][target1] = number1
                    _isUserDataUpdate = True
                    if player.currentTask[3].has_key("target1"):
                        player.currentTask[3].pop("target1")
                if (target2 in fishTypes or multipleTarget2 in fishTypes
                    ) and usersData["results"][target2] >= number2:
                    usersData["results"][target2] = number2
                    _isUserDataUpdate = True
                    if player.currentTask[3].has_key("target2"):
                        player.currentTask[3].pop("target2")
                ftlog.debug("dealCatchEvent->player.currentTask",
                            player.currentTask)
        elif taskType == 2:  # 指定分数
            usersData["results"]["progress"] += score
            _isUserDataUpdate = True
        elif taskType == 3:  # 一炮指定分数
            if score >= usersData["targets"]["target1"]:
                usersData["results"]["progress"] += 1
                _isUserDataUpdate = True
        elif taskType == 4:  # 指定数量任意鱼
            usersData["results"]["progress"] += len(fishTypes)
            _isUserDataUpdate = True
        elif taskType == 5:  # 指定Combo数
            if player and player.combo >= target1:
                usersData["results"]["progress"] += 1
                _isUserDataUpdate = True
        if _isUserDataUpdate:
            self._sendRanksInfo(uid)

        if self._checkFinished(usersData):
            if uid not in self.userEndTimer:
                return
            userEndTimer = self.userEndTimer[uid]
            userEndTimer.cancel()
            self.taskEnd(uid)
Пример #15
0
 def catchFish(self, bulletId, wpId, fIds, extends):
     catch = []
     gain = []
     gainChip = 0
     exp = 0
     otherCatch = {}
     gunX = self.player.getFireGunX(bulletId)
     bufferCoinAdd = self.player.getCoinAddition(self.weaponId)
     odds = self.player.dynamicOdds.getOdds(skill=self)
     realPower = self.originRealPower * odds
     for fId in fIds:
         isOK, catchUserId = self.table.verifyFish(self.player.userId, fId)
         if not isOK or self.impale <= 0:
             break
         catchMap = {}
         catchMap["fId"] = fId
         catchMap["reason"] = 1
         fishInfo = self.table.fishMap[fId]
         fishType = fishInfo["fishType"]
         fishConf = config.getFishConf(fishType, self.table.typeName,
                                       self.fpMultiple)
         originHP = fishInfo["HP"]
         probbRadix = fishInfo["HP"] + fishConf["probb2"]
         if self.impale > probbRadix:  # 子弹能穿刺鱼
             self.impale -= probbRadix
             self.impale = max(self.impale, 0)
             randInt = random.randint(1, 10000)
             if randInt <= 9000 or self.impaleCatch:
                 catchMap["reason"] = 0
             if ftlog.is_debug():
                 ftlog.debug("SkillEnergy_m->impale->", "userId =",
                             self.player.userId, "randInt =", randInt,
                             "fId =", fId, "fishType =",
                             fishInfo["fishType"], "probbRadix =",
                             probbRadix, "impale =", self.impale)
         else:  # 子弹无法穿刺鱼
             realPower += self.impale
             self.impale = 0
             self.deductionHP = self.totalPower
             fishHP = int(originHP - self.deductionHP)
             self.table.dealFishHP(fId, fishHP)
             probbRadix = self._getFishProbbRadix(fishInfo, fishConf)
             probb, realPower = self.getSkillCatchProbb(
                 fId, len(fIds), realPower, probbRadix)
             randInt = random.randint(1, 10000)
             if randInt <= probb:
                 catchMap["reason"] = 0
         catchMap["HP"] = fishInfo["HP"]
         if catchMap["reason"] == 0:
             multiple = self.gunSkinMultiple
             fishGainChip, fishGain, fishExp = self.table.dealKillFishGain(
                 fId,
                 self.player,
                 self.fpMultiple,
                 multiple,
                 bufferCoinAdd,
                 gunX=gunX)
             if catchUserId == self.player.userId:
                 catch.append(catchMap)
                 gainChip += fishGainChip
                 exp += fishExp
                 if fishGain:
                     gain.extend(fishGain)
             else:
                 otherCatch = self.table.extendOtherCatchGain(
                     fId, catchUserId, otherCatch, fishGainChip, fishGain,
                     catchMap, fishExp)
         else:
             if originHP != catchMap["HP"]:
                 catch.append(catchMap)
             fishGainChip, fishGain = self.table.dealHitBossGain(
                 self.power + self.impale, fId, self.player)
             if catchUserId == self.player.userId:
                 gainChip += fishGainChip
                 if fishGain:
                     gain.extend(fishGain)
             else:
                 otherCatch = self.table.extendOtherCatchGain(
                     fId, catchUserId, otherCatch, fishGainChip, fishGain)
     if ftlog.is_debug():
         ftlog.debug("catchFish->", "userId =", self.player.userId,
                     "catch =", catch, "gain =", gain, "onceCostCoin =",
                     self.onceCostCoin)
     for userId, catchInfo in otherCatch.iteritems():
         otherPlayer = self.table.getPlayer(userId)
         if otherPlayer:
             self.table.dealCatch(bulletId, wpId, otherPlayer,
                                  catchInfo["catch"], catchInfo["gain"],
                                  catchInfo["gainChip"], catchInfo["exp"],
                                  self.fpMultiple, self.gunSkinMultiple,
                                  self.gunX)
     return catch, gain, gainChip, exp