Improved plugins/coin.py with TheNoodle
This commit is contained in:
parent
cd9e35ed33
commit
185c1d5ae3
1 changed files with 15 additions and 37 deletions
|
@ -2,38 +2,18 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
import random
|
import random
|
||||||
|
|
||||||
## NOTES:
|
# used for tals: x heads: y
|
||||||
## Need to make a function to return a number of flips
|
|
||||||
|
|
||||||
# this produces a string full of comma seperated coin flips - should output this as a list
|
|
||||||
def flip_list(count):
|
|
||||||
out = ""
|
|
||||||
for i in range(count):
|
|
||||||
flip = random.randint(0,1)
|
|
||||||
if flip == 1:
|
|
||||||
if i == 0:
|
|
||||||
out += "Heads"
|
|
||||||
else:
|
|
||||||
out += ", Heads"
|
|
||||||
else:
|
|
||||||
if i == 0:
|
|
||||||
out += "Tails"
|
|
||||||
else:
|
|
||||||
out += ", Tails"
|
|
||||||
return out
|
|
||||||
|
|
||||||
# this doesn't work (yet)
|
|
||||||
def flip_simple(count):
|
def flip_simple(count):
|
||||||
out = ""
|
|
||||||
heads = 0
|
heads = 0
|
||||||
tails = 0
|
tails = 0
|
||||||
for i in range(count):
|
for x in range(count):
|
||||||
flip = random.randint(0,1)
|
c = random.randint(0,1)
|
||||||
if flip == 1:
|
if c == 0:
|
||||||
heads = heads + 1
|
heads += 1
|
||||||
else:
|
else:
|
||||||
tails = tails + 1
|
tails += 1
|
||||||
return msg
|
return [heads,tails]
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def coin(inp):
|
def coin(inp):
|
||||||
|
@ -47,17 +27,15 @@ def coin(inp):
|
||||||
return "Invalid Input :("
|
return "Invalid Input :("
|
||||||
else:
|
else:
|
||||||
count = 1
|
count = 1
|
||||||
|
# depending on the count, we use two different methods to get the output
|
||||||
# depending on the count, we use three different methods to get the output
|
if count == 1:
|
||||||
if count <= 10 and count > 1:
|
|
||||||
msg = "You flip " + str(count) + " coins and get the following results: " + flip_list(count)
|
|
||||||
return msg
|
|
||||||
elif count == 1:
|
|
||||||
flip = random.randint(0,1)
|
flip = random.randint(0,1)
|
||||||
if flip == 1:
|
if flip == 1:
|
||||||
return "You flip a coin and get heads."
|
sidename = "heads"
|
||||||
else:
|
else:
|
||||||
return "You flip a coin and get tails."
|
sidename = "tails"
|
||||||
|
return "You flip a coin and get "+sidename+"."
|
||||||
else:
|
else:
|
||||||
return "Amounts over ten are not yet implemented"
|
flips = flip_simple(count)
|
||||||
|
return "You flip "+str(count)+" coins and get " +str(flips[0])+" heads and "+str(flips[1])+" tails."
|
||||||
|
|
||||||
|
|
Reference in a new issue