import random

class Game:

def __init__ ( self , human ) :

# These are the possible hands and their corresponding numbers

self . hand = {

1 : "Rock" , 2 : "Paper" , 3 : "Scissors" ,

4 : "Lizard" , 5 : "Spock" , 6 : "Spider-Man" ,

7 : "Batman" , 8 : "Wizard" , 9 : "Gun"

}

# Here we write the "Hand" and "What it beats + the wining message"

self . message = {

"Rock" : { "Scissors" : "Rock crushes Scissors" ,

"Lizard" : "Rock crushes Lizard." ,

"Spider-Man" : "Rock knocks out Spider-Man." ,

"Wizard" : "Rock interrupts Wizard." } ,

"Paper" : { "Rock" : "Paper covers Rock." ,

"Spock" : "Paper disproves Spock." ,

"Batman" : "Paper delays Batman." ,

"Gun" : "Paper jams Gun." } ,

"Scissors" : { "Paper" : "Scissors cut Paper." ,

"Lizard" : "Scissors decapitates Lizard." ,

"Spider-Man" : "Scissors cut Spider-Man." ,

"Wizard" : "Scissors cut Wizard." } ,

"Lizard" : { "Paper" : "Lizard eats Paper." ,

"Spock" : "Lizard poisons Spock." ,

"Batman" : "Lizard confuses Batman, because he looks like Killer Croc." ,

"Gun" : "Lizard is too small for the Gun." } ,

"Spock" : { "Rock" : "Spock vaporizes Rock." ,

"Scissors" : "Spock smashes Scissors." ,

"Spider-Man" : "Spock befuddles Spider-Man." ,

"Wizard" : "Spock zaps Wizard." } ,

"Spider-Man" : { "Paper" : "Spider-Man rips paper." , "Lizard" : "Spider-Man defeats Lizard." ,

"Wizard" : "Spider-Man annoys Wizard." , "Gun" : "Spider-Man disarms the Gun." } ,

"Batman" : { "Rock" : "Batman explodes Rock." , "Scissors" : "Batman dismantles Scissors" ,

"Spock" : "Batman hangs Spock." , "Spider-Man" : "Batman scares Spider-Man." } ,

"Wizard" : { "Paper" : "Wizard burns Paper." , "Lizard" : "Wizard transforms Lizard." ,

"Batman" : "Wizard stuns Batman." , "Gun" : "Wizard melts the Gun." } ,

"Gun" : { "Rock" : "Gun breaks Rock." , "Scissors" : "Gun dents Scissors." ,

"Spock" : "Gun shoots Spock." , "Batman" : "Gun kills Batman's mom." }

}

# human selection and computer selection

self . human = human

self . computer = random . randint ( 1 , len ( self . hand ) )

# This function selects a winner, depending of beating hands

# The winner is picked by assuming the human is the default winner

# 'else' the computer wins.

def show_hand ( self , human ) :

print ( "You played {}, the computer played {}!" . format ( self . hand [ human ] , self . hand [ self . computer ] ) )

def beats ( self ) :

if self . human == self . computer :

return "It's a tie!"

elif self . hand [ self . human ] == "Rock" :

if self . hand [ self . computer ] == "Scissors" or \

self . hand [ self . computer ] == "Lizard" or \

self . hand [ self . computer ] == "Spider-Man" or \

self . hand [ self . computer ] == "Wizard" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Paper" :

if self . hand [ self . computer ] == "Rock" or \

self . hand [ self . computer ] == "Spock" or \

self . hand [ self . computer ] == "Batman" or \

self . hand [ self . computer ] == "Gun" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Scissors" :

if self . hand [ self . computer ] == "Paper" or \

self . hand [ self . computer ] == "Lizard" or \

self . hand [ self . computer ] == "Spider-Man" \

or self . hand [ self . computer ] == "Wizard" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Lizard" :

if self . hand [ self . computer ] == "Paper" or \

self . hand [ self . computer ] == "Spock" or \

self . hand [ self . computer ] == "Batman" or \

self . hand [ self . computer ] == "Gun" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Spock" :

