Exemplo n.º 1
0
 def _clearData(self, isSendMsg=True, fishType=0, isEnd=0.0):
     """
     boss出生前清理相关数据
     """
     self._isBossShowTimeStage = 0
     if self._autofillTimer:
         self._autofillTimer.cancel()
     self._autofillTimer = None
     if self._clearTimer:
         self._clearTimer.cancel()
     self._clearTimer = None
     if self._modQuitTimer:
         self._modQuitTimer.cancel()
     self._modQuitTimer = None
     # 清理鱼阵.
     if self._group and self.table.fishGroupSystem:
         self.table.deleteFishGroup(self._group)
     self._group = None
     if isEnd:
         self.addTideFishGroup(isEnd)
     if isSendMsg:
         msg = MsgPack()
         msg.setCmd("queen_end")
         msg.setResult("gameId", config.FISH_GAMEID)
         msg.setResult("roomId", self.table.roomId)
         msg.setResult("tableId", self.table.tableId)
         msg.setResult("type", "queen")
         msg.setResult("fishType", fishType)
         GameMsg.sendMsg(msg, self.table.getBroadcastUids())
Exemplo n.º 2
0
 def firstFireEffect(self, gunId):
     """开火第一颗子弹触发狂暴效果"""
     if gunId in self.useGunEffect and self.useGunEffect[gunId][
             "state"] == State.PREPARE:
         conf = config.getGunConf(gunId, self.clientId, 1, self.mode)
         self.useGunEffect[gunId] = {
             "state": State.USING,
             "start_time": float('%.2f' % time.time()),
             "progress": [0, conf["duration"]]
         }
         self.updateFireOrEnergy(gunId, idx=1, absValue=1)
         self._setData(gunId)
         data = self.gunEffectData[gunId]
         self.setUseEffectTimer(conf["duration"])  # 启动结束的定时器
         if data:
             dataTmp = deepcopy(data)
             dataTmp.pop(0)
             dataTmp.append(conf["fire_count"])
             data = dataTmp
         msg = MsgPack()
         msg.setCmd("use_gun_effect")
         msg.setResult("userId", self.userId)
         msg.setResult("gunId", gunId)
         msg.setResult("code", 0)
         msg.setResult("progressData", data)
         msg.setResult("data", self.useGunEffect[gunId])
         GameMsg.sendMsg(msg, self.table.getBroadcastUids())
         return
Exemplo n.º 3
0
def sendMiniGameProgress(table, userId, roomId):
    """
    发送断线重连后发送进度信息
    """
    roomData = getRoomMinigame(roomId, userId)
    bigRoomId, _ = util.getBigRoomId(roomId)
    if roomData and roomData.get("current", {}):
        locs = roomData.get("current", {}).get("locs", [])
        reward = roomData.get("current", {}).get("reward", [])
        msgRet = MsgPack()
        # 还没有翻完硬币/还未选择箱子
        if len(locs) < len(reward):
            msgRet = MsgPack()
            msgRet.setCmd("mini_game_continue")
            msgRet.setResult("gameState", 1)
            msgRet.setResult("gameId", FISH_GAMEID)
            msgRet.setResult("userId", userId)
            cardId = roomData.get("current", {}).get("cardId", 0)
            msgRet.setResult("locs", locs)
            msgRet.setResult("cardId", cardId)
            msgRet.setResult("reward", reward)
            totalWinCount = roomData.get("current", {}).get("totalWin", 0)
            msgRet.setResult("totalWin", [{
                "name": 101,
                "count": totalWinCount
            }])
        # 已经选择了箱子,但是还没点击转盘抽奖
        elif len(locs) == len(reward):
            msgRet.setCmd("mini_game_continue")
            msgRet.setResult("gameState", 2)
            msgRet.setResult("gameId", FISH_GAMEID)
            msgRet.setResult("userId", userId)
        GameMsg.sendMsg(msgRet, table.getBroadcastUids())
Exemplo n.º 4
0
 def sendEnergyProgress(self, level, fpMultiple, roomId, changed, fId=0):
     """
     发送轮盘进度
     """
     level = str(level)
     if level not in self.pwConf['energy']:
         level = str(self.getEnergyIdx()[0])
     if not self._enable(level, fpMultiple):
         return
     pwData = self._getData(level, fpMultiple)
     mo = MsgPack()
     mo.setCmd("prize_wheel_progress_m")
     mo.setResult("gameId", FISH_GAMEID)
     mo.setResult("userId", self.userId)
     mo.setResult("roomId", roomId)
     mo.setResult("fId", fId)
     mo.setResult("progressPct", self._getEnergyPct(
         level, fpMultiple))  # 对应段位等级的进度百分比0-100. 100时可以抽奖.
     mo.setResult("nowLevel", level)  # 当前充能的段位
     mo.setResult("state", pwData[PWValueSlot.STATE])
     mo.setResult("progressChanged",
                  changed)  # 进度变化量,大于0表示增加,小于0表示减少,0表示同步数据
     mo.setResult("curRemainTimes", pwData[PWValueSlot.SPINTIMES])
     mo.setResult(
         "is_can", 0 if self.pwConf['condition'] > gamedata.getGameAttrInt(
             self.userId, FISH_GAMEID,
             GameData.levelPrizeWheelCatchFishNumber) else 1)
     GameMsg.sendMsg(mo, self.userId)
