Exemple #1
0
def rpcGuildCreate(who, reqMsg):
    '''创建仙盟
	'''
    name = reqMsg.name
    tenet = reqMsg.tenet
    pid = who.id
    if not checkCreate(who, name, tenet):
        return
    who = getRole(pid)
    if not who:
        return
    who.addTradeCash(-3000, "创建仙盟消耗", None)
    guildId = GUId.gGuildId.nextId()  #公会ID生成器
    oGuild = guild.newGuild(guildId, name, tenet, pid)
    memberObj = guild.newMember(who, GUILD_JOB_CHAIRMAN)
    oGuild.addMember(memberObj)
    hl = oGuild.getHyperLink(pid)
    message.tips(who, "成功创建仙盟#C02{}#n".format(name))
    message.guildAnnounce(
        oGuild.id,
        "#C01{}#n创建了仙盟#C02{}#n,志同道合的玩家可前往加入{}".format(who.name, name, hl))
    title = "创建仙盟"
    content1 = "你成功创建了仙盟,从下周开始,每周一将会返还#IG#n#C02500#n,持续三周"
    content2 = "你成功创建了仙盟,这是返还的#IG#n#C02500#n"
    propsObj = props.new(200002)
    propsObj.setValue(500)
    mail.sendGuildMail(who.id, title, content1, [], 0)
    mail.sendSysMail(who.id, title, content2, [propsObj], 0)
    rpcGuildOperateRes(who, 1, True)
    rpcGuildInfo(who)
    rpcGuildWelfareInfo(who)

    import listener
    listener.doListen("创建仙盟", who, guildId=guildId)
Exemple #2
0
def doSkillSchUpgradeAll(who):
    '''一键升级
	'''
    skillList = getCanUpgradeSkillList(who)
    if not skillList:
        message.tips(who, "门派技能等级都已达到上限,提升人物等级可提高该上限")
        return
    skillList.sort(key=lambda skObj: skObj.level)
    iRepeat = who.level - skillList[0].level
    skillList.sort(key=lambda skObj: skObj.getOpenLevel())
    if not doCheckCash(who, skillList):
        return
    iRealCost, dTmp = doSkillSchUpgradeLoop(who, skillList, iRepeat)
    # 扣费用
    who.costCash(iRealCost, "一键升级门派技能")
    for skObj in skillList:
        skId = skObj.id
        oldLevel = skObj.level
        addLevel, cost = dTmp.get(skId, 0)
        if not addLevel:
            continue
        writeLog(
            "skill/upgrade", "%d %d %d %d->%d" %
            (who.id, skId, cost, oldLevel, oldLevel + addLevel))
        who.setSkill(skId, oldLevel + addLevel)
    who.reCalcAttr()
    message.tips(who, "一键升级成功")

    import listener
    listener.doListen("升级门派技能", who)
Exemple #3
0
def doSkillSchUpgrade(who, skId):
    '''升级
	'''
    skObj = who.skillCtn.getItem(skId)
    if not skObj:
        return
    level = skObj.level
    tRet = calcUpgradeSkillSch(who, skId, level, skObj.getLevelMax(who))
    errCode = tRet[0]
    cost = tRet[1]
    add = tRet[2]
    if errCode == ERR_LACK_CASH:
        if not money.checkCash(who, cost):
            return
    elif errCode == ERR_TOP_LEVEL:
        message.tips(who, "门派技能无法超过人物等级")
        return
    who.costCash(cost, "升级技能%d" % skId)
    writeLog("skill/upgrade",
             "%d %d %d %d->%d" % (who.id, skId, cost, level, level + add))
    who.setSkill(skId, level + add)
    who.reCalcAttr()

    import listener
    listener.doListen("升级门派技能", who)
