示例#1
0
def explore(openid, request):
    """灵路探险
    """
    try:
        seqno = int(request)
    except ValueError:
        return {"result": True, "data": "伙伴序号有误,请重新选择"}
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    try:
        partner = player.partners.getPartnerBySeqno(seqno)
    except IndexError:
        return {"result": True, "data": "伙伴序号有误,请重新选择"}
    if partner.road.energy <= 0:
        info = "当前体力不足,每1小时恢复1点\n提示;每天可以购买20次体力,当前购买体力需要消耗%s元宝,输入“购买体力”可购买体力" % 2 * player.model.energy_buytime
    else:
        info = partner.road.explore()
        player.plot.notice("explore")
        msg = [
            "%s.[%s]%s" % (i, partner.getName(), partner.road.enter_info())
            for i, partner in enumerate(player.partners.getPartners(), start=1)
        ]
        msg.append("当前体力%s(每1小时恢复1点)" % player.model.energy)
        msg.append("\n提示:输入名字前序号将进行灵路探险,例如1")
        player.addRoleMessage(["\n".join(msg)])
    player.model.save()
    return {"result": True, "data": info}
示例#2
0
def strengthen(openid, request):
    """装备强化
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    seqno = weiuser.prev_objectid
    partner = player.partners.getPartnerBySeqno(seqno)
    equipment_key = equip_type(request)
    if equipment_key is None:
        info = partner.equipment.strengthenView()
    else:
        partner.equipment.updateEquipType(equipment_key)
        print partner.equipment.getBattleAttribute()
        if partner.equipment.isTopStren():
            info = "无法强化 已经是最高级"
        else:
            if not partner.equipment.strenRoleLevelEnough():
                info = "当前人物等级不够"
            elif not partner.equipment.moneyEnough():
                info = "强化失败 铜钱不足"
            else:
                info = partner.equipment.strengthen()
                player.plot.notice("strengthen") #通知强化
                player.model.save()
                partner.equipment.equip_model.save()
    return {"result":True,"data":info}
示例#3
0
def partnerinfo(openid, request):
    """伙伴基础信息
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    partner_info = gamedataconfig.ALL_PARTNER_INFO
    partner_ids = [
        partner_id for partner_id in partner_info.iterkeys()
        if not player.partners.checkHasPartner(partner_id)
    ]
    try:
        partnerid = partner_ids[int(request) - 1]
    except (ValueError, IndexError):
        return {"result": True, "data": "伙伴序号有误"}
    print 'partnerid', partnerid
    player.model.prev_command = "tavern_recruit"
    player.model.prev_objectid = partnerid
    friendships = dict(
        ((f.partner_id, f.friendship) for f in player.model.friendships))
    attr = dict(gamedataconfig.ALL_PARTNER_INFO[partnerid])  #make a copy
    #已经有的交情
    attr["a_friendship"] = friendships[
        partnerid] if partnerid in friendships else 0
    skill_1 = attr.get("skill_1", "90000")
    skill_2 = attr.get("skill_2", "90000")
    attr["skill_1"] = gamedataconfig.ALL_SKILL_INFO[skill_1]["skill_name"]
    attr["skill_1_desc"] = gamedataconfig.ALL_SKILL_INFO[skill_1]["skill_desc"]
    attr["skill_2"] = gamedataconfig.ALL_SKILL_INFO[skill_2]["skill_name"]
    attr["skill_2_desc"] = gamedataconfig.ALL_SKILL_INFO[skill_2]["skill_desc"]
    format_info = "{partner_name} (交情:{a_friendship}/{friendship})\n气血:{maxhp}\n普通攻击:{attack}\n法术攻击:{magic_attack}\n普通防御:{defend}\n法术防御:{magic_defend}\n命中:{hit}\n闪避:{dodge}\n暴击:{crit}\n韧性:{tenacity}\n致命:{fatal}\n速度:{speed}\n灵诀:{skill_1}【{skill_1_desc}】\n神术:{skill_2}【{skill_2_desc}】"
    info = format_info.format(**attr)
    info += "\n\n提示:1.输入“增加交情”后可增加交情操作;2.输入“返回酒馆”返回到酒馆"
    player.model.save()
    return {"result": True, "data": info}
