×
☰ Sebsnetwork

RockPaperScissors - Python - 13KB

                
                    #Tested Version of python:
#Python  3.7.9
#Python  3.9.13
#Python  3.10.7

#Welcome to this overally complicated / simple code that was made in a couple of hours!

#Fun fact: The most misspelt word in this code was 'sicissors'

#Last Updated : 05/10/2022 - 00:52 am

#---------
#Imports
#---------

import random
import time
import os

#---------
#Drawrings
#---------

def sicissors():
    print("              __________")
    print("             / _________)")
    print("____________/ /")
    print("            |/_________")
    print("   Sicissor  __________)")
    print("             _____)")
    print("_________________)")

def rock():
    print("________________")
    print("              |_)")
    print("    Rock       |_)")
    print("              |_)")
    print("______________|_)")


def paper():
    print("         ___")
    print("        |  |")
    print("________|  |______")
    print("            ______)")
    print("            \______")
    print("  Paper      |_____)")
    print("              \____")
    print("              |____)")
    print("             /__")
    print("________________)")

#---------
#Variables
#---------
signs = ["Rock", "Paper", "Sicissors"]
computer = random.choice(signs)
playing = True
player1 = ''
player2 = ''
player1_o = ''
player2_o = ''
player1_d = ''
player2_d = ''
player1_p = 0
player2_p = 0
goodanswer = 0
#---------
#Clear console
#---------
def clearconsole():

    os.system('cls' if os.name=='nt' else 'clear') 
#---------
#All the def in the world
#---------

def winner(name):
    global playing,player1_p,player2_p
    clearconsole()
    amount_of_times_done = 0
    while amount_of_times_done < 5:
        print(f"{name} has won the game!!")
        time.sleep(0.3)
        amount_of_times_done += 1
    time.sleep(3)
    betteranswer = 0
    while betteranswer == 0:
        print("")
        print("Would you like to:\n1.Play Again?\n2.Quit!")
        option = input("Option: ")
        if option == '1':
            clearconsole()
            player1_p = 0
            player2_p = 0
            print("Let's go\nPlayer points have been reset!")
            betteranswer = 1

        elif option == '2':
            clearconsole()
            print("Fine :(")
            playing = False
            betteranswer = 1
        else:
            print("Error - Please give a valid answer!")
            time.sleep(1)
            clearconsole()

def leaderboard(score1, score2):
    global player1, player2
    score1 = str(score1)
    score2 = str(score2)
    print("=======")
    print("Scores:")
    print(f"{player1}: {score1}")
    print(f"{player2}: {score2}")
    print("=======")


#---------
#Acutal code
#---------

while goodanswer == 0:
    clearconsole()
    print("==================================")
    print("Hello to this very wonderful game!")
    print("It took way to long to make but it works*")
    print("Please pick which mode you wish to play in:")
    print("1. Multiplayer (Same pc 2 players)")
    print("2. Against the computer (Good luck)")
    print("3. Quit")
    print("===================================")
    option = input("Option: ")
    print(option)
    if option == '1' or option == '2' or option == '3':
        goodanswer = 1
        option = int(option)
        clearconsole()
    else:
        print("Error - Please give a valid answer!")
        time.sleep(1)

if option == 1:
    print("You have picked Multiplayer\nPlease may players input their names:")
    player1 = input("Player 1:")
    player2 = input("Player 2:")
    clearconsole()
    print("Okay we will be doing best to 3!\n\nFirst person to reach 3 points wins!")
    input("Press Enter to Continue")
    while playing == True:
        if player1_p == 3:
            winner(player1)
        elif player2_p == 3:
            winner(player2)
        else:
            
            clearconsole()
            print(f"{player1} type your answer and {player2} please turn around!")
            player1good = False
            while player1good == False:
                player1_o = input("Pick from:\n- Paper\n- Sicissors\n- Rock\nSpell it exactly like it is above (with captial letters)!!!\nOption: ")
                player1_o = player1_o.upper()
                if player1_o == 'PAPER' or player1_o == 'SICISSORS' or player1_o == 'ROCK':
                    print(player1_o)
                    player1good = True 
                else:
                    print("Error - Please give a valid answer!")
                    time.sleep(1)
                clearconsole()
            player2good = False
            print(f"{player2} turn back around! and {player1} please turn around!")
            while player2good == False:
                player2_o = input("Pick from:\n- Paper\n- Sicissors\n- Rock\nSpell it exactly like it is above (with captial letters)!!!\nOption: ")
                player2_o = player2_o.upper()
                if player2_o == 'PAPER' or player2_o == 'SICISSORS' or player2_o == 'ROCK':
                    player2good = True
                else:
                    print("Error - Please give a valid answer!")
                    time.sleep(1)
                clearconsole()
            input("Press Enter to continue")
            clearconsole()
            if player1_o == player2_o:
                if player1_o == 'PAPER':
                    print(f"{player1} has picked {player1_o}")
                    paper()
                    print(f"{player2} has picked {player2_o}")
                    paper()
                    print("---")
                    print("TIE")
                    print("---")
                elif player1_o == 'ROCK':
                    print(f"{player1} has picked {player1_o}")
                    rock()
                    print(f"{player2} has picked {player2_o}")
                    rock()
                    print("---")
                    print("TIE")
                    print("---")
                else:
                    print(f"{player1} has picked {player1_o}")
                    sicissors()
                    print(f"{player2} has picked {player2_o}")
                    sicissors()
                    print("---")
                    print("TIE")
                    print("---")
            elif player1_o == 'PAPER':
                print(f"{player1} has picked {player1_o}")
                paper()
                if player2_o == "ROCK":
                    print(f"{player2} has picked {player2_o}")
                    rock()
                    player1_p += 1 
                    print(f"{player1} has won paper beats rock")
                    leaderboard(player1_p,player2_p)
                else:
                    print(f"{player2} has picked {player2_o}")
                    sicissors()
                    player2_p += 1
                    print(f"{player2}has won sicissors beats paper")
                    leaderboard(player1_p,player2_p)
            elif player1_o == "ROCK":
                print(f"{player1} has picked {player1_o}")
                rock()
                if player2_o == "SICISSORS":
                    print(f"{player2} has picked {player2_o}")
                    sicissors()
                    player1_p += 1 
                    print(f"{player1} has won rock beats sicissors")
                    leaderboard(player1_p,player2_p)
                else:
                    print(f"{player2} has picked {player2_o}")
                    paper()
                    player2_p += 1
                    print(f"{player2} has won paper beats rock")
                    leaderboard(player1_p,player2_p)
            else:
                print(f"{player1} has picked {player1_o}")
                sicissors()
                if player2_o == "PAPER":
                    print(f"{player2} has picked {player2_o}")
                    paper()
                    player1_p += 1
                    print(f"{player1} has won scicissors beats paper")
                    leaderboard(player1_p,player2_p)
                else:
                    print(f"{player2} has picked {player2_o}")
                    rock()
                    player2_p += 1
                    print(f"{player2} has won rock beats scissors")
                    leaderboard(player1_p,player2_p)
            input("Press enter to continue")