Exemplo n.º 5
0
def changeNotify(uid, gid, attrs, broadcastUserIds=None):
    #attrs={"ud":[{},{}], "gd":[], "items":[]}
    msg = MsgPack()
    msg.setCmd("chg")
    msg.setResult("gameId", FISH_GAMEID)
    msg.setResult("userId", uid)
    if "ud" in attrs:
        ud = {}
        for item in attrs["ud"]:
            if item["name"] == "tableChip":
                from newfish.game import TGFish
                TGFish.getEventBus().publishEvent(
                    ChipChangeEvent(uid, FISH_GAMEID, 0, item["count"]))
            ud[item["name"]] = item["count"]
        msg.setResult("ud", ud)
    if "gd" in attrs:
        gd = {}
        for item in attrs["gd"]:
            gd[item["name"]] = item["count"]
        msg.setResult("gd", gd)
    if "items" in attrs:
        items = {}
        for item in attrs["items"]:
            items[item["name"]] = item["count"]
        msg.setResult("items", items)
    if broadcastUserIds:
        GameMsg.sendMsg(msg, broadcastUserIds)
    else:
        GameMsg.sendMsg(msg, uid)
Exemplo n.º 6
0
 def use_item(self, seatId, kindId, fIds, lockFid=0):
     """
     使用道具
     """
     code = self.reason(kindId, fIds, lockFid)
     msg = MsgPack()
     msg.setCmd("item_use")
     msg.setResult("gameId", config.FISH_GAMEID)
     msg.setResult("userId", self.userId)
     msg.setResult("seatId", seatId)
     msg.setResult("kindId", kindId)
     msg.setResult("code", code)
     GameMsg.sendMsg(msg, self.table.getBroadcastUids())
     if code == 0:
         if kindId == config.FREEZE_KINDID:  # 冰冻特性,有几率冰冻鱼
             self.catchFish(kindId, fIds, lockFid)
         # 使用技能道具事件
         from newfish.game import TGFish
         from newfish.entity.event import UseSkillItemEvent
         event = UseSkillItemEvent(self.player.userId, config.FISH_GAMEID,
                                   self.table.roomId, self.table.tableId,
                                   kindId)
         TGFish.getEventBus().publishEvent(event)
         self.player.triggerUseSkillItemEvent(event)
     self.player.syncSkillItemSlots(kindId)
Exemplo n.º 7
0
 def _broadcastPlayerLeave(self, userId, seatId):
     msg = MsgPack()
     msg.setCmd("leave")
     msg.setResult("gameId", FISH_GAMEID)
     msg.setResult("userId", userId)
     msg.setResult("seatId", seatId)
     GameMsg.sendMsg(msg, self.getBroadcastUids(userId))
Exemplo n.º 8
0
 def sendTideTaskStartInfo(self, userId, timeLeft):
     """
     发送限时任务开始消息
     :param userId: 玩家Id
     :param timeLeft: 剩余时间
     """
     userData = self.usersData.get(userId, {})
     task = userData.get("task")
     if userData and task:
         msg = MsgPack()
         msg.setCmd("tide_task")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("userId", userId)
         msg.setResult("action", "start")
         msg.setResult("taskId", task["taskId"])
         desc = config.getMultiLangTextConf(str(task["desc"]),
                                            lang=util.getLanguage(userId))
         if desc.find("%d") >= 0:
             if task["taskType"] == 1:
                 desc = desc % (task["targets"].get(
                     "number", 0), task["targets"].get("target"))
             elif task["taskType"] == 2:
                 desc = desc % (task["targets"].get("number"))
             elif task["taskType"] == 3:
                 desc = desc % (task["targets"].get("number"))
         msg.setResult("desc", desc)
         msg.setResult("timeLeft", timeLeft)
         msg.setResult("timeLong", task["timeLong"])
         msg.setResult("taskType", task["taskType"])
         msg.setResult("rewardType", userData["rewardType"])
         msg.setResult("targets", task["targets"])
         msg.setResult("rewards", task["rewards"])
         GameMsg.sendMsg(msg, userId)