示例#4
0
def tavern(openid, request):
    """酒馆
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    partner_info = gamedataconfig.ALL_PARTNER_INFO
    partner_ids = [
        partner_id for partner_id in partner_info.iterkeys()
        if not player.partners.checkHasPartner(partner_id)
    ]
    friendships = dict(
        ((f.partner_id, f.friendship) for f in player.model.friendships))
    info = [
        "%s. %s (交情值:%s/%s)" %
        (i, partner_info[p]["partner_name"], friendships.get(
            p, 0), partner_info[p]["friendship"])
        for i, p in enumerate(partner_ids, start=1)
    ]
    if info:
        info.append("\n提示:输入伙伴名前的“数字”可查看对应伙伴信息")
        player.model.prev_command = "tavern"
        player.plot.notice("tavern")
        player.model.save()
    else:
        info.append("没有可招募伙伴")

    return {"result": True, "data": "\n".join(info)}
示例#5
0
def RoleProperty(openid, request):
    """获取获取角色属性
    """
    seqnostr = request.replace("属性", "").strip()
    try:
        seqno = int(seqnostr)
    except ValueError:
        seqno = 1
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = []
    try:
        partner = player.partners.getPartnerBySeqno(seqno)
    except IndexError:
        return {"result": True, "data": "伙伴序号有误,请重新选择"}
    partner_info = partner.attribute.getAttributeFormat()
    info.append(partner_info)
    player.plot.notice('property')  #通知查看了角色的属性
    info.append("请选择操作对象:")
    for i, partner in enumerate(player.partners.getPartners(), start=1):
        info.append("%s.%s" % (i, partner.getName()))
    info.append("\n操作提示:输入名字前序号,可以查看相应人物属性信息,例如:输入“1”获得主角信息")
    weiuser.prev_command = "property"
    player.model.save()
    return {"result": True, "data": "\n".join(info)}
示例#6
0
def package(openid, request):
    """背包
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = player.package.view() or "背包为空"
    return {"result": True, "data": info}
示例#7
0
def fight(openid,request):
    """获取当前地图信息
    """
    from app.configdata import gamedataconfig
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    #如果是剧情战斗
    if player.plot.IsPlotFight():
        battleid = player.plot.getPlotBattleId()
        battle_info = gamedataconfig.ALL_FIGHT_INFO.get(battleid)
        m_config_str = battle_info.get("monster")
        
        #战斗描述
        fight_desc = battle_info.get("desc")
        fight = DoFightWithMonster(player, m_config_str)
        fight.start()
#         player.addRoleMessage(fight.rounds)
        player.plot.notice("fight")
        info = fight_desc+"\n"+"\n".join(fight.rounds)
    else:
        info = "没有战斗对象"
    player.model.save()
    return {"result":True,"data":info}



    
    
示例#8
0
def sign(openid, request):
    """签到
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = player.sign.sign()
    player.model.save()
    player.plot.notice("sign")
    return {"result": True, "data": info}
示例#9
0
def rob_info(openid, request):
    """打劫信息
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = player.sign.rob_info()
    player.model.prev_command = "rob_info"
    player.model.save()
    return {"result": True, "data": info}
示例#10
0
def famlist(openid, request):
    """获取当前可进行的副本列表
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = player.fam.getFamList()
    player.plot.notice('famlist')  #通知查看了副本列表
    player.model.prev_command = "famlist"
    player.model.save()
    return {"result": True, "data": info}
示例#11
0
def exchange_info(openid, request):
    """积分兑换信息
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = player.sign.exchange_info()
    player.model.prev_command = "exchange_info"
    player.model.save()
    player.plot.notice("exchange_info")
    return {"result": True, "data": info}
示例#12
0
def property_skill(openid, request):
    """属性·技能
    """
    info = ["%s.%s" % (i, f[0]) for i, f in enumerate(_PS, start=1)]
    info.append("\n提示请输入功能序号,如1将查询”属性“信息")
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    player.model.prev_command = "property_skill"
    player.model.save()
    return {"result": True, "data": "\n".join(info)}
示例#13
0
def formation_tavern(openid, request):
    """布阵·酒馆
    """
    info = ["%s.%s" % (i, f[0]) for i, f in enumerate(_FT, start=1)]
    info.append("\n提示请输入功能序号,如1将查询”阵法“信息")
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    player.model.prev_command = "formation_tavern"
    player.model.save()
    return {"result": True, "data": "\n".join(info)}
示例#14
0
def nowplot(openid,request):
    """获取当前剧情信息
    """
    weiuser = role.Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = player.plot.getNowPlotDesc()
    player.model.save()
    return {"result":True,"data":info}
    
    
示例#15
0
def equipchoice(openid, request):
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = []
    info.append("请选择操作对象:")
    for i, partner in enumerate(player.partners.getPartners(),start=1):
        info.append("%s.%s" % (i, partner.getName()))
    info.append("\n操作提示:输入名字前序号,可以查看相应人物装备信息,例如:输入“1”获得主角装备信息")
    weiuser.prev_command = "equipchoice"
    weiuser.save()
    return {"result":True,"data":"\n".join(info)}
