def initRenwudajihuanTasks(self): Renwudajihuantasks = self.cycleDay.Query("RenwudajihuanTasks", {}) today = str(datetime.date.today()) resRenwu = Game.res_mgr.res_renwudajihuan.get(today) if not Renwudajihuantasks and resRenwu: while True: rid = utility.Choice(resRenwu.task1) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["1"] = res.id break while True: rid = utility.Choice(resRenwu.task2) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["2"] = res.id break while True: rid = utility.Choice(resRenwu.task3) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["3"] = res.id break while True: rid = utility.Choice(resRenwu.task4) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["4"] = res.id break while True: rid = utility.Choice(resRenwu.task5) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["5"] = res.id break self.markDirty() for taskId, taskInfo in Renwudajihuantasks.items(): taskRes, taskobj = CreatTask(taskId, self, taskInfo) if not taskobj: continue self.Renwudajihuantasks[taskId] = taskobj
def to_RenwudajihuanTasks_data(self): Renwudajihuantasks = self.cycleDay.Query("RenwudajihuanTasks", {}) today = str(datetime.date.today()) resRenwu = Game.res_mgr.res_renwudajihuan.get(today) if not Renwudajihuantasks and resRenwu: while True: rid = utility.Choice(resRenwu.task1) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["1"] = res.id break while True: rid = utility.Choice(resRenwu.task) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.Renwudajihuan2Index["2"] = res.id break while True: rid = utility.Choice(resRenwu.task3) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["3"] = res.id break while True: rid = utility.Choice(resRenwu.task4) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["4"] = res.id break while True: rid = utility.Choice(resRenwu.task5) if rid not in Renwudajihuantasks: res = Game.res_mgr.res_task.get(rid, None) Renwudajihuantasks[res.id] = {"taskId": res.id} self.cycleDay.Set("RenwudajihuanTasks", Renwudajihuantasks) self.RenwudajihuanIndex["5"] = res.id break self.markDirty() resp = [] for taskId, taskobj in self.Renwudajihuantasks.items(): one = taskobj.to_save_dict() resp.append(one) return resp
def caoPre(self): hetiPet = Game.res_mgr.res_common.get("hetiPet") hetibigchest = Game.res_mgr.res_common.get("hetibigchest") hetismallchest = Game.res_mgr.res_common.get("hetismallchest") r = [] r.append([0, hetiPet.i]) if self.bigRewardCount < hetibigchest.arrayint1[0]: r.append([1, hetibigchest.arrayint1[1]]) if self.smallRewardCount < hetismallchest.arrayint1[0]: r.append([2, hetismallchest.arrayint1[1]]) boxtype = utility.Choice(r) if boxtype == 0: return 0, 0, boxtype rid = 0 s = 0 if boxtype == 1: self.bigRewardCount += 1 rid, s = hetibigchest.arrayint1[2], hetibigchest.arrayint1[3] elif boxtype == 2: self.smallRewardCount += 1 rid, s = hetismallchest.arrayint1[2], hetismallchest.arrayint1[3] self.score += s self.markDirty() return rid, s, boxtype
def to_init_data(self): init_data = {} RewardData = self.getRewardData() for v in Game.res_mgr.res_zhuanpanSystem.values(): if v.id not in RewardData: RewardData[v.id] = {"disable": [], "data": {}} for vv in v.idxCanDisable.keys(): pool = [] for k in Game.res_mgr.res_zhuanpanPool.values(): if k.sys == v.id and k.idx == vv: value = (k.id, k.Weight) pool.append(value) RewardData[v.id]["data"][vv] = utility.Choice(pool) self.setRewardData(RewardData) init_data["RewardData"] = RewardData init_data["freeResetTime"] = self.freeResetTime init_data["score"] = self.score init_data["rewardid"] = self.rewardid return init_data
def rc_guildFreeExRef(self): guildId = self.player.guild.GetGuildId() if not guildId: return 0, errcode.EC_NO_GUILD rpc_guild = get_rpc_guild(guildId) if not rpc_guild: return 0, errcode.EC_NOT_FOUND_GUILD iGuildLv = rpc_guild.GetLevel() guildlvRes = Game.res_mgr.res_guildlv.get(iGuildLv) if not guildlvRes: return 0, errcode.EC_NORES now = int(time.time()) if now < self.player.guild.refTime: return 0, errcode.EC_GUILD_EX_FREE_REF_TIME_ERR self.player.guild.reSetRefTime() exList = [] for i in range(4): exId = utility.Choice(guildlvRes.exchange) exList.append((exId, 0)) self.player.guild.SetExList(exList) # 打包返回信息 dUpdate = {} dUpdate["guildInfo"] = { "scene": { "refTime": self.player.guild.refTime, "exList": self.player.guild.to_exchange_data() } } resp = { "allUpdate": dUpdate, } return 1, resp
def _selectTargets(self, objs): # 过滤 l_targets = [] for scope in self.res.target_scope: objs = self._selectTargets1(objs, scope) l_targets.append(objs) #去重 l_norepeat = [] for i in range(len(l_targets)-1): a = set(l_targets[i]) b = set(l_targets[i+1]) c = a.symmetric_difference(b) for obj in c: l_norepeat.insert(0, obj) if l_targets: for obj in l_targets[-1]: l_norepeat.insert(0, obj) #取目标 if self.res.target_num: num = utility.Choice(self.res.target_num) else: num = 0 resp = [] for obj in l_norepeat: resp.append(obj) num -= 1 if num <= 0: break return resp
def choose(self, star): ii = [] for k, v in Game.res_mgr.res_rescueTask.items(): if star and v.star != star: continue ii.append(( k, v.w, )) return utility.Choice(ii)
def rc_guildExRef(self): guildId = self.player.guild.GetGuildId() if not guildId: return 0, errcode.EC_NO_GUILD rpc_guild = get_rpc_guild(guildId) if not rpc_guild: return 0, errcode.EC_NOT_FOUND_GUILD iGuildLv = rpc_guild.GetLevel() guildlvRes = Game.res_mgr.res_guildlv.get(iGuildLv) if not guildlvRes: return 0, errcode.EC_NORES guildRefCostRes = Game.res_mgr.res_common.get( "guildRefCost") # 帮会兑换刷新消耗 guildRefNumRes = Game.res_mgr.res_common.get( "guildRefNum") # 帮会兑换每日可刷新次数 if not guildRefCostRes or not guildRefNumRes: return 0, errcode.EC_NORES iTodayNum = self.player.guild.GetTodayExRefNum() if iTodayNum >= guildRefNumRes.i: return 0, errcode.EC_GUILD_EXCHANGE_REFESH_MAX # 扣道具 respBag = self.player.bag.costItem( guildRefCostRes.arrayint2, constant.ITEM_COST_GUILD_EXCHANGE_REFE, wLog=True) if not respBag.get("rs", 0): return 0, errcode.EC_GUILD_EXCHANGE_REFE_NOT_ENOUGH iTodayNum += 1 self.player.guild.SetTodayExRefNum(iTodayNum) exList = [] for i in range(4): exId = utility.Choice(guildlvRes.exchange) exList.append((exId, 0)) self.player.guild.SetExList(exList) # 打包返回信息 dUpdate = self.player.packRespBag(respBag) dUpdate["guildInfo"] = { "scene": { "exRefNum": guildRefNumRes.i - iTodayNum, "exList": self.player.guild.to_exchange_data() } } resp = { "allUpdate": dUpdate, } return 1, resp
def init_exchange_data(self): if not self.guildId: return from game.mgr.guild import get_rpc_guild rpc_guild = get_rpc_guild(self.guildId) if not rpc_guild: return iGuildLv = rpc_guild.GetLevel() guildlvRes = Game.res_mgr.res_guildlv.get(iGuildLv) if not guildlvRes: return exList = [] if guildlvRes.exchange: for i in range(4): exId = utility.Choice(guildlvRes.exchange) exList.append((exId, 0)) self.SetExList(exList)
def _doReward(self, cond, type, pool, player=None): reward = {} rs = Game.condition_mgr.check(cond, player=player) if not rs: return reward for one_group in pool: groupID, num, rate = one_group iLucky = random.randint(1, 100000) if rate < iLucky: continue rewardpool = Game.res_mgr.res_group_rewardpool.get(groupID) if num == 0: # 0表示全拿 for rewardpoolID, rewardpoolRate in rewardpool: rewardpoolRes = Game.res_mgr.res_rewardpool.get(rewardpoolID) if rewardpoolRes: reward[rewardpoolRes.itemNo] = reward.get(rewardpoolRes.itemNo, 0) + rewardpoolRes.num else: if type == 1: #奖池类型 1=id可重复2=id不可重复 for i in range(num): rewardpoolID = utility.Choice(rewardpool) rewardpoolRes = Game.res_mgr.res_rewardpool.get(rewardpoolID) if rewardpoolRes: reward[rewardpoolRes.itemNo] = reward.get(rewardpoolRes.itemNo, 0) + rewardpoolRes.num elif type == 2: #奖池类型 1=id可重复2=id不可重复 rewardpool = copy.deepcopy(rewardpool) for i in range(num): rewardpoolID, rewardpoolRate = utility.ChoiceReturn(rewardpool) rewardpool.remove((rewardpoolID, rewardpoolRate)) rewardpoolRes = Game.res_mgr.res_rewardpool.get(rewardpoolID) if rewardpoolRes: reward[rewardpoolRes.itemNo] = reward.get(rewardpoolRes.itemNo, 0) + rewardpoolRes.num return reward
def rc_petEquipGongming(self, id, uid, bindpet, eatuid, idx): # print("!!!!!!!!!!!!!!!!!",id, uid, bindpet, eatuid, idx) if idx not in [0, 1, 2]: return 0, errcode.EC_PET_EQUIP_GONGMING_BAD_IDX pet = self.player.pet.getPet(id) if pet: equip = pet.getEquipByUid(uid) else: equip = self.player.pet.yishou_bag.getObj(uid) if not equip: # print("!!!!!!!!!!!!!!!!!33333") return 0, errcode.EC_PET_EQUIP_NOT_FIND if bindpet: bpet = self.player.pet.getPet(bindpet) if not bpet: return 0, errcode.EC_PET_EQUIP_GONGMING_NOFOUND_BIND_PET eatequip = self.player.pet.yishou_bag.getObj(eatuid) if not eatequip: return 0, errcode.EC_PET_EQUIP_GONGMING_NOFOUND_EAT eatequipRes = Game.res_mgr.res_petEquip.get(eatequip.id) if not eatequipRes: return 0, errcode.EC_NORES equipRes = Game.res_mgr.res_petEquip.get(equip.id) if not equipRes: return 0, errcode.EC_NORES if eatequipRes.quality != equipRes.quality: return 0, errcode.EC_PET_EQUIP_GONGMING_TYPE_NOTSAME oriType = 0 if bindpet: evolveRes = Game.res_mgr.res_idlv_petevolve.get( (bpet.id, bpet.evolveLv)) if not evolveRes: # print("!!!!!!!!!!!!!!!!!===") return 0, errcode.EC_NORES oriType = evolveRes.oriType if oriType == 2: oriType = 1 # 扣道具 equipCost = self.player.pet.yishou_bag.popObj(eatuid) if not equipCost: return 0, errcode.EC_PET_EQUIP_GONGMING_EAT_FAIL choose = [] for kk, vv in Game.res_mgr.res_shoulinggongming.items(): if vv.oriType == oriType and idx == vv.idx: choose.append(( kk, vv.weight, )) cid = utility.Choice(choose) equip.gongming(idx, cid, bindpet) dPet = {} if pet: dPet["actList"] = [pet.to_init_data()] dPet.update(self.player.pet.to_update_data(delequips=[equipCost])) else: dPet.update( self.player.pet.to_update_data(equips=[equip], delequips=[equipCost])) # print("eeeeeeeeeeeee",dPet) dUpdate = {} dUpdate["pet"] = dPet resp = { "allUpdate": dUpdate, } return 1, resp
def rc_totemUp(self, pos, num, auto): totem = self.player.totem.getTotem(pos) if not totem: return 0, errcode.EC_NOT_FIND_TOTEM oldlv = totem.getLv() res = Game.res_mgr.res_poslv_totem.get((pos, oldlv), None) if not res: return 0, errcode.EC_NORES leftExp = totem.getExp() if res.tpCost and leftExp >= res.exp: return 0, errcode.EC_TOTEM_NEED_TP totalAddExp = 0 totalMulti = 0 respBag = {} for i in range(num): oldlv = totem.getLv() res = Game.res_mgr.res_poslv_totem.get((pos, oldlv), None) respBag1 = self.player.bag.costItem( res.cost, constant.ITEM_COST_TOTEM_UPGRADE, wLog=True, auto=auto) if not respBag1.get("rs", 0): return 0, errcode.EC_TOTEM_UPGRADE_NOT_ENOUGH respBag = self.player.mergeRespBag(respBag, respBag1) oldExp = totem.getExp() oldBjId = totem.getBjResId() oldUpgradeTimes = totem.getUpgradeTimes() bjRes = Game.res_mgr.res_totemBj.get(oldBjId) multi = 1 if oldUpgradeTimes + 1 >= bjRes.num: multi = bjRes.multi nextBjId = oldBjId + 1 nextBjRes = Game.res_mgr.res_totemBj.get(nextBjId) if not nextBjRes: nextBjId = oldBjId totem.setBjResId(nextBjId) totem.setUpgradeTimes(0) else: totem.setUpgradeTimes(oldUpgradeTimes + 1) randomBj = utility.Choice(Game.res_mgr.res_random_totem) randomBjRes = Game.res_mgr.res_totemRan.get(randomBj, None) multi = randomBjRes.multi addRes = Game.res_mgr.res_common.get("totemsUpExp", None) addExp = addRes.i * multi newExp = oldExp + addExp if newExp > res.exp and not res.tpCost: newlv = oldlv + 1 nextRes = Game.res_mgr.res_poslv_totem.get((pos, newlv), None) if nextRes: leftExp = newExp - res.exp totem.setLv(newlv, res, nextRes) totem.setExp(leftExp) else: totem.setExp(newExp) else: totem.setExp(newExp) if multi > 1: totalMulti += multi totalAddExp += addExp # 战力重算 self.player.attr.RecalFightAbility() dTotem = {} dTotem["actList"] = [totem.to_init_data()] dUpdate = self.player.packRespBag(respBag) dUpdate["attr"] = self.player.attr.to_update_data() dUpdate["totem"] = dTotem resp = { "allUpdate": dUpdate, "multi": totalMulti, "addExp": totalAddExp, } return 1, resp
def to_init_data(self): init_data = {} vipres = Game.res_mgr.res_vip.get(self.owner.vip.vip) mapOffTime = Game.res_mgr.res_common.get("mapOffTime") mapOffMaxTimes = Game.res_mgr.res_common.get("mapOffMaxTimes") mapObjTime = Game.res_mgr.res_common.get("mapObjTime") mapObjNum = Game.res_mgr.res_common.get("mapObjNum") res = Game.res_mgr.res_mapSub.get(self.mapSubId) nt = time.time() n = mapOffMaxTimes.i - self.offtimes for _ in range(n): netxt = self.offlasttime + mapOffTime.i if netxt > nt: break self.offtimes += 1 self.offlasttime = netxt self.offexp += res.offexp * (10000 + vipres.offper) // 10000 self.offcoin += res.offcoin * (10000 + vipres.offper) // 10000 self.offexplore += res.offexplore * (10000 + vipres.offper) // 10000 self.offpetexp += res.offpetexp * (10000 + vipres.offper) // 10000 for offreward in res.offreward: rewardRes = Game.res_mgr.res_reward.get(offreward) resp = rewardRes.doReward() # resp={4:1} for k, v in resp.items(): k = str(k) self.offreward[k] = self.offreward.get(k, 0) + v if self.offtimes == mapOffMaxTimes.i: self.offlasttime = nt obj = [] n = mapObjNum.i - len(self.objIDs) for _ in range(n): netxt = self.objlasttime + mapObjTime.i if netxt > nt: break # 重复类型 obj = res.objReuse rx = random.randint(1, 10000) if len(self.objkey) >= len(res.objOnce): rx = 999 isOnce = False if rx <= res.objPercent: isOnce = True obj = [] ooo = copy.deepcopy(res.objOnce) for vv in ooo: if vv[0] not in self.objkey: obj.append(vv) moid = utility.Choice(obj) self.objIDs.append(moid) if isOnce: self.objkey.append(moid) self.objlasttime = netxt if len(self.objIDs) == mapObjNum.i: self.objlasttime = nt self.markDirty() init_data["mapSubId"] = self.mapSubId init_data["passSubId"] = self.passSubId init_data["rewardSubId"] = self.rewardSubId init_data["quickFree"] = self.getquickFree() init_data["quickUse"] = self.getquickUse() init_data["ChargeEndTime"] = self.ChargeEndTime init_data["offexp"] = self.offexp init_data["offcoin"] = self.offcoin init_data["offexplore"] = self.offexplore init_data["offpetexp"] = self.offpetexp init_data["offreward"] = self.offreward init_data["offlasttime"] = self.offlasttime init_data["offtimes"] = self.offtimes init_data["objIDs"] = self.objIDs init_data["objlasttime"] = self.objlasttime init_data["objkey"] = self.objkey init_data["passEncounterId"] = self.passEncounterId return init_data
def Upgrade(self): res = Game.res_mgr.res_petEquip.get(self.id) if not res: return upRes = Game.res_mgr.res_qalv_petEquipUpgrade.get( (res.quality, self.addlv + 1)) if not upRes: return self.addlv += 1 #self.mainAttrData = {} # 主属性 {属性id:[强化等级, 继承比例]} keys = list(self.mainAttrData.keys()) for key in keys: attrData = self.mainAttrData[key] lv = attrData[0] + 1 rate = attrData[1] self.mainAttrData[key] = [lv, rate] #self.viceAttrData = {} # 副属性 {属性id:[强化等级, 继承比例]} #增加副属性条数 for i in range(upRes.viceAdd): # 4条以下 if len(self.viceAttrData) < 4: vicePool = copy.deepcopy(res.vicePool) attrId = utility.Choice(vicePool) #相同属性 if attrId in self.viceAttrData: attrData = self.viceAttrData[attrId] lv = attrData[0] + 1 rate = int((attrData[1] + random.randint(850, 1000)) / 2) self.viceAttrData[attrId] = [lv, rate] else: lv = 1 rate = random.randint(850, 1000) # 属性在75% ~ 100%随机 self.viceAttrData[attrId] = [lv, rate] #4条及以上 只从当前4条内随机 else: viceKeys = list(self.viceAttrData.keys()) attrId = random.choice(viceKeys) attrData = self.viceAttrData[attrId] lv = attrData[0] + 1 rate = int((attrData[1] + random.randint(850, 1000)) / 2) self.viceAttrData[attrId] = [lv, rate] self.mainAttr = [] # [{"hp":100}] self.viceAttr = [] # [{"hp":100}] # 计算出属性 for attrId, data in self.mainAttrData.items(): attrRes = Game.res_mgr.res_petEquipAttr.get(attrId) if attrRes: self.mainAttr.append({ attrRes.attrType: attrRes.baseVal + int(attrRes.addVal * data[0] * data[1] / 1000) }) for attrId, data in self.viceAttrData.items(): attrRes = Game.res_mgr.res_petEquipAttr.get(attrId) if attrRes: self.viceAttr.append({ attrRes.attrType: int(attrRes.baseVal * data[0] * data[1] / 1000) }) self.markDirty()
def __init__(self, res, data=None, owner=None): self.addlv = 0 #强化等级 self.lock = 0 #锁定 self.waste = 0 #是否弃置 self.dicnum = 0 #强化次数-定向 self.gongmingid = [0, 0, 0] #共鸣id 0代表无属性 self.gongmingpet = [0, 0, 0] #共鸣的宠物id 0无需绑定宠物 self.gongmingidBak = [0, 0, 0] #共鸣id 0代表无属性 候选 self.gongmingpetBak = [0, 0, 0] #共鸣的宠物id 0无需绑定宠物 候选 self.mainAttrData = {} #主属性 {属性id:[强化等级, 继承比例]} self.viceAttrData = {} # 副属性 {属性id:[强化等级, 继承比例]} # self.petid=0 # 现在穿在哪个宠物id上 self.mainAttr = [] # [{"hp":100}] self.viceAttr = [] # [{"hp":100}] self.gongmingAttr = [] # [{"hp":100}] if not data: #主属性 attrId = utility.Choice(res.mainPool) self.mainAttrData[attrId] = [0, 1000] #副属性 viceNum = utility.Choice(res.viceNum) vicePool = copy.deepcopy(res.vicePool) for i in range(viceNum): one = utility.ChoiceReturn(vicePool) attrId = one[0] vicePool.remove(one) viceRate = random.randint(850, 1000) #属性在85% ~ 100%随机 self.viceAttrData[attrId] = [1, viceRate] EquipBase.__init__(self, res, data=data, owner=owner) #计算出属性 for attrId, data in self.mainAttrData.items(): attrRes = Game.res_mgr.res_petEquipAttr.get(attrId) if attrRes: self.mainAttr.append({ attrRes.attrType: attrRes.baseVal + int(attrRes.addVal * data[0] * data[1] / 1000) }) for attrId, data in self.viceAttrData.items(): attrRes = Game.res_mgr.res_petEquipAttr.get(attrId) if attrRes: self.viceAttr.append({ attrRes.attrType: int(attrRes.baseVal * data[0] * data[1] / 1000) }) for idx in range(3): ridx = self.gongmingid[idx] if not ridx: continue bid = self.gongmingpet[idx] if bid: continue attrRes = Game.res_mgr.res_shoulinggongming.get(idx) if attrRes: self.gongmingAttr.append(attrRes.attr)
def rc_niudanRoll(self, resid, ten, useFree=False): print("===rc_niudanRoll===", resid, ten, useFree) res = Game.res_mgr.res_niudanSystem.get(resid) if not res: print("111111111111111", resid) return 0, errcode.EC_NORES resxx = getattr(Game.res_mgr, "res_niudan" + res.mod) if not resxx: print("111111111111111", res.mod) return 0, errcode.EC_NORES serverInfo = self.player.base.GetServerInfo() #普通池 resAct1 = Game.res_mgr.res_activity.get(res.ptActID) if not resAct1: print("3333333333333", res.ptActID) return 0, errcode.EC_NORES if not resAct1.isOpen(serverInfo): return 0, errcode.EC_NOT_OPEN funcID1 = resAct1.getCycleFuncID(serverInfo) if not funcID1: return 0, errcode.EC_NOT_OPEN #精英池 resAct2 = Game.res_mgr.res_activity.get(res.jyActID) if not resAct2: print("4444444444444", res.jyActID) return 0, errcode.EC_NORES if not resAct2.isOpen(serverInfo): return 0, errcode.EC_NOT_OPEN funcID2 = resAct2.getCycleFuncID(serverInfo) if not funcID2: return 0, errcode.EC_NOT_OPEN #系统活动 resActX = Game.res_mgr.res_activity.get(res.sysActID) if not resActX.isOpen(serverInfo): return 0, errcode.EC_NOT_OPEN funcIDX = resActX.getCycleFuncID(serverInfo) if not funcIDX: return 0, errcode.EC_NOT_OPEN modres = {} #系统活动res modres = resxx.get(funcIDX) if not modres: print("55555555555", funcIDX) return 0, errcode.EC_NORES times = 1 cost = {} reward = {} rn = {} onenum = 0 if ten: if not res.costTen or not res.Ten: print("666666666666") return 0, errcode.EC_NORES times = res.Ten cost = res.costTen else: cost = res.cost times = 1 rn = self.player.niudan.getRollOneNum() onenum = rn.get(resid, 0) if useFree: if onenum < res.costFree: cost = {} else: return 0, errcode.EC_FREE_EXHAUSTED rxAll = self.player.niudan.getRollNum() rxAllNum = rxAll.get(resid, 0) for k, v in res.reward.items(): reward[k] = v * times modactnum = self.player.niudan.getCycleBaodi(res.sysActID) modactreward = self.player.niudan.getCycleReward(res.sysActID) for timesn in range(times): pool = [] # if ten and not timesn and res.abpool: # for v in Game.res_mgr.res_niudanPool.values(): # if not v.scope[1]: # v.scope[1]=constant.MAX_SAFE_INTEGER # if v.cycleFuncID==funcID and v.scope[0]<=rxAllNum<=v.scope[1]: # value = (v.rewardten, v.WeightTen) # pool.append(value) # else: for v in Game.res_mgr.res_niudanPool.values(): if not v.scope[1]: v.scope[1] = constant.MAX_SAFE_INTEGER if (v.cycleFuncID == funcID1 or v.cycleFuncID == funcID2) and v.scope[0] <= rxAllNum <= v.scope[1]: value = (v.reward, v.Weight) pool.append(value) randomReward = utility.Choice(pool) print("===============", randomReward) modactnum += 1 modactreward += 1 if modres.baodiNum: if modactnum >= modres.baodiNum[res.modidx]: modactnum = 0 randomReward = {} randomReward[modres.reward[res.modidx][0]] = modres.reward[ res.modidx][1] print("==!!!!!=====", randomReward) for k, v in randomReward.items(): reward[k] = reward.get(k, 0) + v rxAllNum += 1 rxAll[resid] = rxAllNum respBag1 = self.player.bag.costItem(cost, constant.ITEM_COST_NIUDAN_ROLL, wLog=True) if not respBag1.get("rs", 0): if ten: if res.costTenRep: respBag1 = self.player.bag.costItem( res.costTenRep, constant.ITEM_COST_NIUDAN_ROLL, wLog=True) if not respBag1.get("rs", 0): return 0, errcode.EC_COST_ERR else: return 0, errcode.EC_COST_ERR else: if res.costRep: respBag1 = self.player.bag.costItem( res.costRep, constant.ITEM_COST_NIUDAN_ROLL, wLog=True) if not respBag1.get("rs", 0): return 0, errcode.EC_COST_ERR else: return 0, errcode.EC_COST_ERR respBag = self.player.bag.add(reward, constant.ITEM_ADD_NIUDAN_ROLL, wLog=True, mail=True) respBag = self.player.mergeRespBag(respBag, respBag1) print("===rc_niudanRoll===reward=", reward) if not ten: onenum += 1 for xresid in res.RollOneResID: rn[xresid] = onenum self.player.niudan.setRollOneNum(rn) self.player.niudan.setRollNum(rxAll) self.player.niudan.setCycleBaodi(modactnum, res.sysActID) self.player.niudan.setCycleReward(modactreward, res.sysActID) # 打包返回信息 dUpdate = self.player.packRespBag(respBag) dUpdate["niudan"] = self.player.niudan.to_init_data() resp = { "allUpdate": dUpdate, } return 1, resp
def WashPeculiarity(self): """技能洗练""" total_sub_type = {} #统计分类 washSkill = {} #当前不锁定可洗坑位 for pos, data in self.peculiarity.items(): skillId, status = data if status == 1: washSkill[pos] = skillId if pos != 0: #专属不算 skillRes = Game.res_mgr.res_skill.get(skillId) one_type = total_sub_type.setdefault(skillRes.subType, []) one_type.append(skillId) else: washSkill[pos] = 0 # 【被动】触发技能同类型仅会出现1个 # 【固定】属性技能同类型最多出现4个 self.washSkill = {} for pos, skillId in washSkill.items(): if skillId > 100: self.washSkill[pos] = skillId continue washRes = Game.res_mgr.res_idstar_petwash.get( (self.resID, self.washStar)) if pos == 0: #专属 pool_group = washRes.private dWashData = Game.res_mgr.res_group_subtype_skills_petwashpool.get( pool_group) if not dWashData: continue lRandPool = [] for randData in dWashData.values(): lRandPool.extend(randData) if lRandPool: skillId = utility.Choice(lRandPool) self.washSkill[pos] = skillId else: #普通 pool_group = washRes.peculiarity dWashData = copy.deepcopy( Game.res_mgr.res_group_subtype_skills_petwashpool.get( pool_group)) for subType, skillids in total_sub_type.items(): # 【被动】触发技能同类型仅会出现1个 if subType <= constant.SKILL_SUB_TYPE_99 and len( skillids) >= 1: if dWashData.get(subType): dWashData.pop(subType) # 【固定】属性技能同类型最多出现2个 if constant.SKILL_SUB_TYPE_200 < subType <= constant.SKILL_SUB_TYPE_299 and len( skillids) >= 4: if dWashData.get(subType): dWashData.pop(subType) if not dWashData: continue lRandPool = [] for randData in dWashData.values(): lRandPool.extend(randData) if lRandPool: skillId = utility.Choice(lRandPool) skillRes = Game.res_mgr.res_skill.get(skillId) one_type = total_sub_type.setdefault(skillRes.subType, []) one_type.append(skillId) self.washSkill[pos] = skillId self.markDirty() return self.washSkill