Exemplo n.º 9
0
 def _verifyFire(self, msg, userId, seatId):
     wpId = msg.getParam("wpId")
     fPosx = msg.getParam("fPosx")
     fPosy = msg.getParam("fPosy")
     bulletId = msg.getParam("bulletId")
     skillId = msg.getParam("skillId")
     timestamp = msg.getParam("timestamp", 0)
     wpConf = config.getWeaponConf(wpId, mode=self.gameMode)
     reason = 0
     player = self.players[seatId - 1]
     wpType = util.getWeaponType(wpId)
     if wpType != config.ROBBERY_WEAPON_TYPE:
         reason = 1
     retMsg = MsgPack()
     retMsg.setCmd("fire")
     retMsg.setResult("gameId", FISH_GAMEID)
     retMsg.setResult("wpId", wpId)
     retMsg.setResult("bulletId", bulletId)
     retMsg.setResult("skillId", skillId)
     retMsg.setResult("timestamp", timestamp)
     retMsg.setResult("reason", reason)
     GameMsg.sendMsg(retMsg, userId)
     if reason == 0:
         retMsg.setResult("fPosx", fPosx)
         retMsg.setResult("fPosy", fPosy)
         retMsg.setResult("seatId", seatId)
         GameMsg.sendMsg(retMsg, self.getBroadcastUids(userId))
         player.addFire(bulletId, wpId, timestamp, player.fpMultiple)
Exemplo n.º 10
0
 def _clearData(self, isSendMsg=True, fishType=0, isEnd=0.0):
     """
     boss出生前清理相关数据
     """
     self._isBossShowTimeStage = 0
     self._hasBorned = []
     for _timer in self._autofillTimer.values():
         if _timer:
             _timer.cancel()
             _timer = None
     self._autofillTimer = {}
     if self._clearTimer:
         self._clearTimer.cancel()
         self._clearTimer = None
     # 清理鱼阵.
     for _group in self._group.values():
         if _group and self.table.fishGroupSystem:
             self.table.deleteFishGroup(_group)
     self._group = {}
     if isEnd:
         self.addTideFishGroup(isEnd)
     if isSendMsg:
         msg = MsgPack()
         msg.setCmd("superboss_end")
         msg.setResult("gameId", config.FISH_GAMEID)
         msg.setResult("roomId", self.table.roomId)
         msg.setResult("tableId", self.table.tableId)
         msg.setResult("type", "box")  # 宝箱
         msg.setResult("fishType", fishType)  # 鱼Id
         GameMsg.sendMsg(msg, self.table.getBroadcastUids())
Exemplo n.º 11
0
 def _updateFriendInfo(self, userId):
     """更新好友消息"""
     ftPlayer = self.getPlayer(self.ftTable.userId)
     ftName = ""
     if ftPlayer:
         ftName = ftPlayer.name
     player = self.getPlayer(userId)
     if player and player.userId:
         msg = MsgPack()
         msg.setCmd("ft_info")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("roomId", self.roomId)
         msg.setResult("tableId", self.tableId)
         msg.setResult("seatId", player.seatId)
         msg.setResult("userId", player.userId)
         msg.setResult("tableState", self._tableState)
         msg.setResult("reward", self.ftTable.fee)
         msg.setResult("ftId", self.ftTable.ftId)
         msg.setResult("ftUserName", ftName)
         msg.setResult("ftUserId", self.ftTable.userId)
         msg.setResult("timeLong", self.runConfig.playingTime)
         msg.setResult(
             "expirseTime",
             int(self._expiresTimer.getTimeOut())
             if self._expiresTimer else self._tableExpiresTime)
         msg.setResult("targets", self.targets)
         GameMsg.sendMsg(msg, player.userId)
Exemplo n.º 12
0
 def sendCmpttTaskInfo(self):
     """
     发送夺宝赛任务倒计时信息
     """
     userIds = []
     for uid in self.table.getBroadcastUids():
         if util.isFinishAllNewbieTask(uid):
             userIds.append(uid)
     if self.sendInfoTimer:
         self.sendInfoTimer.cancel()
     if not userIds:
         return
     if self.state == 0:
         self.sendInfoTimer = FTLoopTimer(self.sendInfoTime, 0,
                                          self.sendCmpttTaskInfo)
         self.sendInfoTimer.start()
     else:
         return
     timeLeft = int(
         self.taskInterval) - int(time.time() - self.recordReloadTime)
     if timeLeft <= 0:
         return
     msg = MsgPack()
     msg.setCmd("cmptt_task")
     msg.setResult("gameId", FISH_GAMEID)
     msg.setResult("action", "info")
     msg.setResult("timeLeft", timeLeft)
     GameMsg.sendMsg(msg, userIds)
