Last active
August 29, 2015 14:22
-
-
Save yolfer/3e13d3d523fec9452638 to your computer and use it in GitHub Desktop.
This program simulates the special die that comes with the game Uno Stacko, but with one fun improvement! The physical die always matches a particular number to a particular color. This script randomizes it for more diverse gameplay. It also rolls again for you when it rolls a Reverse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import choice, randint | |
| from termcolor import colored # must be pip installed | |
| def do_roll(): | |
| roll = randint(1,6) | |
| if roll < 5: | |
| colors = ['red', 'green', 'blue', 'yellow'] | |
| selected_color = choice(colors) | |
| print colored("{} {}".format(roll, selected_color), selected_color) | |
| elif roll == 5: | |
| print "Draw 2!" | |
| elif roll == 6: | |
| print "Reverse!" | |
| do_roll() | |
| else: | |
| print "Error, please roll again" | |
| do_roll() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment