def processLogout(session): print(__name__, session.player) player = session.player if not player: return #发消息通知 mapObj = player.mapObj if mapObj: mapObj.playerLeaveMap(player) #如果地图属性配置了下线后踢到某地图,那么改一下地图和坐标 cfg = mapObj.cfg if cfg.offlineMap != None: player.mapname = cfg.offlineMap.mapname player.x = cfg.offlineMap.x player.y = cfg.offlineMap.y ffext.info('logout name=%s, offlineMap=%s, x=%d, y=%d' % (player.name, player.mapname, player.x, player.y)) elif player.isDeath() and cfg.reviveMap != None: player.mapname = cfg.reviveMap.mapname player.x = cfg.reviveMap.x player.y = cfg.reviveMap.y ffext.info('logout name=%s, reviveMap=%s, x=%d, y=%d' % (player.name, player.mapname, player.x, player.y)) #下线计算本次在线时长 player.gametime = player.gametime + (ffext.getTime() - player.logintime) player.last_logout = ffext.getTime() DbService.getPlayerService().updatePlayer(player) #DbService.getPlayerService().updatePlayer(player) from handler import MarryHandler MarryHandler.processOffline(session) #MARRY_OFFLINE TeamHandler.processTeamOps( session, MsgDef.TeamMsgReq(MsgDef.TeamClientCmd.QUIT_TEAM, 0)) TeamHandler.processBrotherDownline(session)
def doInitRankRecordWithExcept(self, exceptList): for i in range(MsgDef.RankType.FULL_FIGHTPOWER, MsgDef.RankType.MAX_VALUE): if exceptList != None and i not in exceptList: DbService.getPlayerService().addRank( i, MsgDef.RankRefreshType.DAILY) return True
def createArena(self, playerSrc, destUid): playerSrc.arenaCtrl.usedTimes += 1 from model import PlayerModel mapObj = ArenaCopy.create() playerSrc.direction = Base.Direction.LEFT mapObj.playerEnterMap(playerSrc, 77, 70) def cb(dbSet): db = dbSet['player'] dbitem = dbSet['item'] dbPet = dbSet['pet'] session = ffext.SessionNone() player = PlayerModel.Player(db.result[0]) session.setPlayer(player) player.session = session if dbitem.isOk(): player.itemCtrl.fromData(dbitem.result) player.petCtrl.fromData(dbPet.result) player.direction = Base.Direction.RIGHT player.arenaCtrl.destPlayerRef = weakref.ref(playerSrc) #状态机 player.fsm = MonsterAI.FSM(player) def goTo(): mapObj.copyMapHandler.autoPlayerRef = weakref.ref(player) mapObj.playerEnterMap(player, 69, 72) player.fsm.changeState(ffext.singleton(ArenaStateAttack)) ffext.timer(1000, goTo) return DbService.getPlayerService().loadPlayer(destUid, 0, cb, True)
def saveMailOffline(uid, mail): mailStr = mail.toJsonStr() if not mailStr or mailStr == '': return ffext.dump('mailStr', mailStr) DbService.getPlayerService().updateMail4Extend(uid, mailStr) return
def handleTimerWedding(marryId): marryTotalInfo = getMarryMgr().getMarryTotalInfo(marryId) if not marryTotalInfo: return #ffext.dump('handleTimerWedding', marryTotalInfo) #举行婚礼 playerSess = ffext.getSessionMgr().findByUid(marryTotalInfo.coupleData[0].uid) marryPlayerSess = ffext.getSessionMgr().findByUid(marryTotalInfo.coupleData[1].uid) if not playerSess or not marryPlayerSess: marryTotalInfo.flagWeding = MsgDef.WeddingFlagCmd.WEDDING_FAIL DbService.getPlayerService().updateMarry(marryTotalInfo) return player = playerSess.player from handler import MarryHandler ret_msg2 = MarryHandler.processMarryOpsMsgRet(MsgDef.MarriageClientCmd.MARRY_WEDDING_START, player) #ffext.dump('marryTotalInfo.listAttends', marryTotalInfo.listAttends) for k in marryTotalInfo.listAttends: ret_msg2.argPlayer = k prizePlayer = player.mapObj.getPlayerById(k.uid) if prizePlayer: ret_msg2.argPlayer = k ret_msg2.gold = marryTotalInfo.totalGold prizePlayer.addGold(marryTotalInfo.totalGold) #清楚婚礼进行数据 marryTotalInfo.totalGold = 0 marryTotalInfo.listAttends = [] break marryTotalInfo.flagWeding = MsgDef.WeddingFlagCmd.WEDDING_FINISH player.broadcast(MsgDef.ServerCmd.MARRIAGE_OPS_MSG, ret_msg2) #状态变化,更新数据库 DbService.getPlayerService().updateMarry(marryTotalInfo)
def init(self): def cb(ret): for marryRow in ret.result: marryId = long(marryRow[0]) marryTotalInfo = MarryTotalInfo(marryId) marryTotalInfo.assginFromDB(marryRow) #定时举行婚礼 if marryTotalInfo.flagWeding == MsgDef.WeddingFlagCmd.WEDDING_APPLYED: leftSec = ffext.getTime() - marryTotalInfo.tmWedding if leftSec <= 0 or marryTotalInfo.tmWedding == 0: leftSec = 30 #ffext.dump('timer wedding', leftSec, marryTotalInfo) def cb(): handleTimerWedding(marryId) ffext.timer(leftSec*1000, cb) #如果和谐离婚,定时离婚 if marryTotalInfo.tmEndWedding != 0 and marryTotalInfo.getInfoByGender(Base.Gender.MALE).status == MsgDef.MarryStatusCmd.MARRY_STATUS_DIVORCING and \ marryTotalInfo.getInfoByGender(Base.Gender.FEMAIL).status == MsgDef.MarryStatusCmd.MARRY_STATUS_DIVORCING: leftSec = marryTotalInfo.tmEndWedding - ffext.getTime() if leftSec <= 0: leftSec = 10 def cbDiv(): handleTimerDivorce(marryId) #ffext.timer(leftSec*1000, cbDiv) #ffext.dump('marry divorcing left sec', leftSec, marryId) #如果婚礼未举行 self.allMarryInfo[marryTotalInfo.marryId] = marryTotalInfo #ffext.dump('load marryTotalInfo', marryTotalInfo) #ffext.dump('load self.allMarryInfo', len(self.allMarryInfo)) return DbService.getPlayerService().loadAllMarry(cb) return True
def init(self): def brotherInfo(ret): ffext.dump('brother init', ret.result) if ret.flag == False or len(ret.result) == 0: self.allBrotherList = {} return for i in range(0, len(ret.result)): brotherID = long(ret.result[i][0]) if None == self.getBrotherById(brotherID): brotherCtrl = BrotherCtrl() brotherCtrl.bid = brotherID brotherCtrl.allBrothers = {} brotherCtrl.flag = True extra = str(ret.result[i][1]) if extra != '': extra = json.loads(extra) if extra: brotherCtrl.extra = extra brotherCtrl.ranking = 0 self.allBrotherList[brotherCtrl.bid] = brotherCtrl brotherCtrl = self.getBrotherById(brotherID) playerBrotherInfo = PlayerBrotherInfo() playerBrotherInfo.setPlayerBrother(long(ret.result[i][2]), str(ret.result[i][3]), long(ret.result[i][4]), long(ret.result[i][5]), long(ret.result[i][6])) brotherCtrl.allBrothers[ playerBrotherInfo.uid] = playerBrotherInfo return DbService.getGuildService().syncGetBrotherMemberInfoList(brotherInfo) return True
def delTime(self): self.flag = True if None == self.getBrotherExtra().pop('delTime', None): return False DbService.getGuildService().updateBrotherExtra(self.bid, json.dumps(self.extra)) return
def cbEnd(): rankWarInfo = self.allGuildRankWarVSInfo.pop(rankWarId, None) if not rankWarInfo: return rankWarInfo.tmRankWarStart = 0 retMsg = MsgDef.GuildRankWarOpsRet( MsgDef.GuildRankWarOpsCmd.RANKWAR_END, rankWarInfo.tmRankWarStart) retMsg.winGuildId = 0 if rankWarInfo.guildWin: retMsg.winGuildId = rankWarInfo.guildWin elif rankWarInfo.guildScore1 > rankWarInfo.guildScore2: rankWarInfo.guildWin = rankWarInfo.guild1.guildID retMsg.winGuildId = rankWarInfo.guild1.guildID elif rankWarInfo.guildScore1 < rankWarInfo.guildScore2: rankWarInfo.guildWin = rankWarInfo.guild2.guildID retMsg.winGuildId = rankWarInfo.guild2.guildID elif rankWarInfo.guildScore1 == rankWarInfo.guildScore2: allHp1 = 0 allHp2 = 0 for k, v in rankWarInfo.guildTeam1.iteritems(): memberSession = ffext.getSessionMgr().findByUid(k) if memberSession: member = memberSession.player allHp1 += member.hp for k, v in rankWarInfo.guildTeam2.iteritems(): memberSession = ffext.getSessionMgr().findByUid(k) if memberSession: member = memberSession.player allHp2 += member.hp if allHp1 > allHp2: rankWarInfo.guildWin = rankWarInfo.guild1.guildID retMsg.winGuildId = rankWarInfo.guild1.guildID elif allHp1 < allHp2: rankWarInfo.guildWin = rankWarInfo.guild2.guildID retMsg.winGuildId = rankWarInfo.guild2.guildID if not retMsg.winGuildId: DbService.getGuildService().updateRankWarWin( 0, rankWarInfo.guildId1, rankWarInfo.guildId2) for k, v in rankWarInfo.guildTeam1.iteritems(): memberSession = ffext.getSessionMgr().findByUid(k) memberSession.sendMsg(cmd, retMsg) for k, v in rankWarInfo.guildTeam2.iteritems(): memberSession = ffext.getSessionMgr().findByUid(k) memberSession.sendMsg(cmd, retMsg) else: DbService.getGuildService().updateRankWarWin( 0, rankWarInfo.getAnotherGuild(retMsg.winGuildId)) if retMsg.winGuildId == rankWarInfo.guild1.guildID: for k, v in rankWarInfo.guildTeam1.iteritems(): memberSession = ffext.getSessionMgr().findByUid(k) memberSession.sendMsg(cmd, retMsg) elif retMsg.winGuildId == rankWarInfo.guild2.guildID: for k, v in rankWarInfo.guildTeam1.iteritems(): memberSession = ffext.getSessionMgr().findByUid(k) memberSession.sendMsg(cmd, retMsg)
def addBrotherInfo(self, brotherInfo): brotherid = idtool.allocId() brotherInfo.bid = brotherid self.allBrotherList[brotherInfo.bid] = brotherInfo playerInfo = brotherInfo.getPlayerInfo() DbService.getGuildService().addBrother(brotherid, playerInfo[0].uid, playerInfo[1].uid, playerInfo[2].uid)
def dailyRefresh(self): def callback(dbSet): # 命名很难看,意义好理解 :) # init one by one, if not exists, make empty one db_FULL_FIGHTPOWER = dbSet['FULL_FIGHTPOWER'] if db_FULL_FIGHTPOWER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.FULL_FIGHTPOWER, db_FULL_FIGHTPOWER) db_LEVEL = dbSet['LEVEL'] if db_LEVEL.isOk(): getRankMgr().dataFromDailyRefresh(MsgDef.RankType.LEVEL, db_LEVEL) db_GOLD = dbSet['GOLD'] if db_GOLD.isOk(): getRankMgr().dataFromDailyRefresh(MsgDef.RankType.GOLD, db_GOLD) db_WUJIANG_FIGHTPOWER = dbSet['WUJIANG_FIGHTPOWER'] if db_WUJIANG_FIGHTPOWER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.WUJIANG_FIGHTPOWER, db_WUJIANG_FIGHTPOWER) db_CESHI_FIGHTPOWER = dbSet['CESHI_FIGHTPOWER'] if db_CESHI_FIGHTPOWER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.CESHI_FIGHTPOWER, db_CESHI_FIGHTPOWER) db_GONGJIAN_FIGHTPOWER = dbSet['GONGJIAN_FIGHTPOWER'] if db_GONGJIAN_FIGHTPOWER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.GONGJIAN_FIGHTPOWER, db_GONGJIAN_FIGHTPOWER) db_SHUSHI_FIGHTPOER = dbSet['SHUSHI_FIGHTPOER'] if db_SHUSHI_FIGHTPOER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.SHUSHI_FIGHTPOER, db_SHUSHI_FIGHTPOER) db_JUNTUAN_FIGHTPOWER = dbSet['JUNTUAN_FIGHTPOWER'] if db_JUNTUAN_FIGHTPOWER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.JUNTUAN_FIGHTPOWER, db_JUNTUAN_FIGHTPOWER) db_JUNTUAN_LEVEL = dbSet['JUNTUAN_LEVEL'] if db_JUNTUAN_LEVEL.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.JUNTUAN_LEVEL, db_JUNTUAN_LEVEL) db_BROTHER_FIGHTPOWER = dbSet['BROTHER_FIGHTPOWER'] if db_BROTHER_FIGHTPOWER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.BROTHER_FIGHTPOWER, db_BROTHER_FIGHTPOWER) db_MARRY_FIGHTPOWER = dbSet['MARRY_FIGHTPOWER'] if db_MARRY_FIGHTPOWER.isOk(): getRankMgr().dataFromDailyRefresh( MsgDef.RankType.MARRY_FIGHTPOWER, db_MARRY_FIGHTPOWER) #广播更新新的排行榜数据 getRankMgr().broadcastToAllClientNewRank() return DbService.getPlayerService().loadAllRankOnDailyRefresh(callback) pass
def addBrotherList(self, player1, player2, player3): brotherid = idtool.allocId() brother = BrotherCtrl() brother.bid = brotherid brother.addBrotherMember(player1, player2, player3) #brother.extra = '' self.allBrotherList[brother.bid] = brother DbService.getGuildService().addBrother(brotherid, player1.uid, player2.uid, player3.uid) return brotherid
def processDelRoleReq(session, msg): print('DelRoleReq', msg) for k in range(0, len(session.user.allRole)): if session.user.allRole[k].uid == msg.uid: u_name = session.user.allRole[k].name del session.user.allRole[k] DbService.getPlayerService().delRole(msg.uid) # 删角(old)-记录log LogModel.logLoginData(session.user.accountid, msg.uid, u_name, LogModel.LoginOpType.DEL_PLAYER, 0) break retMsg = MsgDef.DelRoleRet(msg.uid) session.sendMsg(MsgDef.ServerCmd.DEL_ROLE, retMsg)
def logLoginData(acc_id, player_id, player_name, op, reason, ip=0, x=0, y=0, param=''): svr_id = 0 #get_server_id() param = DbServiceLog.UserLogParam(svr_id, acc_id, player_id, player_name, op, reason, ip, x, y, param) DbService.getLogService().addUserLog(param) return True
def addTask(self, task, saveFlag=True): self.allTask[task.taskId] = task taskCfg = task.taskCfg owner = self.owner if task.status == TaskStatus.INIT or task.status == TaskStatus.ACCEPT: actionTmp = mergeAction(task.action, task.object) dest = self.action2task.get(actionTmp) if dest: dest.append(weakref.ref(task)) else: self.action2task[actionTmp] = [weakref.ref(task)] if saveFlag: DbService.getPlayerService().addTask(self.owner, task) return task
def cb(ret): if ret and ret.result: if len(ret.result) <= 0: #原来没有记录,插入一条新的-cb判断缺失??? DbService.getPlayerService().addGlobalRecord( GLOBAL_RECORD_INDEX) pass else: dbRow = ret.result[0] getGlobalRecordMgr().last_refresh_time = int(dbRow[1]) getGlobalRecordMgr().citywar_info.parseFrom(dbRow[2]) pass getGlobalRecordMgr().checkOnInit() return
def processCreateRoleReq(session, msg): print('CreateRoleReq', msg) if msg.gender != Base.Gender.MALE and msg.gender != Base.Gender.FEMAIL: msg.gender = Base.Gender.MALE roleTmp = PlayerModel.Role() roleTmp.uid = idtool.allocUid() if session.isWebDebug: msg.name = msg.name.encode('utf-8') roleTmp.name = msg.name roleTmp.job = msg.job roleTmp.gender = msg.gender if roleTmp.gender != Base.Gender.MALE and roleTmp.gender != Base.Gender.FEMAIL: roleTmp.gender = Base.Gender.MALE if roleTmp.job < Base.Job.ZHANSHI or roleTmp.job > Base.Job.YOUXIA: roleTmp.job = Base.Job.ZHANSHI def callback(db): retMsg = MsgDef.CreateRoleRet() if db.isOk(): retMsg.flag = True retMsg.uid = roleTmp.uid session.user.addRole(roleTmp) else: retMsg.flag = False retMsg.errMsg = '角色名已经存在' session.sendMsg(MsgDef.ServerCmd.CREATE_ROLE_RET, retMsg) MailModel.createMailRecrodAtFirstTime(roleTmp.uid) # 新增每日活动记录 DbService.getPlayerService().createDailyLoginAct( session.user.accountid) if retMsg.flag == True: # 创角(old)-记录log LogModel.logLoginData(session.user.accountid, roleTmp.uid, roleTmp.name, LogModel.LoginOpType.CREATE_PLAYER, 0) mapName = 10001 x = 27 y = 188 mapObj = MapMgr.getMapMgr().allocMap(mapName) if mapObj.cfg.reviveMap != None: mapName = mapObj.cfg.reviveMap.mapname x = mapObj.cfg.reviveMap.x y = mapObj.cfg.reviveMap.y DbService.getPlayerService().createRole(session.user, roleTmp, mapName, x, y, callback) return
def checkNewTask(self, task): #如果任务完成,检查是否有新的任务可以做 if task.status != TaskStatus.FINISH: return None nextTaskId = task.taskCfg.nextTaskId if nextTaskId <= 0: return None newTask = self.addTaskById(nextTaskId, False) if not newTask: return None oldTaskId = task.taskId self.delTaskById(oldTaskId) DbService.getPlayerService().replaceTask(self.owner, newTask, oldTaskId) return newTask
def cb(ret): safePasswd = ret.result[0][0] if msg.passwd != safePasswd: retErr = Base.lang('安全密码错误!') session.sendMsg( MsgDef.ServerCmd.ERROR_MSG, buildErrMsg(MsgDef.ClientCmd.MONEY_BANK_OPS, retErr)) else: player.isVerified = True verify_retMsg = MsgDef.MoneyBankOpsRet( 3, 0, player.isSetPasswd) session.sendMsg(MsgDef.ServerCmd.MONEY_BANK_OPS, verify_retMsg) DbService.getPlayerService().querySafePasswd(player, cb) return
def trigger(self, action, object, value=1): actionTmp = mergeAction(action, object) dest = self.action2task.get(actionTmp) player = self.owner if not dest: actionTmp = mergeAction(action, 0) dest = self.action2task.get(actionTmp) if not dest: ffext.dump('trigger2', action, object, value, actionTmp, self.action2task) return 0 ret = None ffext.dump('trigger', action, object, value, actionTmp, self.action2task, dest) for taskref in dest: task = taskref() ffext.dump('trigger', action, object, value, actionTmp, task) if not task: continue #ffext.dump(event) r = task.inc(action, object, value) if r == 1: #完成任务 cfg = task.taskCfg if ret == None: ret = [] ret.append(task.taskId) DbService.getPlayerService().updateTask(player, task) player.sendMsg( ServerCmd.UPDATE_TASK_STATUS, MsgDef.UpdateTaskStatusRet(task.taskId, task.status, task.value)) if cfg.completedialog: player.sendMsg(MsgDef.ServerCmd.SHOW_PLAY, MsgDef.ShowPlayRet(cfg.completedialog)) elif cfg.completeplay: player.sendMsg(MsgDef.ServerCmd.SHOW_PLAY, MsgDef.ShowPlayRet(cfg.completeplay)) elif r == 0: #有进展 DbService.getPlayerService().updateTask(self.owner, task) self.owner.sendMsg( ServerCmd.UPDATE_TASK_STATUS, MsgDef.UpdateTaskStatusRet(task.taskId, task.status, task.value)) #ffext.dump(ret) if ret: sendTaskList(player) return len(ret) return 0
def fromData(self, result): ffext.dump("load db data to login-activity ...") # 从DB获取的数据初始化邮件 if not result or len(result) <= 0: # 新增每日活动记录 DbService.getPlayerService().createDailyLoginAct( self.owner.session.user.accountid) return False row = result[0] self.seven_login_days = int(row[1]) self.seven_login_mask = int(row[2]) self.online_reward_mask = int(row[3]) self.invite_reward = int(row[4]) return True
def settask(session, args): if len(args) < 2: ret_msg.chatMsg = '参数 @settask taskid' session.player.sendMsg(MsgDef.ServerCmd.CHAT_MSG, ret_msg) return nextTaskId = int(args[1]) for taskid, task in session.player.taskCtrl.allTask.iteritems(): session.player.taskCtrl.delTaskById(taskid) newTask = session.player.taskCtrl.addTaskById(nextTaskId, False) if newTask: DbService.getPlayerService().replaceTask(session.player, newTask, taskid) break from handler import TaskHandler TaskHandler.processQueryTask(session) return
def finishTask(self, taskId): task = self.allTask.get(taskId) if not task: return Base.lang('任务不存在') if task.status != TaskStatus.DONE: return Base.lang('无法交任务') task.status = TaskStatus.FINISH player = self.owner player.addExp(task.taskCfg.exp, True) player.addGold(task.taskCfg.gold, True) DbService.getPlayerService().updateTask(player, task) newTask = self.checkNewTask(task) msg = MsgDef.UpdateTaskStatusRet(task.taskId, task.status, task.value) if newTask and newTask.__class__ != str: msg.nextTask = buildTaskMsg(newTask) self.owner.sendMsg(ServerCmd.UPDATE_TASK_STATUS, msg) return newTask
def completeEgg(self): #完成孵化 nowtm = ffext.getTime() if self.petEgg.eggItemCfgId == 0: return False if nowtm < self.petEgg.starttm + self.petEgg.needsec: return False player = self.ownerref() pet = Pet(player) pet.uid = idtool.allocUid() cfgid = 1 pet.cfg = getPetMgr().getCfgById(cfgid) self.allPet[pet.uid] = pet DbService.getPlayerService().addPet(player, pet) self.petEgg.eggItemCfgId = 0 self.petEgg.starttm = 0 self.petEgg.needsec = 0 return pet
def init(self): def cb(ret): exceptList = [] #不需要初始化的type列表 for rankRow in ret.result: rankId = int(rankRow[0]) rankType = int(rankRow[1]) rankData = rankRow[2] exceptList.append(rankId) if rankType == MsgDef.RankRefreshType.DAILY: rankInfo = getRankMgr().genRankDataInfo(rankId, rankData) if rankInfo: getRankMgr().addRankInfo(rankId, rankInfo) else: ffext.dump("not support") getRankMgr().doInitRankRecordWithExcept(exceptList) return DbService.getPlayerService().loadAllRankOnInit(cb) return True
def callback(db): retMsg = MsgDef.CreateRoleRet() if db.isOk(): retMsg.flag = True retMsg.uid = roleTmp.uid session.user.addRole(roleTmp) else: retMsg.flag = False retMsg.errMsg = '角色名已经存在' session.sendMsg(MsgDef.ServerCmd.CREATE_ROLE_RET, retMsg) MailModel.createMailRecrodAtFirstTime(roleTmp.uid) # 新增每日活动记录 DbService.getPlayerService().createDailyLoginAct( session.user.accountid) if retMsg.flag == True: # 创角(old)-记录log LogModel.logLoginData(session.user.accountid, roleTmp.uid, roleTmp.name, LogModel.LoginOpType.CREATE_PLAYER, 0)
def acceptTask(self, taskId): task = self.allTask.get(taskId) if not task: return Base.lang('任务不存在') if task.status != TaskStatus.INIT: return Base.lang('无法接受任务') task.status = TaskStatus.ACCEPT task.acceptTm = ffext.getTime() #for k, item in self.owner.itemCtrl.allItem.iteritems(): #if task.object == item.itemCfg.cfgId: #task.value = self.owner.itemCtrl.countItemNumbyCfgId(task.object) #ffext.dump('Value', task.value) self.owner.sendMsg( ServerCmd.UPDATE_TASK_STATUS, MsgDef.UpdateTaskStatusRet(task.taskId, task.status, task.value)) if task.taskCfg.action == Base.Action.CHAT_NPC: task.status = TaskStatus.DONE DbService.getPlayerService().updateTask(self.owner, task) return None
def handleTimerDivorce(marryId): #ffext.dump('marry divorcing handleTimerDivorce', marryId) marryTotalInfo = getMarryMgr().getMarryTotalInfo(marryId) if not marryTotalInfo: return myMarryInfo = marryTotalInfo.getInfoByGender(Base.Gender.MALE) if myMarryInfo.status != MsgDef.MarryStatusCmd.MARRY_STATUS_DIVORCING:#取消了 ffext.dump('marry divorcing handleTimerDivorce cancel', marryId) return getMarryMgr().delMarryById(marryTotalInfo.marryId) husbend = marryTotalInfo.coupleData[0].getPlayer() wife = marryTotalInfo.coupleData[1].getPlayer() from handler import MarryHandler opstype = MsgDef.MarriageClientCmd.MARRY_DIVORCE_NORMAL if husbend: husbend.marriageCtrl.divorceForce() ret_msg = MarryHandler.processMarryOpsMsgRet(opstype, husbend) husbend.sendMsg(MsgDef.ServerCmd.MARRIAGE_OPS_MSG, ret_msg) if wife: wife.marriageCtrl.divorceForce() ret_msg = MarryHandler.processMarryOpsMsgRet(opstype, wife) wife.sendMsg(MsgDef.ServerCmd.MARRIAGE_OPS_MSG, ret_msg) # 更新数据库 DbService.getPlayerService().updateMarryDivorce(marryTotalInfo.marryId) DbService.getPlayerService().updateMarryDivorcePlayer(marryTotalInfo.coupleData[0].uid) DbService.getPlayerService().updateMarryDivorcePlayer(marryTotalInfo.coupleData[1].uid)
def main(): db = DbService() user_repo = UserRepository(db) profile_repo = ProfileRepository(db) post_repo = PostRepository(db) user_controller = UserController(user_repo) profile_controller = ProfileController(profile_repo) post_controller = PostController(post_repo) app = StartMenu(user_controller, profile_controller, post_controller) app.show()
def whenDie(self, objAttack): if objAttack.getType() == Base.PLAYER: try: #增加仇人 if objAttack.uid not in self.friendCtrl.getEnemy(): DbService.getFriendService().addEnemy( self.uid, objAttack.uid, 0) self.friendCtrl.addEnemy(objAttack) from handler import FriendHandler opstype = MsgDef.FriendOpsClientCmd.ADD_ENEMY self.sendMsg( MsgDef.ServerCmd.FRIEHND_MSG, FriendHandler.processFriendPlayerMsgRet( opstype, objAttack.uid, objAttack.name, objAttack.job, objAttack.gender, objAttack.level, True)) except: ffext.error('whenDie error %s' % (self.name)) pksinVal = 100 if objAttack.guildCtrl.GuildRankWarWhenKillOther(self): #行会排名战 pksinVal = 0 if objAttack.guildCtrl.GuildWarWhenKillOther(self): #行会战进行中 pksinVal = 0 if pksinVal > 0: objAttack.pkSinValue += pksinVal #更新pk罪恶值 objAttack.broadcast( MsgDef.ServerCmd.PK_SIN_UPDATE_OPS, MsgDef.PkSinUpdateRet(0, objAttack.pkSinValue, objAttack.uid) ) #objAttack.sendMsg(MsgDef.ServerCmd.PK_SIN_UPDATE_OPS, MsgDef.PkSinUpdateRet(0, objAttack.pkSinValue)) self.processDrop() if self.mapObj and self.mapObj.copyMapHandler: #try: self.mapObj.copyMapHandler.handleObjDie(self.mapObj, self) #except: #ffext.error('mapObj.copyMapHandler.handleObjDie failed mapname=%s player=%s'%(self.mapObj.mapname, self.name)) self.handleReborn() return