Exemplo n.º 13
0
 def sendNcmpttTaskStartInfo(self, userId, timeLeft):
     """
     发送限时任务开始消息
     :param userId: 玩家Id
     :param timeLeft: 剩余时间
     """
     userData = self.usersData.get(userId, {})
     task = userData.get("task")
     if userData and task:
         msg = MsgPack()
         msg.setCmd("ncmptt_task")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("userId", userId)
         msg.setResult("action", "start")
         msg.setResult("taskId", task["taskId"])
         desc = config.getMultiLangTextConf(str(task["desc"]),
                                            lang=util.getLanguage(userId))
         if desc.find("%d") >= 0:
             desc = desc % (task["targets"].get("target1")
                            or task["targets"].get("number1", 0))
         msg.setResult("desc", desc)
         msg.setResult("timeLeft", timeLeft)
         msg.setResult("timeLong", task["timeLong"])
         msg.setResult("taskType", task["taskType"])
         msg.setResult("rewardType", userData["rewardType"])
         msg.setResult("targets", task["targets"])
         msg.setResult("reward", {"name": task["chestReward"], "count": 1})
         GameMsg.sendMsg(msg, userId)
Exemplo n.º 14
0
def sendGrandPrizeReward(roomId, tableId, userId, fId, coinCount, level,
                         seatId, fpMultiple):
    """
    发放巨奖奖励
    """
    try:
        rewards = [{"name": config.CHIP_KINDID, "count": coinCount}]
        room = gdata.rooms()[roomId]
        table = room.maptable[tableId]
        player = table.getPlayer(userId)

        msg = MsgPack()
        msg.setCmd("getGrandPrizeRewards")
        msg.setResult("gameId", FISH_GAMEID)
        msg.setResult("userId", userId)
        msg.setResult("fId", fId)
        msg.setResult("rewards", rewards)
        msg.setResult("level", level)
        msg.setResult("seatId", seatId)
        msg.setResult("fpMultiple", fpMultiple)
        GameMsg.sendMsg(msg, table.getBroadcastUids())

        if player:
            for bigRoomId in config.getGrandPrizeConf().get("roomIds", []):
                player.fireCost[str(bigRoomId)] = 0
            name = player.name
            player.addTableChip(coinCount, "BI_NFISH_GRAND_PRIZE")
            player.totalGainChip += coinCount
            # 深海巨奖触发幸运降临
            table.checkBigPrize(player,
                                coinCount // fpMultiple,
                                coinCount,
                                fpMultiple,
                                isGrandPriz=True)
        else:
            from poker.entity.dao import gamedata
            from newfish.entity.redis_keys import GameData
            fireCost = gamedata.getGameAttrJson(userId, FISH_GAMEID,
                                                GameData.fireCost, {})
            for bigRoomId in config.getGrandPrizeConf().get("roomIds", []):
                fireCost[str(bigRoomId)] = 0
            gamedata.setGameAttr(userId, FISH_GAMEID, GameData.fireCost,
                                 json.dumps(fireCost))
            name = util.getNickname(userId)
            util.addRewards(userId, rewards, "BI_NFISH_GRAND_PRIZE", roomId)

        leds = [
            "ID_LED_GRAND_PRIZE_1", "ID_LED_GRAND_PRIZE_2",
            "ID_LED_GRAND_PRIZE_3"
        ]
        if len(leds) > level >= 0:
            lang = util.getLanguage(userId)
            msg = config.getMultiLangTextConf(leds[level], lang=lang) % \
                  (name, config.getMultiLangTextConf(table.runConfig.title, lang=lang), util.formatScore(coinCount, lang=lang))
            user_rpc.sendLed(FISH_GAMEID, msg, id=leds[level], lang=lang)
    except Exception as e:
        ftlog.error("sendGrandPrizeReward", roomId, tableId, userId, fId,
                    coinCount, traceback.format_exc())
    return 0
Exemplo n.º 15
0
 def sendAddGroupMsg(self, groups, userIds):
     """
     发送新增鱼群消息
     """
     msg = MsgPack()
     msg.setCmd("add_group")
     msg.setResult("gameId", FISH_GAMEID)
     msg.setResult("groups", groups)
     GameMsg.sendMsg(msg, userIds)
