MCPcopy Create free account
hub / github.com/geekcomputers/Python / play

Function play

BoardGame-CLI/snakeLadder.py:40–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39# play method
40def play():
41 global players
42 global isReady
43 global imp
44
45 while imp:
46 print("/" * 20)
47 print("1 -> roll the dice (or enter)")
48 print("2 -> start new game")
49 print("3 -> exit the game")
50 print("/" * 20)
51
52 for i in players:
53 n = input("{}'s turn: ".format(i)) or 1
54 n = int(n)
55
56 if players[i] < 100:
57 if n == 1:
58 temp1 = roll()
59 print(f"you got {temp1}")
60 print("")
61
62 if isReady[i] == False and temp1 == 6:
63 isReady[i] = True
64
65 if isReady[i]:
66 looproll = temp1
67 counter_6 = 0
68 while looproll == 6:
69 counter_6 += 1
70 looproll = roll()
71 temp1 += looproll
72 print(f"you got {looproll} ")
73 if counter_6 == 3:
74 temp1 -= 18
75 print("Three consectutives 6 got cancelled")
76 print("")
77 # print(temp1)
78 if (players[i] + temp1) > 100:
79 pass
80 elif (players[i] + temp1) < 100:
81 players[i] += temp1
82 players[i] = move(players[i], i)
83 elif (players[i] + temp1) == 100:
84 print(f"congrats {i} you won !!!")
85 imp = False
86 return
87
88 print(f"you are at position {players[i]}")
89
90 elif n == 2:
91 players = {} # stores player and their locations
92 isReady = {}
93 current_loc = 1 # reset starting location to 1
94 player_input()
95
96 elif n == 3:
97 print("Bye Bye")

Callers 1

player_inputFunction · 0.70

Calls 3

moveFunction · 0.85
player_inputFunction · 0.85
rollFunction · 0.70

Tested by

no test coverage detected