示例#16
0
def autostrengthen(openid, request):
    """自动强化
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    seqno = weiuser.prev_objectid
    partner = player.partners.getPartnerBySeqno(seqno)

    flags = dict(izip(EQUIPMENT_KEY,(False,)*3))
    success = OrderedDict(izip(EQUIPMENT_KEY,(None,)*3))
    minus = set()
    for i in xrange(5):
        for key in EQUIPMENT_KEY:
            if key in minus:
                continue
            partner.equipment.updateEquipType(key)
            if partner.equipment.isTopStren():
                minus.add(key)
                flags[key] = 1
            elif not partner.equipment.strenRoleLevelEnough():
                minus.add(key)
                flags[key] = 2
            elif not partner.equipment.moneyEnough():
                minus.add(key)
                flags[key] = 3
            else:
                success[key] = partner.equipment.strengthen() + '\n'
    info = [v for v in success.itervalues() if v]
    if info: #至少有一件强化成功
        player.model.save()
        partner.equipment.equip_model.save()
    else:
        c = {
            1: "无法强化 已经是最高级",
            2: "强化失败 当前人物等级不够",
            3: "强化失败 铜钱不足"
        }
        values = set(flags.itervalues())
        if len(values) == 1: #强化失败原因都相同
            info.append(c[values.pop()])
        else:
            for key in EQUIPMENT_KEY:
                info.append("%s %s" %(EQUIPMENT[key], c[flags[key]]))
    player.plot.notice("strengthen") #通知强化
    player.model.save()
    info = "\n".join(info)
    return {"result":True,"data":info}





    
    
示例#17
0
def setNickName(openid,request):
    """
    """
    weiuser = role.Role.objects.get(openid=openid)
    if not checkNickname(request):
        return {"result":True,"data":msgconfig.getMsgFormat("illegal_name")}
    weiuser.nickname = request
    player = Charater(weiuser)
    player.plot.notice("subscribe")
    player.model.save()
    return {"result":True,"data":""}
示例#18
0
def rob(openid, request):
    """打劫
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    help = "\n提示:输入玩家序号可以继续打劫"
    if player.sign.rob_time <= 0:
        return {"result": True, "data": "您今天做的坏事已经够多了,不要再打劫别人啦!"}
    try:
        ropenid = player.sign.rob_user[int(request) - 1]
    except (IndexError, ValueError):
        return {"result": True, "data": "序号选择有误,请重新选择"}
    robed_player = Charater(Role.objects.get(openid=ropenid))
    if robed_player.sign.robed_time >= 10:
        info = "他今天被打劫的次数已经够多了,不要再打劫他啦!!"
    else:
        info = player.sign.rob(robed_player)
        robed_player.model.save()
    player.addRoleMessage([player.sign.rob_info()])
    player.model.save()
    return {"result": True, "data": info}
示例#19
0
def exitFam(openid, request):
    """挑战副本
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    fam_id = player.fam.fam
    if not fam_id:
        info = "当前不在秘境中"
    else:
        info = player.fam.exitFam()
        player.plot.notice('exitfam', fam_id=fam_id)  #通知进行了副本战斗
    player.model.save()
    return {"result": True, "data": info}
示例#20
0
def getSkillInfo(openid, request):
    """获取技能信息
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = []
    for i, partner in enumerate(player.partners.getPartners(), start=1):
        attr = partner.attribute.getSkillDetails()
        info.append("%s.%s" % (i, partner.getName()))
        info.append(
            "  灵诀:{skill_1} 【{skill_1_desc}】\n  神术:{skill_2} 【{skill_2_desc}】\n"
            .format(**attr))
    player.plot.notice("skill")
    player.model.save()
    return {"result": True, "data": "\n".join(info)}
示例#21
0
def challenge(openid, request):
    """挑战副本
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    fam_id = player.fam.fam
    fam_node = player.fam.famnode
    if not fam_id or not fam_node:
        info = "当前不在秘境中"
    else:
        info = player.fam.challenge()
        player.plot.notice('challenge', fam_id=fam_id,
                           fam_node=fam_node)  #通知进行了副本战斗
    player.model.save()
    return {"result": True, "data": info}
示例#22
0
def enterFam(openid, request):
    """进入副本
    """
    fam_id = request.replace("进入", "").strip()
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    now_fam_id = player.fam.fam
    # if now_fam_id:
    #     info="当前已经在秘境中"
    # else:
    info = player.fam.enterFam(fam_id)
    player.plot.notice('enterfam', fam_id=fam_id)  #通知进入了副本

    player.model.save()
    return {"result": True, "data": info}
示例#23
0
def gongfa(openid, request):
    """功法
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = []
    info = [
        "%s.%s" % (i, partner.getName())
        for i, partner in enumerate(player.partners.getPartners(), start=1)
    ]
    info.append("\n提示:输入名字前序号提高功法,例如1")
    player.model.prev_command = "gongfa"
    player.model.save()
    player.plot.notice("gongfa")
    return {"result": True, "data": "\n".join(info)}