Exemplo n.º 16
0
    def endGrandPrix(self):
        """
        大奖赛结束
        """
        if self.userId == 0:
            return

        if self.grandPrixEndTimer:
            self.grandPrixEndTimer.cancel()
            self.grandPrixEndTimer = None

        if not self.isGrandPrixMode():
            return

        grandPrixFinalPoint = self.saveGrandPrixPoint()
        # 完成大奖赛事件
        event = FinishGrandPrixEvent(self.userId, FISH_GAMEID,
                                     self.table.bigRoomId, grandPrixFinalPoint)
        TGFish.getEventBus().publishEvent(event)
        bireport.reportGameEvent("BI_NFISH_GRAND_PRIX_END", self.userId,
                                 FISH_GAMEID, 0, 0, grandPrixFinalPoint, 0, 0,
                                 0, [], util.getClientId(self.userId))
        if self.inGameTimes:
            bireport.reportGameEvent("BI_NFISH_GRAND_PRIX_INGAMETIMES",
                                     self.userId, FISH_GAMEID, 0, 0,
                                     self.grandPrixStartTS, self.inGameTimes,
                                     0, 0, [], util.getClientId(self.userId))
            self.inGameTimes = 0

        self.cancelUsingSkills()  # 恢复技能数据 取消处于使用中的技能
        self.unloadSkills()  # 下载所有技能
        self._resetGrandPrixData()  # 重置数据存档
        self.loadAllSkillData()  # 重新加载技能 读取并初始化所有技能数据
        self.syncSkillSlots()  # 同步技能槽消息
        rank, rankRewards = ranking_system.getUserRankAndRewards(
            RankType.TodayGrandPrix, self.userId)
        if ftlog.is_debug():
            ftlog.debug("endGrandPrix", self.grandPrixStartTS,
                        self.grandPrixFireCount, self.grandPrixFishPoint)
        mo = MsgPack()
        mo.setCmd("end_grand_prix")
        mo.setResult("gameId", FISH_GAMEID)
        mo.setResult("userId", self.userId)
        mo.setResult("seatId", self.seatId)
        mo.setResult("fishPoint", grandPrixFinalPoint)
        mo.setResult("rank", rank)
        mo.setResult("rankRewards", rankRewards)
        mo.setResult("fee", config.getGrandPrixConf("fee"))
        mo.setResult(
            "tabs",
            ranking_system.getRankingTabs(self.userId,
                                          util.getClientId(self.userId),
                                          RankType.TodayGrandPrix,
                                          rankDetail=True))
        GameMsg.sendMsg(mo, self.userId)
        self.sendGrandPrixInfo()
        self.table.clearPlayer(self)  # 从桌子中踢掉玩家
Exemplo n.º 17
0
 def _chat(self, isFace=1):
     chatMsg = random.choice(self.exp)
     mo = MsgPack()
     mo.setCmd("table_chat")
     mo.setResult("gameId", FISH_GAMEID)
     mo.setResult("userId", self.userId)
     mo.setResult("seatId", self.seatId)
     mo.setResult("isFace", isFace)
     mo.setResult("chatMsg", chatMsg)
     GameMsg.sendMsg(mo, self.table.getBroadcastUids())
 def setRewards(self, fpMultiple, bet, betType=None):
     """
     确定转盘奖励结果
     """
     rewards = []
     fishPool = str(self.fishPool)
     pwData = self._getData(fishPool, fpMultiple)
     prizeConf = self.getPrizeConf(fishPool, fpMultiple)
     weightList = []
     if self._enable(fishPool, fpMultiple):
         for idx, item in enumerate(prizeConf.get("wheel", [])):
             enable = 1 if idx not in pwData[PWValueSlot.TAKEN] else 0
             weightList.append(item["rate"] if enable else 0)
     code = 1
     if pwData[PWValueSlot.STATE] in [
             PWState.NOT_TAKE_REWARD, PWState.FAIL_SPIN
     ] and len(pwData[PWValueSlot.RET]) > 0:
         if pwData[PWValueSlot.
                   STATE] == PWState.NOT_TAKE_REWARD and betType == "bet":
             for item in pwData[PWValueSlot.RET]:
                 if item["ratio"] == bet:
                     try:
                         rewards = [item["rewards"][item["ret"]]]
                         if rewards and rewards[0].get("count",
                                                       0) > 0:  # 抽奖成功,获得奖励
                             code = util.addRewards(
                                 self.userId, rewards,
                                 "BI_NFISH_PRIZE_WHEEL_REWARDS",
                                 int(fishPool), self.roomId, fpMultiple)
                             self.addRoomLotteryProfitCoin(rewards)
                         else:
                             if ftlog.is_debug():
                                 ftlog.debug("prize_wheel, userId =",
                                             self.userId, "fishPool =",
                                             fishPool, "bet =", bet, code,
                                             "data =",
                                             pwData[PWValueSlot.RET])
                         self._resetPrizeWheelState(fishPool, fpMultiple)
                     except:
                         ftlog.error("prize_wheel, userId =", self.userId,
                                     "fishPool =", fishPool, "bet =", bet,
                                     code, "data =",
                                     pwData[PWValueSlot.RET])
                     break
     self._setData(fishPool, fpMultiple)
     mo = MsgPack()
     mo.setCmd("prize_wheel_bet")
     mo.setResult("betType", betType)
     mo.setResult("gameId", FISH_GAMEID)
     mo.setResult("userId", self.userId)
     mo.setResult("code", code)
     mo.setResult("bet", bet)
     mo.setResult("rewards", rewards)
     GameMsg.sendMsg(mo, self.userId)
     self.sendEnergyProgress(self.fishPool, fpMultiple, self.roomId, 0)
