def sendRpcScore(self): import app from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if rpc_diaoyu and self.score: rpc_diaoyu.setScore(self.owner.id, app.addr, self.owner.name, config.serverNo, self.score)
def rc_diaoyudiaoyu(self): resAct = Game.res_mgr.res_activity.get(constant.ACTIVITY_DIAOYU) serverInfo = self.player.base.GetServerInfo() if not resAct.isOpen(serverInfo): return 0, errcode.EC_DIAOYU_NOTOPEN q = self.player.diaoyu.getFish() if not q: return 0, errcode.EC_DIAOYU_DIAOYU_NOABLE from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL data = self.player.getDiaoyuInfo() rrv = rpc_diaoyu.updateNoBroadcast(2, self.player.id, data) if not rrv: return 0, errcode.EC_DIAOYU_DIAOYUERR dUpdate = {} dUpdate["diaoyu"] = self.player.diaoyu.to_init_data() resp = {"allUpdate": dUpdate, "id": q} return 1, resp
def rc_diaoyuGetData(self): resAct = Game.res_mgr.res_activity.get(constant.ACTIVITY_DIAOYU) serverInfo = self.player.base.GetServerInfo() if not resAct.isOpen(serverInfo): return 0, errcode.EC_DIAOYU_NOTOPEN from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL data = self.player.getDiaoyuInfo() import app rrv = rpc_diaoyu.hello(2, self.player.id, config.serverNo, app.addr, self.player.name, data, 0, 1) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL rrv = rpc_diaoyu.get(2, self.player.id) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL # 抛事件 self.player.safe_pub(msg_define.MSG_JOIN_DIAOYU) if not self.player.cycleDay.Query("todayHasJoinDiaoyu", 0): self.player.safe_pub(msg_define.MSG_ACTIVITY_KF_JOIN) self.player.cycleDay.Set("todayHasJoinDiaoyu", 1) return 1, rrv["v"]
def rc_sendWorldMSG(self, content, type=0): if self.player.isShutup(): return if type == 0: for addr, logic in Game.rpc_logic_game: if logic: logic.sendWorldMSG(self.player.id, content) elif type == 2: from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL rrv = rpc_diaoyu.msg(2, self.player.id, content) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL elif type == 3: from game.mgr.room import get_rpc_wakuang rpc_wakuang = get_rpc_wakuang() if not rpc_wakuang: return 0, errcode.EC_GETD_RPC_ROOM_FAIL data = self.player.zudui.getTeamInfo(0) rrv = rpc_wakuang.msg(3, data["id"], content) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL elif type == 4: from game.mgr.room import get_rpc_boss rpc_boss = get_rpc_boss() if not rpc_boss: return 0, errcode.EC_GETD_RPC_ROOM_FAIL rrv = rpc_boss.msg(4, self.player.id, content) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL elif type == 5: from game.mgr.room import get_rpc_gongcheng rpc_gongcheng = get_rpc_gongcheng() if not rpc_gongcheng: return 0, errcode.EC_GETD_RPC_ROOM_FAIL rrv = rpc_gongcheng.msg(5, self.player.id, content) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL elif type == 6: from game.mgr.room import get_rpc_jiujiyishou rpc_jiujiyishou = get_rpc_jiujiyishou() if not rpc_jiujiyishou: return 0, errcode.EC_GETD_RPC_ROOM_FAIL rrv = rpc_jiujiyishou.msg(6, self.player.id, content) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL # 抛事件 self.player.safe_pub(msg_define.MSG_SEND_WORLD_MSG) return 1, {}
def rc_diaoyuChange(self, roomid): from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL rrv = rpc_diaoyu.changeRoom(2, self.player.id, roomid) if not rrv: return 0, errcode.EC_DIAOYU_CHANGEROOM_ERR return 1, {"roomid": rrv["roomid"]}
def robFishOk(self, q): res = Game.res_mgr.res_diaoyu.get(q) import app from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if rpc_diaoyu: rpc_diaoyu.addScore(self.owner.id, app.addr, self.owner.name, config.serverNo, res.score) self.score = self.score + res.score self.addDiaoyuDayScore(res.score) self.markDirty() return res.score
def rc_diaoyuStatus(self, status): self.player.diaoyu.status = status from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL data = self.player.getDiaoyuInfo() rrv = rpc_diaoyu.update(2, self.player.id, data) if not rrv: return 0, errcode.EC_DIAOYU_STATUSERR return 1, {}
def rc_diaoyuRank(self): resp = {} from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL resp = rpc_diaoyu.getRankList(self.player.id) if not resp: return 0, errcode.EC_DIAOYU_CHANGEROOM_ERR # resp["list"]=[] # resp["rank"]=666 # resp["score"]=999 return 1, resp
def getFish(self): diaoyuFish = Game.res_mgr.res_common.get("diaoyuFish") now = time.time() if now < self.diaoyutime + diaoyuFish.i: return 0 self.diaoyutime = now q = 1 kks = {} num = 0 for kk, vv in Game.res_mgr.res_diaoyu.items(): vvv = [] for _ in range(vv.weight): vvv.append(num) num += 1 kks[kk] = vvv x = randint(0, num - 1) for kk, vv in kks.items(): if x in vv: q = kk break res = Game.res_mgr.res_diaoyu.get(q) import app from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if rpc_diaoyu: rpc_diaoyu.addScore(self.owner.id, app.addr, self.owner.name, config.serverNo, res.score) self.score = self.score + res.score self.addDiaoyuDayScore(res.score) self.yulou.append(q) self.markDirty() return q
def rc_diaoyuGetUser(self, id): from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL rrv = rpc_diaoyu.getOneByServerNo(2, config.serverNo, id) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL # print("1111111111",config.serverNo,id,rrv) data = rrv["v"] if len(data) == 0: return 0, errcode.EC_DIAOYU_NOFOUNDONE resp = {} resp["data"] = data[0] return 1, resp
def rc_diaoyuRob(self, id, quality): diaoyuCatchNum = Game.res_mgr.res_common.get("diaoyuCatchNum") if not diaoyuCatchNum: return 0, errcode.EC_NORES diaoyuRobNum = Game.res_mgr.res_common.get("diaoyuRobNum") if not diaoyuRobNum: return 0, errcode.EC_NORES diaoyuXdayReward = Game.res_mgr.res_common.get("diaoyuXdayReward") if not diaoyuXdayReward: return 0, errcode.EC_NORES if self.player.diaoyu.getDiaoyuRob() >= diaoyuRobNum.i: return 0, errcode.EC_DIAOYU_ROB_USEUP from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if not rpc_diaoyu: return 0, errcode.EC_GETD_RPC_ROOM_FAIL rrv = rpc_diaoyu.getOneByServerNo(2, config.serverNo, id) if not rrv: return 0, errcode.EC_CALL_RPC_ROOM_FAIL data = rrv["v"] if len(data) == 0: return 0, errcode.EC_DIAOYU_NOFOUNDONE if quality not in data[0]["data"]["yulou"]: return 0, errcode.EC_DIAOYU_NOFOUNDONEFISH res = Game.res_mgr.res_diaoyu.get(quality) if not res: return 0, errcode.EC_NORES if diaoyuCatchNum.i <= data[0]["data"]["catch"]: return 0, errcode.EC_DIAOYU_ROB_LIMIT from game.mgr.logicgame import LogicGame proxy = get_proxy_by_addr(data[0]["addr"], LogicGame._rpc_name_) if not proxy: return 0, errcode.EC_GETD_LOGIC_PROXY_ERR fdata = self.player.GetFightData() historydata = { "id": self.player.id, "name": self.player.name, "quality": quality, "redhp": self.player.diaoyu.hp } resp = proxy.diaoyuRob(self.player.id, data[0], fdata, historydata) if not resp: return 0, errcode.EC_CALL_LOGIC_PROXY_ERR redhp = resp["redhp"] self.player.diaoyu.sethp(redhp) fightResult = resp["fightLog"]["result"].get("win", 0) if fightResult: self.player.diaoyu.robFishOk(quality) self.player.diaoyu.addDiaoyuRob() myhistory = { "id": data[0]["id"], "name": data[0]["name"], "quality": quality } self.player.diaoyu.addHistory(2, myhistory) iOpenDay = self.player.base.GetServerOpenDay() reward = copy.deepcopy(res.reward) if iOpenDay >= diaoyuXdayReward.i: reward = copy.deepcopy(res.reward2) respBag = self.player.bag.add(reward, constant.ITEM_ADD_DIAOYU_ROBREWARD, wLog=True) else: self.player.safe_pub(msg_define.MSG_XIANSHITUISONGLIBAO_DIAOYU_F) myhistory = { "id": data[0]["id"], "name": data[0]["name"], "quality": quality } self.player.diaoyu.addHistory(3, myhistory) respBag = {} dUpdate = self.player.packRespBag(respBag) dUpdate["diaoyu"] = self.player.diaoyu.to_init_data() resp["allUpdate"] = dUpdate return 1, resp
def diaoyuRob(self, robid, data, fdata, historydata): oldRedHp = historydata["redhp"] pvpRounds = Game.res_mgr.res_common.get("pvpRounds") fightobj = Game.fight_mgr.createFight(constant.FIGHT_TYPE_160) fightobj.SetRounds(pvpRounds.i) mydata = self.owner.GetFightData() rs = fightobj.init_players_by_data(fdata, mydata) if not rs: return {} fix = {} if self.hp: fix[constant.FIGHT_TEAM_BLUE] = self.hp if oldRedHp: fix[constant.FIGHT_TEAM_RED] = oldRedHp # print("!!!!",fix) fightobj.FixFighterHP(fix) historydata["redhp"] = {} fightLog = fightobj.doFight(1) fightResult = fightLog["result"].get("win", 0) myhp = fightLog["resultInfo"][constant.FIGHT_TEAM_BLUE] redhp = fightLog["resultInfo"][constant.FIGHT_TEAM_RED] if fightobj.teamIsAllDead(myhp): myhp = {} if fightobj.teamIsAllDead(redhp): redhp = {} self.hp = myhp # a={1: {1: {899030007: {'role': {'fashion': 1, 'name': '\xe7\xa7\x8b\xe8\x8a\xaf\xe8\x8a\xab', 'title': 1, 'hp': 33610, 'attrExtra': {'onlineGoldExtra': 0, 'onlineExpExtra': 0}, 'sex': 1, 'rid': 899030007, 'outfit': 0, 'showList': [{'modeType': 1, 'imageType': 1, 'imageId': 1}, {'modeType': 2, 'imageType': 1, 'imageId': 1}, {'modeType': 7, 'imageType': 1, 'imageId': 1}, {'modeType': 8, 'imageType': 1, 'imageId': 1}]}}}, 3: {70: {'pet': {'petId': 70, 'hp': 34810, 'name': '', 'evolveLv': 0}}}, 4: {1: {'tiannv': {'tiannvType': 9, 'imageId': 1, 'hp': 33610, 'imageType': 1, 'tiannvId': 1}}}}, 2: {1: {499030007: {'role': {'fashion': 1, 'name': '\u6e29\u83ba\u537f', 'title': 1, 'hp': 33610, 'attrExtra': {'onlineGoldExtra': 0, 'onlineExpExtra': 0}, 'sex': 2, 'rid': 499030007, 'outfit': 0, 'showList': [{'modeType': 1, 'imageType': 1, 'imageId': 1}, {'modeType': 2, 'imageType': 1, 'imageId': 1}, {'modeType': 7, 'imageType': 1, 'imageId': 1}, {'modeType': 8, 'imageType': 1, 'imageId': 1}]}}}, 3: {70: {'pet': {'petId': 70, 'hp': 34810, 'name': '', 'evolveLv': 0}}}, 4: {1: {'tiannv': {'tiannvType': 9, 'imageId': 1, 'hp': 33610, 'imageType': 1, 'tiannvId': 1}}}}} if fightResult: if historydata["quality"] in self.yulou: self.yulou.remove(historydata["quality"]) self.addDiaoyuBerob() self.addHistory(0, historydata) from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if rpc_diaoyu: dydata = self.owner.getDiaoyuInfo() rpc_diaoyu.updateNoBroadcast(2, self.owner.id, dydata) else: self.addHistory(1, historydata) dUpdate = {} dUpdate["diaoyu"] = self.to_init_data() spawn(self.owner.call, "diaoyuPush", {"allUpdate": dUpdate}, noresult=True) self.markDirty() return {"data": data, "fightLog": fightLog, "redhp": redhp}
def exitRpcDiaoyu(self): from game.mgr.room import get_rpc_diaoyu rpc_diaoyu = get_rpc_diaoyu() if rpc_diaoyu: rpc_diaoyu.bye(2, self.owner.id)