repl.it
@RyanCrouch/

MY PROJECT THAT WONT WORK

Python

No description

fork
loading
Files
  • main.py
  • passwords.txt
  • scores.txt
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import random
from random import randrange

def rules():
  print("rules")
  print("each roll is added to your total score.")
  print("if the total is a even number then you will recive 10 additional points")
  print("if the totals a odd number you will recive an additional 5 points ")
  print("if you roll a double number then you get and extra roll ")
  print("the person with the biggest score after 5 round wins")
  print("if the 2 players have the same score after 5 rounds then it goes into a break point ")
  print("\n")
  print("player 1s username is player 1")
  print("player 2s username is player 2")

def filescore(score):
  file = open("scores.txt","a")
  file.write(score)
  file.close()
  
def diceroll():
  s1 = (random.randrange(1, 7))
  print("roll 1 was a", s1)
  s2 = (random.randrange(1, 7))
  print("roll 2 was a", s2)
  total = s1 + s2
  if s1 == s2:
    extraroll = (random.randrange(1, 7))
    print("your extra roll was" , extraroll)
    total = total + extraroll
  if (total % 2 == 0):
    print("player 1 got an even number +10 points")
    total += 10
  else:
    print("player 1 got an odd number -5 points")
    total -= 5  
  return total 

def login():
  print("welcome to the game")
  login = int(input("press 1 if you have an accound and press 0 if you require a account >"))
  if login == 1:
    input("enter your username >")
    input("enter your password>")
  else:
    input("enter any username you desire >")
    input("enter a password >")

















#game#
def game():
  rules()
  print("\n")
  login()
  p1score = 0
  p2score = 0
  for rounds in range (1 , 6):
    print("round start")
    print("\n")
    input("player 1 ready to roll")
    p1score = p1score + diceroll()
    if p1score < 0:
      p1score = 0
      print("player 1s score was" , p1score)
    print("\n")
    input("player 2 ready to roll")
    p2score = p2score + diceroll()
    print("round start")
    if p2score < 0:
      p2score = 0
      print("player 2s score is" , p2score)
    print("end of round")
    if p1score > p2score:
      print("player 1 wins this round with" , p1score , "points")
    else:
      print("player 2 wins this round with" , p2score , "points")
      filescore(str(p1score)+"\n")
  if p1score > p2score:
    print("player 1 wins the game with" , p1score , "points")
  else:
    print("player 2 wins the game with" , p2score , "points")
    filescore(str(p2score)+"\n")



















game() 
Fetching token
?