Exemplo n.º 19
0
 def sendGrandPrixInfo(self):
     """
     发送大奖赛信息 大奖赛相关信息(进入渔场后服务器主动推送)
     """
     if not grand_prix.isGrandPrixOpenTime():  # 是否为大奖赛开放时段 00:00 —— 23:00
         self._resetGrandPrixData()
         self._freeTimes = 0  # 免费次数
         weakdata.setDayFishData(self.userId,
                                 WeakData.grandPrix_getPointsInfo,
                                 json.dumps([]))
         weakdata.setDayFishData(self.userId, WeakData.grandPrix_freeTimes,
                                 self._freeTimes)
     if ftlog.is_debug():
         ftlog.debug("sendGrandPrixInfo", self.grandPrixStartTS,
                     self.isGrandPrixMode())
     signUpState = 1 if self.isGrandPrixMode() else 0  # 是否已经报名
     remainFreeTimes = config.getVipConf(self.vipLevel).get(
         "grandPrixFreeTimes", 0) - self._freeTimes  # 剩余免费次数
     openTime = "-".join(config.getGrandPrixConf("openTimeRange"))  # 时间范围
     mo = MsgPack()
     mo.setCmd("grand_prix_info")
     mo.setResult("gameId", FISH_GAMEID)
     mo.setResult("userId", self.userId)
     mo.setResult("seatId", self.seatId)
     mo.setResult("remainFreeTimes", remainFreeTimes)
     mo.setResult("fee", config.getGrandPrixConf("fee"))  # 报名费
     mo.setResult("openTime", openTime)  # 00:00 - 23:00
     mo.setResult(
         "isInOpenTime",
         1 if grand_prix.isGrandPrixOpenTime() else 0)  # 大奖在是否在开放时间段
     mo.setResult("signUpState", signUpState)  # 是否已报名大奖赛
     mo.setResult(
         "todayRankType",
         RankType.TodayGrandPrix)  # 今日榜Type,使用fish_ranking获取排行榜数据,下同
     mo.setResult("todayDate", util.timestampToStr(int(time.time()),
                                                   "%m/%d"))  # 今日榜时间
     mo.setResult("yesterdayRankType", RankType.LastGrandPrix)
     mo.setResult("yesterdayDate",
                  util.timestampToStr(int(time.time() - 86400), "%m/%d"))
     mo.setResult(
         "des",
         config.getMultiLangTextConf(
             config.getGrandPrixConf("info").get("des"),
             lang=self.lang))  # 每日积分超过2400送100珍珠,今日榜单每10分钟刷新1次,最终排名00:00公布
     mo.setResult("pointsInfo", grand_prix.getPointInfo(
         self.userId))  # 奖励积分 道具Id、道具数量、是否领取了奖励0|1
     mo.setResult("todayMaxPoints",
                  weakdata.getDayFishData(self.userId,
                                          WeakData.grandPrix_point,
                                          0))  # 今日最高积分
     GameMsg.sendMsg(mo, self.userId)
     if ftlog.is_debug():
         ftlog.debug("FishGrandPrixPlayer, userId =", self.userId, "mo =",
                     mo)
Exemplo n.º 20
0
 def sendOctopusFaceInfo(self, state):
     """
     发送章鱼表情信息
     """
     if self._state == Octopus.ST_APPEARED:
         msg = MsgPack()
         msg.setCmd("octopus_face")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("roomId", self.table.roomId)
         msg.setResult("tableId", self.table.tableId)
         msg.setResult("state", state)
         GameMsg.sendMsg(msg, self.table.getBroadcastUids())
Exemplo n.º 21
0
 def clearWave(self):
     """
     清屏波浪
     """
     msg = MsgPack()
     msg.setCmd("clear_wave")
     msg.setResult("gameId", FISH_GAMEID)
     msg.setResult("roomId", self.table.roomId)
     msg.setResult("tableId", self.table.tableId)
     GameMsg.sendMsg(msg, self.table.getBroadcastUids())
     # 清屏波浪结束后出现鱼潮
     FTLoopTimer(2.5, 0, self._addTideFishGroup).start()