Exemple #4
0
def rpcEquipMakeReq(who, reqMsg):
	'''打造请求
	'''
	pid = who.id
	equipNo = reqMsg.equipNo
	makeType = reqMsg.makeType
	if not makeType in (0, 1):
		message.tips(who, "非法打造方式")
		return
	oTemplate = props.getCacheProps(equipNo)
	if not oTemplate:
		message.tips(who, "该装备不存在,无法打造")
		return
	elif oTemplate.level < 40:
		message.tips(who, "低于#C0440级#n的装备无法打造")
		return
	elif oTemplate.level > int(who.level / 10 + 1) * 10:
		message.tips(who, "装备等级超过当前可打造的最高等级,无法打造")
		return
	if who.propsCtn.leftCapacity() < 1:
		message.tips(who, "背包已满,无法打造,请先清理背包")
		return
	dMaterial = oTemplate.getConfig("打造材料", {})
	iMoney, dOwn, dLack = make.checkEquipMake(who, dMaterial)
	if makeType == 0:
		# 普通打造,检查打造所需材料
		if iMoney:
			message.tips(who, "材料不足,无法打造")
			return
	elif makeType == 1:
		# 快捷打造,检查打造所需材料和元宝
		if not money.checkTradeCash(who, iMoney):
			return
	else:
		return
	who = getRole(pid)
	if not who:
		return
	# 扣除打造消耗材料或元宝
	for iNo, iAmount in dOwn.iteritems():
		if not iAmount:
			continue
		who.propsCtn.subtractPropsByNo(iNo, iAmount, "打造消耗", None)
	if iMoney:
		who.addTradeCash(-iMoney, "快捷打造消耗", None)
		for iPropsId, iAmount in dLack.iteritems():
			ctype, price = trade.getGoodsPrice(iPropsId)
			trade.wave(iPropsId, price, iAmount)
	# 生成装备随机属性
	oEquip = make.makeEquip(equipNo)
	# 加到玩家背包
	launch.launchProps(who, oEquip, "装备打造", None)
	packData = make.packEquipInfo(oEquip)
	who.endPoint.rpcEquipMakeResponse(packData)
	message.tips(who, "打造成功,获得#C02{}×1#n".format(oEquip.name))
	equipMakeInfo(who, equipNo)
	
	import listener
	listener.doListen("打造装备", who, propsNo=oEquip.no(), propsId=oEquip.id)
Exemple #5
0
def add(who, iNo):
	buddyObj = new(iNo)
	who.buddyCtn.addItem(buddyObj)
	buddyObj.checkRelation(who)
	who.buddyCtn.addMajor(buddyObj)
	buddyObj.reCalcAttr()
	
	import listener
	listener.doListen("获得助战", who, buddyNo=buddyObj.no)

	return buddyObj
Exemple #6
0
def rpcBuyGoods(who, reqMsg):
    iPropsNo, iAmount = reqMsg.iPropsNo, reqMsg.iAmount
    if iAmount <= 0:
        message.tips(who, "购买数量异常")
        return
    if not shopData.hasProps(iPropsNo):
        return

    iNeedLv = shopData.getConfig(iPropsNo, "等级限制", -1)  #-1为没有等级限制
    # 人物>=40级只能买40级的物品,<40级只能买相关等级段的物品
    decimalLv = min(who.level / 10 * 10, 40)
    if iNeedLv != -1 and decimalLv != iNeedLv:
        message.tips(who, "等级不符合")
        return

    oProps = props.getCacheProps(iPropsNo)
    if not oProps:
        message.tips(who, "没有该物品")
        return

    iPrice = oProps.getConfig("出售价格")
    if iPrice <= 0:
        raise PlannerError("{}商品价格异常!请通知策划!".format(iPropsNo))
    iTotlePrice = iPrice * iAmount
    if not money.checkCash(who, iTotlePrice):
        return
    iCapacity = int(math.ceil(float(iAmount) / oProps.maxStack()))
    if iCapacity > who.propsCtn.leftCapacity():
        message.tips(who, "包裹已满,请清理包裹")
        return

    iBind = oProps.isBind()
    who.addCash(-iTotlePrice, "商店购买商品", None)
    launch.launchBySpecify(who,
                           iPropsNo,
                           iAmount,
                           iBind,
                           sLogReason="商店购买商品",
                           sTips=None)
    message.tips(who, "成功购买了#C02{}#n件#C02{}#n".format(iAmount, oProps.name))

    import listener
    listener.doListen("购买物品", who, price=iPrice)
