示例#1
0
def do_list(ch, argument):
    if state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_PET_SHOP):
        # hack to make new thalos pets work
        pRoomIndexNext = None
        if ch.in_room.vnum == 9621:
            if 9706 in instance.room_templates:
                pRoomIndexNext = handler_room.get_room_by_vnum(9706)
        else:
            if ch.in_room.vnum + 1 in instance.room_templates:
                pRoomIndexNext = handler_room.get_room_by_vnum(ch.in_room.vnum + 1)
        if not pRoomIndexNext:
            logger.warn("BUG: Do_list: bad pet shop at vnum %d.", ch.in_room.vnum)
            ch.send("You can't do that here.\n")
            return
        found = False
        for pet in pRoomIndexNext.people[:]:
            if pet.act.is_set(merc.ACT_PET):
                if not found:
                    found = True
                    ch.send("Pets for sale:\n")
                ch.send("[[%2d]] %8d - %s\n" % (pet.level, 10 * pet.level * pet.level, pet.short_descr))
        if not found:
            ch.send("Sorry, we're out of pets right now.\n")
        return
    else:
        keeper = shop_utils.find_keeper(ch)
        if not keeper:
            return
        argument, arg = game_utils.read_word(argument)
        items = collections.OrderedDict()
        for item_id in keeper.inventory[:]:
            item = instance.items[item_id]
            cost = shop_utils.get_cost(keeper, item, True)
            if not item.equipped_to and ch.can_see_item(item) and cost > 0 \
                    and (not arg or arg in item.name.lower()):
                if item.inventory:
                    items[(item.vnum, item.short_descr)] = (item.vnum, -1)
                else:
                    k = (item.vnum, item.short_descr)
                    if k not in items:
                        items[k] = (item, 1)
                    else:
                        items[k][1] += 1
        if not items:
            ch.send("You can't buy anything here.\n")
            return
        ch.send("[[Lv Price Qty]] Item\n")
        for k, p in items.items():
            item, count = p
            cost = shop_utils.get_cost(keeper, item, True)
            ch.send("[[%2d %5d %2s ]] %s" % (item.level, cost, ("--" if item.flags.shop_inventory else count), item.short_descr))
            if ch.act.is_set(merc.PLR_OMNI):
                ch.send("(%d)" % item.vnum)
            ch.send("\n")
示例#2
0
def spell_word_of_recall(sn, level, ch, victim, target):
    # RT recall spell is back */
    if victim.is_npc():
        return

    location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
    if not location:
        victim.send("You are completely lost.\n")
        return

    if state_checks.IS_SET(victim.in_room.room_flags,
                           merc.ROOM_NO_RECALL) or victim.is_affected(
                               merc.AFF_CURSE):
        victim.send("Spell failed.\n")
        return

    if victim.fighting:
        fight.stop_fighting(victim, True)

    ch.move //= 2
    handler_game.act("$n disappears.", victim, None, None, merc.TO_ROOM)
    victim.in_room.get(victim)
    location.put(victim)
    handler_game.act("$n appears in the room.", victim, None, None,
                     merc.TO_ROOM)
    victim.do_look("auto")
示例#3
0
def cmd_list(ch, argument):
    argument, arg = game_utils.read_word(argument)

    buf = []
    if ch.in_room.room_flags.is_set(merc.ROOM_PET_SHOP):
        proomindexnext = None
        if ch.in_room.vnum + 1 in instance.room_templates:
            proomindexnext = handler_room.get_room_by_vnum(ch.in_room.vnum + 1)
        if not proomindexnext:
            comm.notify("cmd_list: bad pet shop at vnum {}".format(ch.in_room.vnum), merc.CONSOLE_ERROR)
            ch.send("You can't do that here.\n")
            return

        found = False
        for pet in proomindexnext.people[:]:
            if pet.act.is_set(merc.ACT_PET):
                if not found:
                    found = True
                    buf = "Pets for sale:\n"

                buf += "[{:2}] {:8} - {}\n".format(pet.level, 10 * pet.level * pet.level, pet.short_descr)

        if not found:
            buf += "Sorry, we're out of pets right now.\n"
        ch.send("".join(buf))
        return

    keeper = shop_utils.find_keeper(ch)
    if not keeper:
        return

    items = collections.OrderedDict()
    for item_id in keeper.inventory[:]:
        item = instance.items[item_id]
        cost = shop_utils.get_cost(keeper, item, True)

        if not item.equipped_to and ch.can_see_item(item) and cost > 0 and (not arg or not game_utils.str_prefix(arg, item.name)):
            if item.inventory:
                items[(item.vnum, item.short_descr)] = (item.vnum, -1)
            else:
                k = (item.vnum, item.short_descr)
                if k not in items:
                    items[k] = (item, 1)
                else:
                    items[k][1] += 1

    if not items:
        if not arg:
            buf += "You can't buy anything here.\n"
        else:
            buf += "You can't buy that here.\n"

    buf += "[Lv Price] Item\n"

    for k, p in items.items():
        item, count = p
        cost = shop_utils.get_cost(keeper, item, True)
        buf += "[{:2} {:5}] {}\n".format(item.level, cost, item.short_descr.capitalize())
    ch.send("".join(buf))