Exemplo n.º 22
0
    def taskEnd(self, *args, **kwargs):
        """
        任务结束
        """
        if int(args[0]) in self.userIds:
            uid = int(args[0])
            ranks = self._getRanks(uid)
            reward = False
            dropItems = None
            player = None
            task = self.usersData[uid]["task"]
            _taskId = task["taskId"]
            userData = self.usersData[uid]
            userData["state"] = TaskState.TS_End
            ftlog.debug("ncmptt->taskEnd1 = ", args[0], kwargs, ranks,
                        userData)
            if ranks and self._checkFinished(userData):
                reward = True
                player = self.table.getPlayer(uid)
                if userData["rewardType"] == 1:
                    rewardDropId = task["chestReward"]
                else:
                    rewardDropId = task["coinReward"]
                # dropType, dropItem = drop_system.getDropItem(rewardDropId)
                dropItems = self._sendTaskReward(player, 1, rewardDropId,
                                                 self.userIds)
                # 限时任务获奖
                from newfish.game import TGFish
                from newfish.entity.event import WinNcmpttTaskEvent
                event = WinNcmpttTaskEvent(player.userId, FISH_GAMEID,
                                           self.table.roomId,
                                           self.table.tableId)
                TGFish.getEventBus().publishEvent(event)

            msg = MsgPack()
            msg.setCmd("ncmptt_task")
            msg.setResult("gameId", FISH_GAMEID)
            msg.setResult("userId", uid)
            msg.setResult("action", "finish")  # 完成奖励
            msg.setResult("taskId", task["taskId"])
            msg.setResult("taskType", task["taskType"])
            msg.setResult("ranks", ranks)
            if reward:
                if player:
                    msg.setResult("reward", dropItems)
                else:
                    ftlog.warn("ncmptt->taskEnd cannot get player taskId =",
                               self.taskId, "ranks =", ranks)
            GameMsg.sendMsg(msg, uid)
            self.clearTaskData(uid)
            if _taskId and self.table.ttAutofillFishGroup:
                self.table.ttAutofillFishGroup.endAutofill(uid, _taskId)
Exemplo n.º 23
0
 def _sendRanksInfo(self):
     """
     发送排名信息
     """
     if self.currentTask:
         msg = MsgPack()
         msg.setCmd("cmptt_task")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("action", "rank")
         msg.setResult("taskId", self.currentTask["taskId"])
         msg.setResult("taskType", self.currentTask["taskType"])
         msg.setResult("ranks", self._getRanks())
         GameMsg.sendMsg(msg, self.userIds)
Exemplo n.º 24
0
 def sendDragonStormMsg(self):
     """
     发送冰冻风暴消息
     """
     msg = MsgPack()
     msg.setCmd("dragon_storm")
     msg.setResult("gameId", FISH_GAMEID)
     msg.setResult("roomId", self.table.roomId)
     msg.setResult("tableId", self.table.tableId)
     msg.setResult("rounds", [self.currentRound, self.totalRound])
     msg.setResult("bulletId", self.fishId)
     msg.setResult("catchUserId", self.catchUserId)
     GameMsg.sendMsg(msg, self.table.getBroadcastUids())
Exemplo n.º 25
0
 def taskReady(self, *args):
     """
     任务准备
     :param args:
     """
     tasks = config.getNcmpttTaskConf(self.table.runConfig.fishPool)
     if len(tasks) == 0 or len(self.table.getBroadcastUids()) == 0:
         endTimer = FishTableTimer(self.table)
         endTimer.setup(0, "task_end", {"uid": 0, "task": self.taskName})
         return
     self.taskId = "%d-%d" % (self.table.tableId, int(time.time()))
     for uid in self.table.getBroadcastUids():
         if util.isFinishAllRedTask(uid):  # 获得所有已完成的引导
             self.userIds.append(uid)
     for uid in self.userIds:
         randTask = random.choice(tasks)
         task = copy.deepcopy(randTask)
         # player = self.table.getPlayer(uid)                                # 火炮装扮减少任务鱼数量(暂时不用)
         # if player:
         # if player.gunSkinId in self.wpFishNumScale.keys():
         #     fNumScale = self.wpFishNumScale.get(player.gunSkinId, 1)
         #     for fId in task["targets"]:
         #         fNum = task["targets"][fId]["fishNum"]
         #         fNum = int(round(int(fNum) * fNumScale))
         #         fNum = fNum if fNum >= 1 else 1
         #         task["targets"][fId]["fishNum"] = fNum
         targets = task["targets"]
         readySeconds = task["readySeconds"]
         state = TaskState.TS_Ready  # 任务即将开始
         self.usersData[uid] = {
             "uid": uid,
             "task": task,
             "targets": targets,
             "state": state,
             "rewardType": 1,
             "results": {}
         }
         msg = MsgPack()
         msg.setCmd("ncmptt_task")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("userId", uid)
         msg.setResult("action", "ready")
         msg.setResult("taskId", task["taskId"])
         msg.setResult("taskType", task["taskType"])
         GameMsg.sendMsg(msg, uid)
         startTimer = FishTableTimer(self.table)
         self.userStartTimer[uid] = startTimer
         startTimer.setup(readySeconds, "task_start", {
             "uid": uid,
             "task": self.taskName
         })