Exemple #7
0
def listenerRaceAchv(who, **kwargs):
	rank = kwargs.get("rank", 0)
	if rank:
		import listener
		listener.doListen("竞技场排名", who, rank=rank)
Exemple #8
0
def rpcEquipRecast(who, reqMsg):
    '''装备重铸
	'''
    if who.level < 40:
        message.tips(who, "#C0440级#n开启#C02重铸系统#n")
        return
    oEquip = getRecastEquip(who, reqMsg.propsId)
    if not oEquip:
        return
    if oEquip.kind != ITEM_EQUIP:
        return

    # if not oEquip.fetch("addAttr") or not oEquip.getConfig("重铸材料"):
    if not oEquip.getConfig("重铸材料"):
        message.tips(who, "普通装备无法重铸")
        return

    #冷却时间
    recastTime = fetchEquipRecastTime(who, oEquip.id)
    if recastTime and getSecond() - recastTime < 3:
        message.tips(
            who, "冷却中,请#C04{}#n秒后再试".format(max(1,
                                                getSecond() - recastTime)))
        return

    propsNeeded = getRecastCost(who, oEquip, reqMsg.shortcut)
    # print "propsNeeded = ",propsNeeded
    if reqMsg.shortcut and propsNeeded.get(c.GOLD):
        if not money.checkTradeCash(who, propsNeeded.get(c.GOLD)):
            return
        # if who.tradeCash < propsNeeded.get(c.GOLD):
        # 	#检查游戏币是否足够
        # 	message.tips(who, "元宝不足")
        # 	return

    failReason = checkReCastCost(who, propsNeeded)
    if failReason:
        message.tips(who, failReason)
        #message.tips(who, "材料不足,无法重铸")
        return

    doConsumeRecastCost(who, propsNeeded, "装备重铸:{}".format(oEquip.no()))
    #重铸属性
    recastAttr = {}
    recastAttr["baseAttr"] = make.creatBaseAttr(oEquip)
    recastAttr["addAttr"] = make.creatAddAttr(oEquip)
    recastAttr["spEffect"] = make.createSpecialEffect(oEquip)
    recastAttr["spSkill"] = make.createSpecialSkill(oEquip)

    oEquipFork = props.fork(oEquip)
    oEquipFork.set("baseAttr", recastAttr["baseAttr"])
    oEquipFork.set("addAttr", recastAttr["addAttr"])
    oEquipFork.set("spEffect", recastAttr["spEffect"])
    oEquipFork.set("spSkill", recastAttr["spSkill"])

    #数据保存在玩家身上,装备的临时变量在穿上/卸下、移入仓库/取回时会丢失
    iIsRare = int(oEquipFork.isRare())
    recastAttr["isRare"] = iIsRare
    setEquipRecastAttr(who, oEquip.id, recastAttr)

    oldScore = oEquip.getScore()
    newScore = grade.gradeEquip(oEquipFork)
    # print "==rpcEquipRecast=",recastAttr,newScore,oldScore
    if newScore > oldScore or recastAttr.get("spEffect", 0) or recastAttr.get(
            "spSkill", 0):
        setEquipRecastTime(who, oEquip.id)

    sendEquipRecastAttr(who, oEquip, 1)
    message.tips(who, "重铸成功")
    log.log(
        "EquipRecast",
        "装备重铸:id={};no={};recastAttr={}".format(oEquip.id, oEquip.no(),
                                                recastAttr))

    import listener
    listener.doListen("重铸装备",
                      who,
                      propsNo=oEquip.no(),
                      propsId=oEquip.id,
                      recastIsRare=iIsRare)