elif option == 2:
    print("You have picked to play against the computer!\nPlease enter your name.")
    player1 = input("Player:")
    player2 = 'Computer'
    clearconsole()
    print("Okay we will be doing best to 3!\n\nFirst person to reach 3 points wins!")
    input("Press Enter to Continue")
    while playing == True:
        if player1_p == 3:
            winner(player1)
        elif player2_p == 3:
            winner(player2)
        else:
            
            clearconsole()
            print(player1 + " type your answer!")
            player1good = False
            while player1good == False:
                player1_o = input("Pick from:\n- Paper\n- Sicissors\n- Rock\nSpell it exactly like it is above (with captial letters)!!!\nOption: ")
                player1_o = player1_o.upper()
                if player1_o == 'PAPER' or player1_o == 'SICISSORS' or player1_o == 'ROCK':
                    print(player1_o)
                    player1good = True 
                else:
                    print("Error - Please give a valid answer!")
                    time.sleep(1)
                clearconsole()
            player2_o = random.choice(signs)
            input("Press Enter to continue")
            clearconsole()
            if player1_o == player2_o:
                if player1_o == 'PAPER':
                    print(f"{player1} has picked {player1_o}")
                    paper()
                    print(f"{player2} has picked {player2_o}")
                    paper()
                    print("---")
                    print("TIE")
                    print("---")
                elif player1_o == 'ROCK':
                    print(f"{player1} has picked {player1_o}")
                    rock()
                    print(f"{player2} has picked {player2_o}")
                    rock()
                    print("---")
                    print("TIE")
                    print("---")
                else:
                    print(f"{player1} has picked {player1_o}")
                    sicissors()
                    print(f"{player2} has picked {player2_o}")
                    sicissors()
                    print("---")
                    print("TIE")
                    print("---")
            elif player1_o == 'PAPER':
                print(f"{player1} has picked {player1_o}")
                paper()
                if player2_o == "ROCK":
                    print(f"{player2} has picked {player2_o}")
                    rock()
                    player1_p += 1 
                    print(f"{player1} has won paper beats rock")
                    leaderboard(player1_p,player2_p)
                else:
                    print(f"{player2} has picked {player2_o}")
                    sicissors()
                    player2_p += 1
                    print(f"{player2} has won sicissors beats paper")
                    leaderboard(player1_p,player2_p)
            elif player1_o == "ROCK":
                print(f"{player1} has picked {player1_o}")
                rock()
                if player2_o == "SICISSORS":
                    print(f"{player2} has picked {player2_o}")
                    sicissors()
                    player1_p += 1 
                    print(f"{player1} has won rock beats sicissors")
                    leaderboard(player1_p,player2_p)
                else:
                    print(f"{player2} has picked {player2_o}")
                    paper()
                    player2_p += 1
                    print(f"{player2} has won paper beats rock")
                    leaderboard(player1_p,player2_p)
            else:
                print(f"{player1} has picked {player1_o}")
                sicissors()
                if player2_o == "PAPER":
                    print(f"{player2} has picked {player2_o}")
                    paper()
                    player1_p += 1 
                    print(f"{player1} has won scicissors beats paper")
                    leaderboard(player1_p,player2_p)
                else:
                    print(f"{player2} has picked {player2_o}")
                    rock()
                    player2_p += 1
                    print(f"{player2} has won rock beats scissors")
                    leaderboard(player1_p,player2_p)
            input("Press enter to continue")

else:
    print("If you were going to quit straight away\nWhy did you lauch the code in the first place?")
    time.sleep(2)
    print("====")
    print("Top 10 questions humanity can't answer!")
    print("====")
    quit()