Exemplo n.º 26
0
 def _updateMatchRank(self, userId):
     """比赛排名"""
     player = self.getPlayer(userId)
     if player and player.userId and self._match_table_info:
         msg = MsgPack()
         msg.setCmd("m_update")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("roomId", self.roomId)
         msg.setResult("tableId", self.tableId)
         msg.setResult("seatId", player.seatId)
         msg.setResult("userId", player.userId)
         msg.setResult("rank",
                       [player.rank, self._match_table_info["playerCount"]])
         GameMsg.sendMsg(msg, player.userId)
Exemplo n.º 27
0
 def _updateMatchTask(self, userId):
     """更新比赛任务"""
     player = self.getPlayer(userId)
     usersData = self._usersData.get(userId, {})
     if player and usersData and usersData["results"]:
         msg = MsgPack()
         msg.setCmd("m_task")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("roomId", self.roomId)
         msg.setResult("tableId", self.tableId)
         msg.setResult("seatId", player.seatId)
         msg.setResult("userId", player.userId)
         msg.setResult("targets", usersData["results"])
         GameMsg.sendMsg(msg, player.userId)
Exemplo n.º 28
0
 def syncOctopusState(self, userId=0):
     """
     向玩家同步巨型章鱼状态
     """
     if Octopus.ST_IDLE < self._state < Octopus.ST_FINAL:
         msg = MsgPack()
         msg.setCmd("octopus_info")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("roomId", self.table.roomId)
         msg.setResult("tableId", self.table.tableId)
         msg.setResult("state", self.state)
         msg.setResult("progress", self.getCurrentStateStageTime())
         GameMsg.sendMsg(msg, userId or self.table.getBroadcastUids())
         if ftlog.is_debug():
             ftlog.debug("syncOctopusState", self.table.tableId, msg)
Exemplo n.º 29
0
 def dealEnterTable(self, userId):
     """
     玩家进入渔场时发送
     """
     # 当前阶段boss开始出现的时间戳.
     startTS = 0
     if self._isBossShowTimeStage & 0x111 != 0:
         startTS = self._startTS
     msg = MsgPack()
     msg.setCmd("box_info")
     msg.setResult("gameId", config.FISH_GAMEID)
     msg.setResult("roomId", self.table.roomId)
     msg.setResult("tableId", self.table.tableId)
     msg.setResult("startTS", startTS)
     GameMsg.sendMsg(msg, userId)
Exemplo n.º 30
0
    def taskEnd(self, *args, **kwargs):
        """
        任务结束
        """
        if self.state == 0:
            self.clear()
            return
        self.state = 0
        _taskId = 0
        if self.currentTask:
            _taskId = self.currentTask["taskId"]
            ranks = kwargs.get("ranks")
            if not ranks:
                ranks = self._getRanks()
            reward = False
            dropItems = None
            player = None
            rewardDropId = 0
            rewardItem = 0
            if ranks:
                usersData = self.usersData.get(ranks[1]["uid"])
                if self._checkFinished(usersData):
                    reward = True
                    player = self.table.getPlayer(ranks[1]["uid"])
                    dropItems = self._sendTaskReward(player,
                                                     self.chestRewardId,
                                                     self.userIds)
                    # 夺宝赛获奖
                    from newfish.game import TGFish
                    from newfish.entity.event import WinCmpttTaskEvent
                    event = WinCmpttTaskEvent(player.userId, FISH_GAMEID,
                                              self.table.roomId,
                                              self.table.tableId)
                    TGFish.getEventBus().publishEvent(event)

            msg = MsgPack()
            msg.setCmd("cmptt_task")
            msg.setResult("gameId", FISH_GAMEID)
            msg.setResult("action", "finish")
            msg.setResult("taskId", self.currentTask["taskId"])
            msg.setResult("taskType", self.currentTask["taskType"])
            msg.setResult("ranks", ranks)
            if reward and player:
                msg.setResult("reward", dropItems)
            GameMsg.sendMsg(msg, self.userIds)
        self.clearTaskData()
        if _taskId and self.table.ttAutofillFishGroup:
            self.table.ttAutofillFishGroup.endAutofill(0, _taskId)