repl.it
@ash15khng/

EnragedVitalEmulators challenge

Python

default name challenge

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# how am i supposed to make a emulator in python with my limited knowledge
# also how is an emulator vital
# and enraged
# i guess im making a rock paper scissors "emulator" 
# i think this is cheating but ok
import random
randomoption = 0
playeroption = 0
playerscore = 0
comscore = 0 
roundnum = 0
def setnumber(option):
  global playeroption
  if option == "s":
    playeroption = 1
  if option == "p":
    playeroption = 2
  if option == "r":
    playeroption = 3
def setname(roption, poption):
  global playeroption, randomoption
  if roption == 1:
    randomoption = "scissors"
  if roption == 2:
    randomoption = "paper"
  if roption == 3:
    randomoption = "rock"
  if poption == 1:
    playeroption = "scissors"
  if poption == 2:
    playeroption = "paper"
  if poption == 3:
    playeroption = "rock"
def checkvalid(): 
  if playeroption!="s" and playeroption!="r" and playeroption!="p":
    print("Invalid option "+playeroption)
    exit()
def oneround():
  global playerscore, comscore, roundnum
  setnumber(playeroption)
  if playeroption < randomoption or playeroption == 3 and randomoption == 1:
    setname(randomoption, playeroption)
    print(" Your %s beats computer's %s, you win!" % (playeroption, randomoption))
    playerscore += 1
    roundnum += 1
    print("The score is "+str(playerscore)+"-"+str(comscore))
  elif playeroption == randomoption:
    setname(randomoption, playeroption)
    print("Your %s and computer's %s result in a tie!" % (playeroption, randomoption))
    print("The score is "+str(playerscore)+"-"+str(comscore))
  else:
    setname(randomoption, playeroption)
    print("Computer's %s beats your %s, you lose :(" %(randomoption, playeroption))
    comscore += 1
    roundnum += 1
    print("The score is "+str(playerscore)+"-"+str(comscore))
while roundnum < 5:    
  randomoption = random.randint(1,3)
  playeroption = input("What is your option? r/p/s ")
  checkvalid()
  oneround()
if playerscore == 3:
  print("You win!")
elif comscore == 3:
  print("You lose...")

# this code is old and badddd