示例#24
0
def road(openid, request):
    """灵路
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = []
    info = [
        "%s.[%s]%s" % (i, partner.getName(), partner.road.enter_info())
        for i, partner in enumerate(player.partners.getPartners(), start=1)
    ]
    info.append("当前体力%s(每1小时恢复1点)" % player.model.energy)
    info.append("\n提示:输入名字前序号进行灵路探险,例如1")
    player.model.prev_command = "road"
    player.model.save()
    player.plot.notice("enter_road")
    return {"result": True, "data": "\n".join(info)}
示例#25
0
def buy(openid, request):
    """购买体力
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    cost = player.model.energy_buytime * 2
    if player.model.energy_buytime > 20:
        info = "同学今日购买次数已达上限,明天再来吧"
    elif player.model.gold >= cost:
        player.model.gold -= cost
        player.model.energy_buytime += 1
        player.model.energy += 1
        player.model.save()
        info = "购买成功,消耗%s元宝,当前体力%s" % (cost, player.model.energy)
    else:
        info = "购买失败,元宝不足"
    return {"result": True, "data": info}
示例#26
0
def getFormationInfo(openid, request):
    """获取阵法信息
    """
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    info = ["【当前拥有伙伴】"]
    for i, p in enumerate(player.partners.getPartners()[1:], start=1):
        info.append("%s:%s" % (i, p.getName()))
    if len(info) == 1:
        info.append("暂时没有伙伴")
    info.append("【当前阵法】")
    info.append(player.formation.getFormationInfo())
    info.append(
        "\n操作提示:更换阵法请输入“更换阵法”,如“更换阵法 @2@3@4”,即上阵2号、3号和4号伙伴,若输入“@”则所有伙伴都不上阵")
    player.plot.notice('formation_info')  #通知查看了角色的属性
    player.model.save()
    return {"result": True, "data": "\n".join(info)}
示例#27
0
def equipment(openid, request):
    """查看装备
    """
    if not request.isdigit():
        return {"result":True,"data":"操作对象序号有误"}
    seqno = int(request)
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    if seqno < 1 or seqno > player.partners.getPartnerCount():
        return {"result":True,"data":"操作对象序号有误"}

    partner = player.partners.getPartnerBySeqno(seqno)
    weiuser.prev_objectid = seqno
    weiuser.prev_command = "equipment"
    weiuser.save()
    info = partner.equipment.view()
    return {"result":True,"data":info}
示例#28
0
def gongfa_choice(openid, request):
    """具体功法选择
    """
    try:
        no = int(request)
    except ValueError:
        return {"result": False, "data": "提升功法序号有误,请重新选择"}
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    seqno = player.model.prev_objectid
    partner = player.partners.getPartnerBySeqno(seqno)
    success, info = partner.gongfa.choice(no)
    player.model.prev_command = "gongfa_choice"
    player.model.prev_objectid2 = no
    if success:
        player.model.save()
    return {"result": True, "data": info}
示例#29
0
def gongfa_enter(openid, request):
    """
    """
    try:
        seqno = int(request)
    except ValueError:
        return {"result": False, "data": "伙伴序号有误,请重新选择"}
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    try:
        partner = player.partners.getPartnerBySeqno(seqno)
    except IndexError:
        return {"result": False, "data": "伙伴序号有误,请重新选择"}
    info = partner.gongfa.enter_info()
    player.model.prev_command = "gongfa_enter"
    player.model.prev_objectid = seqno
    player.model.save()
    return {"result": True, "data": info}
示例#30
0
def gongfa_practice(openid, request):
    """功法修炼
    """
    try:
        no = int(request)
    except ValueError:
        return {"result": False, "data": "序号有误,请重新选择"}
    if no not in [1, 2]:
        return {"result": False, "data": "序号有误,请重新选择"}
    weiuser = Role.objects.get(openid=openid)
    player = Charater(weiuser)
    seqno = player.model.prev_objectid
    partner = player.partners.getPartnerBySeqno(seqno)
    gfno = player.model.prev_objectid2
    success, info = partner.gongfa.practice(gfno, no)
    if success:
        player.model.save()
        partner.gongfa.save()
    return {"result": True, "data": info}