This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/coin.py
Fletcher Boyd 7ab4f756fe .format
2013-09-05 09:46:49 +08:00

25 lines
697 B
Python
Executable file

from util import hook
import random
@hook.command(autohelp=False)
def coin(inp, me=None):
"""coin [amount] -- Flips [amount] of coins."""
if inp:
try:
amount = int(inp)
except (ValueError, TypeError):
return "Invalid input!"
else:
amount = 1
if amount == 1:
me("flips a coin and gets {}.".format(random.choice(["heads", "tails"])))
elif amount == 0:
me("makes a coin flipping motion with its hands.")
else:
heads = int(random.normalvariate(.5 * amount, (.75 * amount) ** .5))
tails = amount - heads
me("flips {} coins and gets {} heads and {} tails.".format(amount, heads, tails))