NAME

Bot::Backbone::Service::OFun::Dice - Tools for rolling dice, flipping coins, choosing, and shuffling

VERSION

version 0.142230

SYNOPSIS

    # in your bot config
    service dice => (
        service => 'OFun::Dice',
    );

    dispatcher chatroom => as {
        redispatch_to 'dice';
    };

    # in chat
    alice> !roll
    bot> Rolled 4
    alice> !roll 2d4+3
    bot> Rolled 7
    alice> !flip
    bot> Flipped 1 times: heads
    alice> !flip 4
    bot> Flipped 4 times: tails, tails, tails, heads
    alice> !choose 2 alice bob chuck dick ed
    bot> I choose ed, chuck
    alice> !choose alice bob chuck dick ed
    bot> I choose dick
    alice> !shuffle alice bob chuck dick ed
    bot> I choose bob, alice, ed, dick, chuck

DESCRIPTION

This service provides a number of tools related to randomly generating numbers, coin flips, choosing items, etc.

DISPATCHER

!roll

    !roll
    !roll 2d6
    !roll 4d20+12

Generates a dice roll. If no arguments are given, it's the same as rolling a single 6-sided die. If you specify dice notation, it will roll the dice specified.

!flip

    !flip
    !flip 5

Flips a coin or several. If no arguments are given, it will flip a single coin and report the outcome. If a number is given, it will flip that many coins.

!choose

    !choose 3 a b c d e
    !choose a b c d e

Choose 1 or more items from a list. If the first argument is a number, it will choose that many items from the list. If the first argument is not a number, it will choose a single item.

!shuffle

    !shuffle a b c d e

This is identical to:

    !choose 5 a b c d e

It choose all items, but shuffles them in the process.

METHODS

roll_dice

Implements the !roll and !flip commands.

flip_coin

Implements the !flip command by passing "d2" as the dice notation to "roll_dice".

choose_n

Implements the !choose and !shuffle commands.

choose_all

Implements the !shuffle command by counting the number of arguments and asking "choose_n" to pick that many items.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Qubling Software LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.