Rock Paper Scissors | Source Code | Mr. UnRivaled |

Rock Paper Scissors | Source Code | Creators_world |


Hello Friends !

Welcome to my blog !

Here is the source code for the program . . .

Thankyou for visiting my blog !



import androidhelper
import random
from os import *
import time

android = androidhelper.Android()

def main():
    title = 'Rock, Paper, Scissors'
    message = ('Choose anyone from the following...')
    android.dialogCreateAlert(title, message)
    android.dialogSetPositiveButtonText('Rock')
    android.dialogSetNegativeButtonText('Paper')
    android.dialogSetNeutralButtonText('Scissors')
    android.dialogShow()
    global response 
    response = android.dialogGetResponse().result
    return response['which'] in ('positive', 'negative', 'neutral')

def main2():
    global a
    a = response['which'] in ('positive')
    global b
    b = response['which'] in ('negative')
    global c
    c = response['which'] in ('neutral')

    if a:
        print("\nRock\n")
    elif b:
        print("\nPaper\n")
    elif c:
        print("\nScissors\n")

def c_choice():
    cr = ("Rock", "Paper", "Scissors")
    global comp_response
    comp_response = random.choice(cr)
    print(comp_response)
    
def function():
    if a:
        if comp_response == "Paper":
            print("\nYou lose!\n")
        elif comp_response == "Scissors":
            print("\nYou Win!\n")
        elif comp_response == "Rock":
            print("\nTie\n")

    elif b:
        if comp_response == "Scissors":
            print("\nYou lose!\n")
        elif comp_response == "Rock":
            print("\nYou Win!\n")
        elif comp_response == "Paper":
            print("\nTie\n")

    elif c:
        if comp_response == "Rock":
            print("\nYou Lose!\n")
        elif comp_response == "Paper":
            print("\nYou Win!\n")
        elif comp_response == "Scissors":
            print("\nTie\n")

    else:
        print("\nNot working...\n")

def conti():
    title = 'Message'
    message = ('Do you want to continue ?')
    android.dialogCreateAlert(title, message)
    android.dialogSetPositiveButtonText('Yes')
    android.dialogSetNegativeButtonText('No')
    android.dialogShow()
    global cont 
    cont = android.dialogGetResponse().result
    

if __name__ == '__main__':
    while True:
        main()
        main2()
        c_choice()
        function()
        time.sleep(3)
        conti()
        if cont['which'] in ('positive'):
            system('clear')

        elif cont['which'] in ('negative'):
            break
    

Comments

Popular posts from this blog

Ping Pong Game On Scratch!!