示例#4
0
def cmd_recall(ch, argument):
    handler_game.act("Your body flickers with green energy.", ch, None, None,
                     merc.TO_CHAR)
    handler_game.act("$n's body flickers with green energy.", ch, None, None,
                     merc.TO_ROOM)

    location = handler_room.get_room_by_vnum(ch.home)
    if not location:
        location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
        if not location:
            ch.send("You are completely lost.\n")
            return

    if ch.in_room == location:
        return

    if ch.in_room.room_flags.is_set(merc.ROOM_NO_RECALL) or ch.is_affected(
            merc.AFF_CURSE):
        ch.send("You are unable to recall.\n")
        return

    victim = ch.fighting
    if victim:
        if game_utils.number_bits(1) == 0:
            ch.wait_state(4)
            ch.send("You failed!\n")
            return

        ch.send("You recall from combat!\n")
        fight.stop_fighting(ch, True)

    handler_game.act("$n disappears.", ch, None, None, merc.TO_ROOM)
    ch.in_room.get(ch)
    location.put(ch)
    handler_game.act("$n appears in the room.", ch, None, None, merc.TO_ROOM)
    ch.cmd_look("auto")

    mount = ch.mount
    if mount:
        mount.in_room.get(mount)
        location.put(mount)
示例#5
0
def do_recall(ch, argument):
    if ch.is_npc() and not ch.act.is_set(merc.ACT_PET):
        ch.send("Only players can recall.\n")
        return
    handler_game.act("$n prays for transportation!", ch, 0, 0, merc.TO_ROOM)
    location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
    if not location:
        ch.send("You are completely lost.\n")
        return
    if ch.in_room == location:
        return
    if state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_NO_RECALL) or ch.is_affected(merc.AFF_CURSE):
        ch.send("Mota has forsaken you.\n")
        return
    victim = ch.fighting
    if victim:
        skill = ch.get_skill("recall")
        if random.randint(1, 99) < 80 * skill / 100:
            if ch.is_pc():
                ch.check_improve( "recall", False, 6)
            state_checks.WAIT_STATE(ch, 4)
            ch.send("You failed!.\n")
            return
        lose = 25 if ch.desc else 50
        update.gain_exp(ch, 0 - lose)
        if ch.is_pc():
            ch.check_improve( "recall", True, 4)
        ch.send("You recall from combat!  You lose %d exps.\n" % lose)
        fight.stop_fighting(ch, True)
    ch.move /= 2
    handler_game.act("$n disappears.", ch, None, None, merc.TO_ROOM)
    ch.in_room.get(ch)
    location.put(ch)
    handler_game.act("$n appears in the room.", ch, None, None, merc.TO_ROOM)
    ch.do_look("auto")

    if ch.pet is not None:
        ch.pet.do_recall("")
    return
示例#6
0
def spell_word_of_recall(sn, level, ch, victim, target):
    # RT recall spell is back */
    if victim.is_npc():
        return

    location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
    if not location:
        victim.send("You are completely lost.\n")
        return

    if state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NO_RECALL) or victim.is_affected(merc.AFF_CURSE):
        victim.send("Spell failed.\n")
        return

    if victim.fighting:
        fight.stop_fighting(victim, True)

    ch.move //= 2
    handler_game.act("$n disappears.", victim, None, None, merc.TO_ROOM)
    victim.in_room.get(victim)
    location.put(victim)
    handler_game.act("$n appears in the room.", victim, None, None, merc.TO_ROOM)
    victim.do_look("auto")
