#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 17 02:57:50 2020

@author: AktorEvan
@github: https://github.com/aktortifan
@instagram: @aktortifan47

desc: Let's play rock, paper, and scissor during quarantine!
"""

import random 
import os

lst = ["Rock", "Paper", "Scissor"]

#Firstly, I am creating the function rand_comp() to random my range in the list
#random.randint() will return the random value between 0 ~ 2

def rand_comp():
    y = random.randint(0, 2) 
    return y

x = lst[rand_comp()]

#The function exit() is to confirm whether a player still wants to carry on his game.

def exit():
    confirm = input("Do you want to play again? (Y/N)")
    if confirm == "Y":
        os.system('clear')
        start()
        
    elif confirm == "N":
        print("Thank you for playing with Python \nAnd don't forget to check https://github.com/aktortifan")
    else:
        print("Please only choose Y or N!")
        exit()

#This is the main script of the game

def start():
    print("1. Rock\n2. Paper\n3. Scissor")
    ans = input("Please input your choice: ")

#I am using the nested if to choose the option based on the user's decision
    
############################################################################## 
    if ans == str(1):        
        print("You chose Rock")
        
#x is the random value generated by CPU itself
#If the random value matched with the real value from the list, then it would show different result.
    
        if lst[0] == x:
        
            print("The CPU chose Rock \nIt's Draw!")
    
        elif lst[1] == x:
       
            print("The CPU chose Paper \nYou Lose!" )

        elif lst[2] == x:
       
            print("The CPU chose Scissor \nYou Win!")
            
        exit()
            
                        
##############################################################################            
    elif ans == str(2):       
        print("You chose Paper")
    
        if lst[0] == x:        
            print("The CPU chose Rock \nYou Win!")
    
        elif lst[1] == x:
            print("The CPU chose Paper \nIt's Draw!" )

        elif lst[2] == x:       
            print("The CPU chose Scissor \nYou Lose!")
            
        exit()
                    
############################################################################## 
    elif ans == str(3):       
        print("You chose Scissor")
    
        if lst[0] == x:
            print("The CPU chose Rock \nYou Lose!")
    
        elif lst[1] == x:
            print("The CPU chose Paper \nYou Win!" )

        elif lst[2] == x:
           print("The CPU chose Scissor \nIt's Draw!")
           
        exit()
       
#############################################################################        
#If the users have other keys to return (except 1, 2, or 3), it will be directed to start() until they return the key 1, 2, or 3.    
    else:
        os.system('clear')
        
        print("please only choose 1, 2, or 3!")
        
        start()

#############################################################################
start()

    
    




    
    
    
    

