Exemple #1
0
async def begin_manuscript(cmd):
    user_data = EwUser(member=cmd.message.author)
    title = cmd.message.content[(len(cmd.tokens[0])):].strip()

    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    cost = 20000

    poi = poi_static.id_to_poi.get(user_data.poi)

    if not poi.write_manuscript or poi.id_poi == ewcfg.poi_id_clinicofslimoplasty:
        response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS)."

    elif user_data.slimes < cost:
        response = "You don't have enough slime to create a manuscript. ({:,}/{:,})".format(user_data.slimes, cost)

    elif user_data.hunger >= user_data.get_hunger_max() and user_data.life_state != ewcfg.life_state_corpse:
        response = "You are just too hungry to begin your masterpiece!"

    elif title == "":
        response = "Specify a title."

    elif len(title) > 50:
        response = "Alright buddy, reel it in. That title is just too long. ({:,}/50)".format(len(title))

    else:

        if user_data.manuscript != -1:
            response = "You already have a manuscript deployed you eager beaver!"
        else:
            book = EwBook(member=cmd.message.author, book_state=0)
            book.author = cmd.message.author.display_name
            book.title = title
            user_data.manuscript = book.id_book
            user_data.change_slimes(n=-cost, source=ewcfg.source_spending)

            book.persist()
            user_data.persist()

            response = "You exchange 20,000 slime for a shoddily-bound manuscript. You scrawl the name \"{} by {}\" into the cover.".format(book.title, book.author)

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Exemple #2
0
async def publish_manuscript(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    market_data = EwMarket(id_server=user_data.id_server)

    poi = poi_static.id_to_poi.get(user_data.poi)

    if not poi.write_manuscript:
        response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS)."

    elif user_data.manuscript == -1:
        response = "You have yet to create a manuscript. Try !createmanuscript"

    else:
        book = EwBook(member=cmd.message.author, book_state=0)
        # check if zine is unreasonably short
        length = 0
        for page in book.book_pages.keys():
            length += len(book.book_pages[page])

        if book.genre == -1:
            response = "Before you publish your zine, you must first set a genre with !setgenre. The genre choices are {}.".format(ewutils.formatNiceList(ewcfg.book_genres))

        elif len(book.book_pages.keys()) < 3 or length < 10:
            response = "Who are you trying to fool? This zine is obviously too short!"

        else:
            accepted = False

            response = "Are you sure you want to publish your manuscript? This cannot be undone. **!accept** or **!refuse**"

            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            try:
                message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and
                                                                                                 message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

                if message != None:
                    if message.content.lower() == ewcfg.cmd_accept:
                        accepted = True
                    if message.content.lower() == ewcfg.cmd_refuse:
                        accepted = False
            except:
                accepted = False

            if not accepted:
                response = "The manuscript was not published."

            else:
                book.book_state = 1
                book.date_published = market_data.day
                length = 0

                for page in range(1, book.pages + 1):
                    length += len(book.book_pages.get(page, ""))

                book.length = length
                user_data.manuscript = -1

                user_data.persist()
                book.persist()

                bknd_item.item_create(
                    item_type=ewcfg.it_book,
                    id_user=user_data.id_user,
                    id_server=book.id_server,
                    item_props={
                        "title": book.title,
                        "author": book.author,
                        "date_published": book.date_published,
                        "id_book": book.id_book,
                        "book_desc": "A zine by {}, published on {}. It's the author's copy.".format(book.author, book.date_published)
                    })

                book_sale = EwBookSale(id_book=book.id_book, member=cmd.message.author)
                book_sale.bought = 1

                book_sale.persist()

                response = "You've published your manuscript! Anybody can now buy your creation and you'll get royalties!"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))