示例#7
0
def cmd_buy(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Buy what?\n")
        return

    if ch.in_room.room_flags.is_set(merc.ROOM_PET_SHOP):
        if ch.is_npc():
            return

        proomindexnext = None
        if ch.in_room.vnum + 1 in instance.room_templates:
            proomindexnext = handler_room.get_room_by_vnum(ch.in_room.vnum + 1)
        if not proomindexnext:
            comm.notify(
                "cmd_buy: bad pet shop at vnum {}".format(ch.in_room.vnum),
                merc.CONSOLE_ERROR)
            ch.send("Sorry, you can't buy that here.\n")
            return

        in_room = ch.in_room
        ch.in_room = proomindexnext
        pet = ch.get_char_room(arg)
        ch.in_room = in_room

        if not pet or not pet.act.is_set(merc.ACT_PET):
            ch.send("Sorry, you can't buy that here.\n")
            return

        if ch.gold < 10 * pet.level * pet.level:
            ch.send("You can't afford it.\n")
            return

        if ch.level < pet.level:
            ch.send("You're not ready for this pet.\n")
            return

        ch.gold -= 10 * pet.level * pet.level
        pet = object_creator.create_mobile(instance.npc_templates[pet.vnum])
        pet.act.set_bit(merc.ACT_PET)
        pet.affected_by.set_bit(merc.AFF_CHARM)

        argument, arg = game_utils.read_word(argument)
        if arg:
            pet.name = "{} {}".format(pet.name, arg)

        pet.description = "{}A neck tag says 'I belong to {}'.\n".format(
            pet.description, ch.name)
        ch.in_room.put(pet)
        pet.add_follower(ch)
        ch.send("Enjoy your pet.\n")
        handler_game.act("$n bought $N as a pet.", ch, None, pet, merc.TO_ROOM)
    else:
        keeper = shop_utils.find_keeper(ch)
        if not keeper:
            return

        item = keeper.get_item_carry(arg)
        cost = shop_utils.get_cost(keeper, item, True)
        if cost <= 0 or not ch.can_see_item(item):
            handler_game.act("$n tells you 'I don't sell that -- try 'list''.",
                             keeper, None, ch, merc.TO_VICT)
            ch.reply = keeper
            return

        if ch.gold < cost:
            handler_game.act("$n tells you 'You can't afford to buy $p'.",
                             keeper, item, ch, merc.TO_VICT)
            ch.reply = keeper
            return

        if item.level > ch.level and ch.level < 3:
            handler_game.act("$n tells you 'You can't use $p yet'.", keeper,
                             item, ch, merc.TO_VICT)
            ch.reply = keeper
            return

        if ch.carry_number + 1 > ch.can_carry_n():
            ch.send("You can't carry that many items.\n")
            return

        if ch.carry_weight + item.get_weight() > ch.can_carry_w():
            ch.send("You can't carry that much weight.\n")
            return

        handler_game.act("$n buys $p.", ch, item, None, merc.TO_ROOM)
        handler_game.act("You buy $p.", ch, item, None, merc.TO_CHAR)
        ch.gold -= cost
        keeper.gold += cost

        if item.flags.inventory:
            item = object_creator.create_item(
                instance.item_templates[item.vnum], item.level)
        else:
            item.in_living.get(item)
        ch.put(item)
示例#8
0
文件: do_list.py 项目: totalgit/PyRom
def do_list(ch, argument):
    if state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_PET_SHOP):
        # hack to make new thalos pets work
        pRoomIndexNext = None
        if ch.in_room.vnum == 9621:
            if 9706 in instance.room_templates:
                pRoomIndexNext = handler_room.get_room_by_vnum(9706)
        else:
            if ch.in_room.vnum + 1 in instance.room_templates:
                pRoomIndexNext = handler_room.get_room_by_vnum(
                    ch.in_room.vnum + 1)
        if not pRoomIndexNext:
            logger.warn("BUG: Do_list: bad pet shop at vnum %d.",
                        ch.in_room.vnum)
            ch.send("You can't do that here.\n")
            return
        found = False
        for pet in pRoomIndexNext.people[:]:
            if pet.act.is_set(merc.ACT_PET):
                if not found:
                    found = True
                    ch.send("Pets for sale:\n")
                ch.send(
                    "[[%2d]] %8d - %s\n" %
                    (pet.level, 10 * pet.level * pet.level, pet.short_descr))
        if not found:
            ch.send("Sorry, we're out of pets right now.\n")
        return
    else:
        keeper = shop_utils.find_keeper(ch)
        if not keeper:
            return
        argument, arg = game_utils.read_word(argument)
        items = collections.OrderedDict()
        for item_id in keeper.inventory[:]:
            item = instance.items[item_id]
            cost = shop_utils.get_cost(keeper, item, True)
            if not item.equipped_to and ch.can_see_item(item) and cost > 0 \
                    and (not arg or arg in item.name.lower()):
                if item.inventory:
                    items[(item.vnum, item.short_descr)] = (item.vnum, -1)
                else:
                    k = (item.vnum, item.short_descr)
                    if k not in items:
                        items[k] = (item, 1)
                    else:
                        items[k][1] += 1
        if not items:
            ch.send("You can't buy anything here.\n")
            return
        ch.send("[[Lv Price Qty]] Item\n")
        for k, p in items.items():
            item, count = p
            cost = shop_utils.get_cost(keeper, item, True)
            ch.send("[[%2d %5d %2s ]] %s" %
                    (item.level, cost,
                     ("--" if item.flags.shop_inventory else count),
                     item.short_descr))
            if ch.act.is_set(merc.PLR_OMNI):
                ch.send("(%d)" % item.vnum)
            ch.send("\n")