def pushHonor(userId, honorId): """ 获得称号时推送 """ mo = MsgPack() mo.setCmd("honor_push") mo.setResult("gameId", FISH_GAMEID) mo.setResult("userId", userId) # mo.setResult("honors", getHonorList(userId)) router.sendToUser(mo, userId) isIn, roomId, tableId, seatId = util.isInFishTable(userId) if isIn: mo = MsgPack() mo.setCmd("table_call") mo.setParam("action", "honor_push") mo.setParam("gameId", FISH_GAMEID) mo.setParam("clientId", util.getClientId(userId)) mo.setParam("userId", userId) mo.setParam("roomId", roomId) mo.setParam("tableId", tableId) mo.setParam("seatId", seatId) router.sendTableServer(mo, roomId) from newfish.game import TGFish event = GetHonorEvent(userId, FISH_GAMEID, honorId) TGFish.getEventBus().publishEvent(event)
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)
def __init__(self, roomDefine): super(FishNewbieRoom, self).__init__(roomDefine) if ftlog.is_debug(): ftlog.debug("FishNewbieRoom->", gdata.serverType(), self.roomDefine.shadowRoomIds) self._keyLock = KeyLock() if gdata.serverType() == gdata.SRV_TYPE_ROOM: # GR进程 self.shadowRoomIdOccupyList = [[ shadowRoomId, 0, [] ] for shadowRoomId in self.roomDefine.shadowRoomIds] self.shadowRoomIdOccupyList.sort(key=lambda x: x[0]) self.tableSeatDetails = {} if gdata.serverType() == gdata.SRV_TYPE_TABLE: # GT进程 self._allTableDict = {} # tableId: table self._allPlayerDict = {} # userId: tableId self._allTableSeatDict = {} # tableId: set() self._usableTableDict = {} # taskId: [tableId, tableId1] FTLoopTimer(self.roomConf.get("occupyIntervalSeconds", 3), -1, self._reportRoomUserOccupy).start() from newfish.game import TGFish from newfish.entity.event import EnterTableEvent, LeaveTableEvent TGFish.getEventBus().subscribe(EnterTableEvent, self._triggerEnterTableEvent) TGFish.getEventBus().subscribe(LeaveTableEvent, self._triggerLeaveTableEvent)
def addShareInvitedUserId(shareUserId, invitedUserId, isNewUser=False): """ 添加分享邀请人信息 :param shareUserId: 分享卡片的分享者 :param invitedUserId: 点击卡片的被邀请者 :param isNewUser: 是否为新用户 """ inviteCount = weakdata.getDayFishData(shareUserId, "inviteCount", 0) if inviteCount < config.getCommonValueByKey("inviteLimitCount", 99999): if not isNewUser: inviteOldUserCount = weakdata.getDayFishData(shareUserId, "inviteOldUserCount", 0) if inviteOldUserCount > config.getCommonValueByKey("inviteLimitOldCount", 99999): return weakdata.incrDayFishData(shareUserId, "inviteOldUserCount", 1) inviteList = gamedata.getGameAttrJson(shareUserId, FISH_GAMEID, GameData.inviteList, []) inviteId = gamedata.incrGameAttr(shareUserId, FISH_GAMEID, GameData.inviteId, 1) inviteData = { "inviteId": inviteId, "userId": invitedUserId, "inviteTime": int(time.time()), "isNewUser": isNewUser, "isAppUser": 1 if util.isAppClient(invitedUserId) else 0 } inviteList.append(inviteData) gamedata.setGameAttr(shareUserId, FISH_GAMEID, GameData.inviteList, json.dumps(inviteList)) weakdata.incrDayFishData(shareUserId, "inviteCount", 1) module_tip.addModuleTipEvent(shareUserId, "invite", inviteId) getShareTaskInfo(shareUserId) from newfish.game import TGFish from newfish.entity.event import InvitedFinishEvent event = InvitedFinishEvent(shareUserId, FISH_GAMEID) TGFish.getEventBus().publishEvent(event)
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)
def loginByInvited(userId, shareUserId, isNewPlayer): """ :param userId: 被邀请人 :param shareUserId: 分享者(邀请人) :param isNewPlayer: 是否为新用户 """ isCanInvite = config.getCommonValueByKey("canInvite") isInvite = weakdata.getDayFishData(userId, "isInvited", 0) if not isCanInvite or isInvite: return False userdata.checkUserData(shareUserId) if isNewPlayer: from newfish.game import TGFish from newfish.entity.event import AddInvitedNewUserEvent # 存储邀请人信息 from hall.entity import hallvip from newfish.entity.redis_keys import GameData shareUserVip = int(hallvip.userVipSystem.getUserVip(shareUserId).vipLevel.level) inviterInfo = { "userId": shareUserId, "inviteTime": int(time.time()), "vip": shareUserVip } gamedata.setGameAttr(userId, FISH_GAMEID, GameData.inviterInfo, json.dumps(inviterInfo)) saveKey = "inviteNewPlayers" actionType = NewPlayerAction event = AddInvitedNewUserEvent(shareUserId, FISH_GAMEID, userId) TGFish.getEventBus().publishEvent(event) else: saveKey = "recallPlayers" actionType = RecallPlayerAction user_rpc.addInviteNum(shareUserId, userId, actionType, saveKey, isNewPlayer) return True
def taskStart(self, interval=0, delay=0): """ 任务开始 """ if ftlog.is_debug(): ftlog.debug("taskBase_______taskStart", self.taskId) if self.taskActivateTimer: self.taskActivateTimer.cancel() if delay > 0: taskActivateInterval = max(interval, Task_Delay_Ready_Time) self.taskActivateTimer = FTLoopTimer(taskActivateInterval, 0, self._taskActivate, delay) self.taskActivateTimer.start() elif self.taskConfig["timeLong"] > 0: if util.isNewbieRoom(self.player.table.typeName) and self.taskSystem.taskModel == TaskModel.Main: time_ = Task_Red_Ready_Time else: time_ = Task_Normal_Ready_Time taskActivateInterval = max(interval, time_) taskInfoInterval = max(interval - time_, 0) self.delaySendUserTaskInfo(taskInfoInterval) self.taskActivateTimer = FTLoopTimer(taskActivateInterval, 0, self._taskActivate) self.taskActivateTimer.start() else: self.taskActivateTimer = FTLoopTimer(interval, 0, self._taskActivate) self.taskActivateTimer.start() from newfish.game import TGFish from newfish.entity.event import TableTaskStartEvent event = TableTaskStartEvent(self.userId, FISH_GAMEID, self.taskSystem.table.tableId, self.getTaskId()) TGFish.getEventBus().publishEvent(event)
def _sendTaskReward(self, player, dropType, dropItem, broadcastUserIds): """ 发送任务奖励 """ dropItems = None if dropType == 1: # 宝箱 chestRewards = chest_system.getChestRewards( player.userId, dropItem) util.addRewards(player.userId, chestRewards, "BI_NFISH_NCMPTT_TASK_REWARDS", roomId=self.table.roomId, tableId=self.table.tableId) dropItems = { "chest": dropItem, "chestRewards": chestRewards, "chip": 0, "type": 0 } from newfish.game import TGFish from newfish.entity.event import GainChestEvent from newfish.entity.chest.chest_system import ChestFromType event = GainChestEvent(player.userId, FISH_GAMEID, dropItem, ChestFromType.Cmptt_Ncmptt_Bonus_Task) TGFish.getEventBus().publishEvent(event) # chest_system.newChestItem(player.userId, dropItem["name"], "BI_NFISH_NCMPTT_TASK_REWARDS", self.table.roomId) elif dropType == 2: # 金币 dropItems = {"chest": 0, "chip": dropItem["count"], "type": 1} rewards = [{"name": "tableChip", "count": dropItem["count"]}] util.addRewards(player.userId, rewards, "BI_NFISH_NCMPTT_TASK_REWARDS", self.table.roomId) return dropItems
def taskEnd(self): """ 任务结束 """ if ftlog.is_debug(): ftlog.debug("taskBase_______taskEnd", self.taskId, self.userId, self.taskData["state"]) beforeState = self.taskData["state"] self.clear() if beforeState == TaskState.Update: isComplete = self._isComplete() if isComplete: _, rewards = self._receiveTaskReward() self.receiveRewards = rewards self.taskSystem.saveRedState() # 保存红包 else: self.taskSystem.taskExpedite = 1 self.taskData["state"] = TaskState.Fail if self.isLimitTime(): self.taskData["failTime"] += 1 from newfish.game import TGFish from newfish.entity.event import TableTaskEndEvent event = TableTaskEndEvent(self.userId, FISH_GAMEID, self.taskSystem.table.tableId, self.getTaskId(), isComplete, self.isLimitTime(), self.receiveRewards) TGFish.getEventBus().publishEvent(event) # 上传当前完成任务进度 if self.taskSystem.taskModel == TaskModel.Main and self.taskSystem.isRedRoom(): ftlog.debug("BI_NFISH_THOUSAND_RED_TASK_PROGRESS--->000", self.getTaskId()) bireport.reportGameEvent("BI_NFISH_GE_THOUSAND_RED_TASK", self.userId,FISH_GAMEID, self.taskSystem.table.roomId, self.taskSystem.table.tableId, self.getTaskId(), int(isComplete), 0, 0, [], config.CLIENTID_ROBOT) # 新手引导步骤完成 if self.taskConfig["type"] == TaskType.UpgradeLevel: util.addGuideStep(self.player.userId, config.NEWBIE_GUIDE_GUN_UP, self.player.clientId) self.sendUserTaskInfo()
def _registerEvent(self): """ 注册监听事件 """ from newfish.game import TGFish TGFish.getEventBus().subscribe(EnterTableEvent, self._dealEnterTable) TGFish.getEventBus().subscribe(LeaveTableEvent, self._dealLeaveTable)
def addOneMail(senderUserId, receiverUserId, mailRewardType, rewards=None, message=None, title=None): """ 添加一封邮件 :param senderUserId: 发件人 :param receiverUserId: 收件人 :param mailRewardType: 邮件类型 :param rewards: 附件奖励 :param message: 邮件内容 :param title: 标题 :return: 是否添加成功 """ if ftlog.is_debug(): ftlog.debug("addOneMail->", senderUserId, receiverUserId, mailRewardType, rewards, message, title) message = message or "" rewards = rewards or [] title = title or "" # # 查询收件人信息 # _key = GameData.mailInfos if senderUserId == config.ROBOT_MAX_USER_ID else GameData.userMailInfos # mailInfos = gamedata.getGameAttrJson(receiverUserId, FISH_GAMEID, _key, []) # mailInfos = _removeMailExpData(mailInfos, MAIL_DISPLAY_COUNT) # tempMail = _getUnDeleteMail(mailInfos[0:MAIL_DISPLAY_COUNT]) # if len(tempMail) >= MAIL_DISPLAY_COUNT and mailRewardType == MailRewardType.Present: # 收件箱已满 # return False # 添加邮件到发件人发件箱 if senderUserId > config.ROBOT_MAX_USER_ID: _sendMailBySender(senderUserId, receiverUserId, mailRewardType, rewards, message, title) # 添加邮件到收件人收件箱 user_rpc.sendMailToReceiver(senderUserId, receiverUserId, mailRewardType, rewards, message, title) from newfish.game import TGFish event = SendMailEvent(senderUserId, FISH_GAMEID, receiverUserId, rewards) TGFish.getEventBus().publishEvent(event) return True
def upgradeMaxSkill(userId, expendItemId, clientId): """ 技能升级满级 """ if config.getItemConf(clientId, expendItemId).get("up_skill", 0) == 0: return 7, 0, 0, 0, 0 actions = config.getItemConf(clientId, expendItemId).get("actions", 0) skillId = 0 for it in actions: if it["action"] == "up_skill": skillId = int(it["params"][0]["skillId"]) break if not skillId: return 8, 0, 0, 0, 0 actionType = 0 userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag() code, skill = checkSkillStatus(userId, skillId) if code != 0: return code, 0, 0, 0, 0 if skill[INDEX_ORIGINAL_LEVEL] >= MAX_ORIGINAL_LEVEL: return 6, 0, 0, 0, 0 previousLevel = skill[INDEX_ORIGINAL_LEVEL] expendItemKind = hallitem.itemSystem.findItemKind(expendItemId) expendCount = userBag.calcTotalUnitsCount(expendItemKind) needCount = 1 if needCount > expendCount: return 4, skill[INDEX_STAR_LEVEL], skill[INDEX_ORIGINAL_LEVEL], skill[ INDEX_CURRENT_LEVEL], previousLevel consumeCount = userBag.consumeUnitsCountByKind( FISH_GAMEID, expendItemKind, needCount, pktimestamp.getCurrentTimestamp(), "BI_NFISH_SKILL_UPGRADE", skillId) if consumeCount != needCount: ftlog.error("upgradeMaxSkill-> needSkillCard not enough", userId, skillId) return 4, skill[INDEX_STAR_LEVEL], skill[INDEX_ORIGINAL_LEVEL], skill[ INDEX_CURRENT_LEVEL], previousLevel skill[INDEX_ORIGINAL_LEVEL] = MAX_ORIGINAL_LEVEL skill[INDEX_CURRENT_LEVEL] = MAX_ORIGINAL_LEVEL setSkill(userId, skillId, skill) upgradedSkill = getSkill(userId, skillId) if not upgradedSkill: ftlog.error("upgradeMaxSkill-> getSkill error", userId, skillId) return 5, skill[INDEX_STAR_LEVEL], skill[INDEX_ORIGINAL_LEVEL], skill[ INDEX_CURRENT_LEVEL], previousLevel datachangenotify.sendDataChangeNotify(FISH_GAMEID, userId, "item") skills = getSkillList(userId) # convertOverflowCardToCoin(userId, skills) # 技能道具数量变化事件(用于刷新小红点) from newfish.game import TGFish from newfish.entity.event import SkillItemCountChangeEvent event = SkillItemCountChangeEvent(userId, FISH_GAMEID) TGFish.getEventBus().publishEvent(event) # 技能升级事件 from newfish.game import TGFish from newfish.entity.event import SkillLevelUpEvent event = SkillLevelUpEvent(userId, FISH_GAMEID, skills, actionType) TGFish.getEventBus().publishEvent(event) return 0, upgradedSkill[INDEX_STAR_LEVEL], upgradedSkill[INDEX_ORIGINAL_LEVEL], \ upgradedSkill[INDEX_CURRENT_LEVEL], previousLevel
def _doSitDown(self, msg, userId, seatId, clientId): """ 比赛牌桌只有玩家断线重连时才会触发坐下操作,既重新坐回牌桌 """ if seatId != 0: if self.seats[seatId - 1].userId == 0: onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) ftlog.warn("reconnect user is cleaned from table", "seats =", self.seats) return False elif userId != self.seats[seatId - 1].userId: onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) ftlog.warn("reconnect user id is not matched", "seats =", self.seats) return False else: ftlog.info("user reconect, userId:", userId) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, seatId) self.players[seatId - 1].offline = 1 self.players[seatId - 1].clientId = clientId self.players[seatId - 1].lang = util.getLanguage( userId, clientId) self.players[seatId - 1].refreshGunSkin() self._sendTableInfo(userId, seatId) self._updateMatchInfo(userId) self._updateMatchRank(userId) self._updateMatchTask(userId) self.players[seatId - 1].dealEnterTable() self.players[seatId - 1].enterTime = int(time.time()) self.players[seatId - 1].offline = 0 from newfish.game import TGFish event = EnterTableEvent(userId, FISH_GAMEID, self.roomId, self.tableId, seatId, 1) TGFish.getEventBus().publishEvent(event) return True else: for i in range(len(self.seats)): if self.seats[i].userId == userId: ftlog.info("lost user reconect, userId:", userId, "i =", i) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, i + 1) self.players[i].offline = 1 self.players[i].clientId = clientId self.players[i].lang = util.getLanguage(userId, clientId) self.players[i].refreshGunSkin() self._sendTableInfo(userId, i + 1) self._updateMatchInfo(userId) self._updateMatchRank(userId) self._updateMatchTask(userId) self.players[i].dealEnterTable() self.players[i].enterTime = int(time.time()) self.players[i].offline = 0 from newfish.game import TGFish event = EnterTableEvent(userId, FISH_GAMEID, self.roomId, self.tableId, seatId, 1) TGFish.getEventBus().publishEvent(event) return True
def initialize(): ftlog.debug("newfish returner_mission initialize begin") global _inited if not _inited: _inited = True from newfish.entity.event import DailyTaskRewardEvent from newfish.game import TGFish TGFish.getEventBus().subscribe(DailyTaskRewardEvent, _triggerDailyTaskRewardEvent) ftlog.debug("newfish returner_mission initialize end")
def initialize(): ftlog.debug("newfish fish_notice_system initialize begin") global _inited if not _inited: _inited = True from poker.entity.events.tyevent import EventUserLogin from newfish.game import TGFish TGFish.getEventBus().subscribe(EventUserLogin, _triggerUserLoginEvent) ftlog.debug("newfish fish_notice_system initialize end")
def initialize(): ftlog.debug("newfish mailSystem initialize begin") global _inited if not _inited: from poker.entity.events.tyevent import EventUserLogin from newfish.game import TGFish TGFish.getEventBus().subscribe(EventUserLogin, _triggerReportBIPropEvent) # TGFish.getEventBus().subscribe(EventUserLogin, _triggerCheckExpireMail) ftlog.debug("newfish mailSystem initialize end")
def initialize(): ftlog.debug("newfish level_gift initialize begin") global _inited if not _inited: _inited = True from newfish.game import TGFish from newfish.entity.event import GunLevelUpEvent TGFish.getEventBus().subscribe(GunLevelUpEvent, _triggerLevelUpEvent) ftlog.debug("newfish level_gift initialize end")
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) # 从桌子中踢掉玩家
def getQuestReward(userId, taskId, rewardflyPos): """ 领取每日任务奖励 """ code = 1 reason = 2 rewards = [] questInfo = getUserQuestInfoData(userId) progress, state = questInfo.get(str(taskId), [0, QuestTaskState.Normal]) # 未达到领取条件 if state == QuestTaskState.Normal: reason = 2 # 已经领取过奖励 elif state == QuestTaskState.Received: reason = 1 elif state == QuestTaskState.Complete: reason = 0 questInfo[str(taskId)] = [progress, QuestTaskState.Received] setUserQuestInfoData(userId, questInfo) module_tip.cancelModuleTipEvent(userId, "task", taskId) # -1 todayQuest, activeLv = getTodayQuest(userId) quest = todayQuest.get(taskId, {}) rewards = _processQuestReward(userId, quest) # quest.get("rewards", []) code = util.addRewards(userId, rewards, "DTASK_REWARD") taskLevel = quest.get("taskLevel", 0) # 更新周奖励的星级 finishedWeekStar = _incrDailyQuestWeekStar(userId, taskLevel) questData = getDailyQuestData(userId) finishedStar = questData.get("finishedStar", 0) all = len(questInfo) == len(config.getDailyQuestGroupOrder()) dailyQuestRewardFinishedStars = config.getDailyQuestRewardFinishedStars("day", all) for star in dailyQuestRewardFinishedStars: if finishedStar >= star > finishedStar - taskLevel: module_tip.addModuleTipEvent(userId, "task", star) break dailyQuestRewardFinishedWeekStars = config.getDailyQuestRewardFinishedStars("week", all) for star in dailyQuestRewardFinishedWeekStars: if finishedWeekStar >= star > finishedWeekStar - taskLevel: module_tip.addModuleTipEvent(userId, "task", star) break from newfish.entity.event import DailyTaskRewardEvent from newfish.game import TGFish event = DailyTaskRewardEvent(userId, FISH_GAMEID, taskId, taskLevel) TGFish.getEventBus().publishEvent(event) mo = MsgPack() mo.setCmd("task") mo.setResult("gameId", FISH_GAMEID) mo.setResult("userId", userId) mo.setResult("action", "questReward") mo.setResult("taskId", taskId) mo.setResult("rewardflyPos", rewardflyPos) mo.setResult("reason", reason) if reason == 0: mo.setResult("code", code) mo.setResult("rewards", rewards) router.sendToUser(mo, userId)
def initialize(): ftlog.debug("newfish souvenir coin initialize begin") global _inited if not _inited: _inited = True from newfish.entity.event import UserVipExpChangeEvent from newfish.game import TGFish TGFish.getEventBus().subscribe(UserVipExpChangeEvent, _triggerUserVipExpChangeEvent) ftlog.debug("newfish souvenir coin initialize end")
def cancelModuleTipEvent(userId, moduleName, value): """ 取消对应的提示信息 """ from newfish.game import TGFish tip = FishModuleTipEvent(userId, FISH_GAMEID, 0, moduleName, value) TGFish.getEventBus().publishEvent(tip) if ftlog.is_debug(): ftlog.debug("newfish cancelModuleTipEvent name=", moduleName, "value=", value, "userId=", userId)
def initialize(): ftlog.debug("newfish moduletip initialize begin") global _inited if not _inited: _inited = True _reloadConf() from newfish.game import TGFish tyeventbus.globalEventBus.subscribe(EventConfigure, _onConfChanged) TGFish.getEventBus().subscribe(FishModuleTipEvent, handleEvent) ftlog.debug("newfish moduletip initialize end")
def resetModuleTipEvent(userId, moduleName): """ 重置提示信息 """ from newfish.game import TGFish tip = FishModuleTipEvent(userId, FISH_GAMEID, -1, moduleName, None) TGFish.getEventBus().publishEvent(tip) if ftlog.is_debug(): ftlog.debug("newfish resetModuleTipEvent name=", moduleName, "userId=", userId)
def initialize(): ftlog.info("newfish item_monitor initialize begin") global _inited if not _inited: _inited = True from newfish.game import TGFish from newfish.entity.event import ItemMonitorEvent TGFish.getEventBus().subscribe(ItemMonitorEvent, _triggerItemChangeEvent) ftlog.info("newfish item_monitor initialize end")
def initialize(): ftlog.info("newfish checkin initialize begin") global _inited if not _inited: _inited = True from newfish.game import TGFish from newfish.entity.event import NewbieTaskCompleteEvent TGFish.getEventBus().subscribe( NewbieTaskCompleteEvent, _triggerNewbieTaskCompleteEvent) # 新手任务完成事件 ftlog.info("newfish checkin initialize end")
def initialize(): ftlog.info("newfish skill_system initialize begin") global _inited if not _inited: _inited = True from poker.entity.events.tyevent import EventUserLogin from newfish.game import TGFish from newfish.entity.event import SkillItemCountChangeEvent TGFish.getEventBus().subscribe(SkillItemCountChangeEvent, _triggerSkillItemCountChangeEvent) TGFish.getEventBus().subscribe(EventUserLogin, _triggerUserLoginEvent) ftlog.info("newfish skill_system initialize end")
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)
def _incQuestValue(userId, taskType, incVlaue, resetTime=0, fishPool=0, fpMultiple=0, gunX=0): """ 更新每日任务进度并检测;任务是否完成 """ if util.getDayStartTimestamp(resetTime) != util.getDayStartTimestamp(int(time.time())): resetTime = weakdata.getDayFishData(userId, "resetTime") if not resetTime: weakdata.setDayFishData(userId, WeakData.resetTime, int(time.time())) refreshDailyQuestData(userId) key = _getUserDailyQuestKey(userId) newValue = daobase.executeUserCmd(userId, "HINCRBY", key, str(taskType), incVlaue) confs = config.getDailyQuestConfsByType(taskType) todayQuest, _ = getTodayQuest(userId) questInfo = getUserQuestInfoData(userId) update = False for conf in confs: if conf and conf["taskId"] in todayQuest: if isinstance(conf.get("fishPool"), list) and conf.get("fishPool") and fishPool not in conf.get("fishPool"): continue if conf.get("fpMultiple", 0) > 0 and fpMultiple < conf.get("fpMultiple", 0): continue if conf.get("gunX", 0) > 0 and gunX < conf.get("gunX", 0): continue taskId = conf["taskId"] targetsNum = conf.get("targetsNum") process, state = questInfo.get(str(taskId), [0, QuestTaskState.Normal]) # if newValue >= targetsNum and newValue - incVlaue < targetsNum: if state == QuestTaskState.Normal: update = True questInfo[str(taskId)] = [process + incVlaue, state] if process < targetsNum <= process + incVlaue: questInfo[str(taskId)] = [targetsNum, QuestTaskState.Complete] quest = todayQuest[taskId] _sendQuestFinished(userId, quest) module_tip.addModuleTipEvent(userId, "task", taskId) taskLevel = conf.get("taskLevel", 0) # questData = getDailyQuestData(userId) # finishedStar = questData.get("finishedStar", 0) # dailyQuestRewardFinishedStars = config.getDailyQuestRewardFinishedStars() # for star in dailyQuestRewardFinishedStars: # if finishedStar >= star and finishedStar - taskLevel < star: # module_tip.addModuleTipEvent(userId, "task", star) # break # 发送完成任务事件 from newfish.entity.event import DailyTaskFinishEvent from newfish.game import TGFish event = DailyTaskFinishEvent(userId, FISH_GAMEID, int(conf["taskId"]), taskLevel) TGFish.getEventBus().publishEvent(event) bireport.reportGameEvent("BI_NFISH_GE_TASK_FINISHED", userId, FISH_GAMEID, 0, 0, int(conf["taskId"]), int(taskLevel), 0, 0, [], util.getClientId(userId)) if update: setUserQuestInfoData(userId, questInfo)
def addUserVipExp(gameId, userId, toAddExp, eventId, intEventParam, productId, rmbs=-1, isAddVipExp=True): """ 增加VIP经验值 """ rmbs = int(rmbs) if rmbs == -1 and toAddExp >= 10: rmbs = toAddExp / 10 if isAddVipExp: hallvip.userVipSystem.addUserVipExp(gameId, userId, toAddExp, eventId, intEventParam) else: # 自己处理vip升级事件. from hall.game import TGHall from hall.entity.hallvip import TYUserVipLevelUpEvent vipExp = hallvip.userVipSystem.getUserVip(userId).vipExp oldVipLevel = hallvip.vipSystem.findVipLevelByVipExp(vipExp - toAddExp) userVip = hallvip.userVipSystem.getUserVip(userId) if oldVipLevel.level != userVip.vipLevel.level: lv_event = TYUserVipLevelUpEvent(FISH_GAMEID, userId, oldVipLevel, userVip, [], 0, 0) TGHall.getEventBus().publishEvent(lv_event) # vip经验发生变化. from newfish.game import TGFish event = UserVipExpChangeEvent(userId, gameId, toAddExp) TGFish.getEventBus().publishEvent(event) if ftlog.is_debug(): ftlog.debug("addUserVipExp----->event", gameId, userId, toAddExp, eventId, intEventParam, rmbs, isAddVipExp) # 上报购买商品事件. loginDays = gamedata.getGameAttrInt(userId, FISH_GAMEID, GameData.loginDays) userLevel = gamedata.getGameAttrInt(userId, FISH_GAMEID, GameData.level) isIn, roomId, tableId, _ = util.isInFishTable(userId) if isIn: from newfish.servers.table.rpc import table_remote table_remote.buyProduct(roomId, tableId, userId, intEventParam, userLevel, loginDays) else: from poker.entity.biz import bireport userChip = userchip.getUserChipAll(userId) bireport.reportGameEvent("BI_NFISH_BUY_PRODUCT", userId, FISH_GAMEID, roomId, intEventParam, userLevel, 0, 0, 0, [], util.getClientId(userId), loginDays, userChip) # ftlog.debug("BI_NFISH_BUY_PRODUCT", userId, roomId, intEventParam, userLevel, util.getClientId(userId), userChip) updateUserDataByRecharge(userId, productId, rmbs)
def initialize(): ftlog.debug("newfish daily_gift initialize begin") global _inited if not _inited: _inited = True from poker.entity.events.tyevent import ChargeNotifyEvent from hall.game import TGHall from newfish.game import TGFish from newfish.entity.event import NFChargeNotifyEvent TGHall.getEventBus().subscribe(ChargeNotifyEvent, _triggerChargeNotifyEvent) TGFish.getEventBus().subscribe(NFChargeNotifyEvent, _triggerChargeNotifyEvent) ftlog.debug("newfish daily_gift initialize end")