コード例 #1
0
ファイル: f2p.py プロジェクト: JordanMilne/reddit-plugin-f2p
def comment_reply_effect(comment):
    if comment.parent_id is not None:
        parent = Comment._byID(comment.parent_id, data=True)
    else:
        parent = Link._byID(comment.link_id, data=True)
    all_effects = effects.get_all_effects([parent._fullname])
    parent_effects = all_effects.get(parent._fullname, [])
    for item_name in parent_effects:
        item = items.get_item(item_name)
        item.on_reply(c.user, parent)
コード例 #2
0
def comment_reply_effect(comment):
    if comment.parent_id is not None:
        parent = Comment._byID(comment.parent_id, data=True)
    else:
        parent = Link._byID(comment.link_id, data=True)
    all_effects = effects.get_all_effects([parent._fullname])
    parent_effects = all_effects.get(parent._fullname, [])
    for item_name in parent_effects:
        item = items.get_item(item_name)
        item.on_reply(c.user, parent)
コード例 #3
0
ファイル: f2p.py プロジェクト: JordanMilne/reddit-plugin-f2p
    def POST_use_item(self, item_name, target):
        try:
            inventory.consume_item(c.user, item_name)
        except inventory.NoSuchItemError:
            abort(400)

        c.user.f2p = "participated"
        c.user._commit()

        item = items.get_item(item_name)
        if not item.is_target_valid(target):
            abort(400)
        item.on_use(c.user, target)

        return json.dumps(c.state_changes)
コード例 #4
0
    def POST_use_item(self, item_name, target):
        try:
            inventory.consume_item(c.user, item_name)
        except inventory.NoSuchItemError:
            abort(400)

        c.user.f2p = "participated"
        c.user._commit()

        item = items.get_item(item_name)
        if not item.is_target_valid(target):
            abort(400)
        item.on_use(c.user, target)

        return json.dumps(c.state_changes)
コード例 #5
0
ファイル: f2p.py プロジェクト: JordanMilne/reddit-plugin-f2p
def drop_item():
    """Choose an item and add it to the user's inventory.

    The rarity class of the item to drop is chosen by weighted lottery
    according to the weights configured in live config. An item from within
    that rarity class is then chosen uniformly at random.

    """

    item_name = choose_random_item()

    g.log.debug("dropping item %r for %r", item_name, c.user.name)
    g.stats.event_count("f2p.drop", item_name)
    item = items.get_item(item_name)
    item.on_drop(c.user)
    c.js_preload.set("#drop", [item_name])
コード例 #6
0
def drop_item():
    """Choose an item and add it to the user's inventory.

    The rarity class of the item to drop is chosen by weighted lottery
    according to the weights configured in live config. An item from within
    that rarity class is then chosen uniformly at random.

    """

    item_name = choose_random_item()

    g.log.debug("dropping item %r for %r", item_name, c.user.name)
    g.stats.event_count("f2p.drop", item_name)
    item = items.get_item(item_name)
    item.on_drop(c.user)
    c.js_preload.set("#drop", [item_name])
コード例 #7
0
ファイル: f2p.py プロジェクト: JordanMilne/reddit-plugin-f2p
def gild_comment_effect(comment, gilder):
    """Add an effect to the gilded comment author."""
    author = Account._byID(comment.author_id, data=True)
    hat = choose_random_item(lambda i: i.endswith("_hat"))
    item = items.get_item(hat)
    item.on_use(c.user, author)
コード例 #8
0
def gild_comment_effect(comment, gilder):
    """Add an effect to the gilded comment author."""
    author = Account._byID(comment.author_id, data=True)
    hat = choose_random_item(lambda i: i.endswith("_hat"))
    item = items.get_item(hat)
    item.on_use(c.user, author)