if self . hand [ self . computer ] == "Rock" or \

self . hand [ self . computer ] == "Scissors" or \

self . hand [ self . computer ] == "Spider-Man" or \

self . hand [ self . computer ] == "Wizard" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Spider-Man" :

if self . hand [ self . computer ] == "Paper" or \

self . hand [ self . computer ] == "Lizard" or \

self . hand [ self . computer ] == "Wizard" or \

self . hand [ self . computer ] == "Gun" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Batman" :

if self . hand [ self . computer ] == "Rock" or \

self . hand [ self . computer ] == "Scissors" or \

self . hand [ self . computer ] == "Spock" or \

self . hand [ self . computer ] == "Spider-Man" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Wizard" :

if self . hand [ self . computer ] == "Paper" or \

self . hand [ self . computer ] == "Lizard" or \

self . hand [ self . computer ] == "Batman" or \

self . hand [ self . computer ] == "Gun" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

elif self . hand [ self . human ] == "Gun" :

if self . hand [ self . computer ] == "Rock" or \

self . hand [ self . computer ] == "Scissors" or \

self . hand [ self . computer ] == "Spock" or \

self . hand [ self . computer ] == "Batman" :

return self . message [ self . hand [ self . human ] ] [ self . hand [ self . computer ] ] + " You Win!"

else :

return self . message [ self . hand [ self . computer ] ] [ self . hand [ self . human ] ] + " The Computer Wins!"

def intro ( ) :

print ( )

print ( "This is a game of Rock, Paper, Scissors, Lizard, Spock,

Spider-Man, Batman, Wizard, Gun." )

print ( "You will be playing vs the Computer." )

print ( )

def instructions ( ) :

print ( )

print ( "*Instructions*" )

print ( )

print ( 'Enter "1" or "Rock" for Rock' )

print ( 'or' )

print ( 'Enter "2" or "Paper" for Paper' )

print ( 'or' )

print ( 'Enter "3" or "Scissors" for Scissors' )

print ( 'or' )

print ( 'Enter "4" or "Lizard" for Lizard' )

print ( 'or' )

print ( 'Enter "5" or "Spock" for Spock' )

print ( 'or' )

print ( 'Enter "6" or "Spider-Man" for Spider-Man' )

print ( 'or' )

print ( 'Enter "7" or "Batman" for Batman' )

print ( 'or' )

print ( 'Enter "8" or "Wizard" for Wizard' )

print ( 'or' )

print ( 'Enter "9" or "Gun" for Gun' )

print ( )

def main ( ) :

intro ( )

while True :

instructions ( )

while True :

print ( )

player_input = input ( "Please make your selection: " )

print ( )

if player_input == "1" or player_input. lower ( ) == "rock" :

player_input = 1

break

elif player_input == "2" or player_input. lower ( ) == "paper" :

player_input = 2

break

elif player_input == "3" or player_input. lower ( ) == "scissors" :

player_input = 3

break

elif player_input == "4" or player_input. lower ( ) == "lizard" :

player_input = 4

break

elif player_input == "5" or player_input. lower ( ) == "spock" :

player_input = 5

break

elif player_input == "6" or player_input. lower ( ) == "spider-man" or player_input. lower ( ) == \

"spiderman" :

player_input = 6

break

elif player_input == "7" or player_input. lower ( ) == "batman" :

player_input = 7

break

elif player_input == "8" or player_input. lower ( ) == "wizard" :

player_input = 8

break

elif player_input == "9" or player_input. lower ( ) == "gun" :

player_input = 9

break

else :

print ( "There seems to be an error on your selection." ) ,

print ( "Please read the instructions well and try again." )

print ( )

instructions ( )

game = Game ( player_input )

print ( )

game. show_hand ( player_input )

print ( )

if game. beats ( ) == "It's a tie!" :

print ( )

print ( game. beats ( ) )

print ( )

print ( "Give it one more try!" )

print ( )

else :

print ( game. beats ( ) )

print ( )

select = input ( "Do you want to play again (Y/N)?: " )

if select . lower ( ) == "n" or select . lower ( ) == "no" :

break