-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtt_m.py
115 lines (102 loc) · 2.83 KB
/
tt_m.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
import curses
import curses.textpad
import time
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
from random import randint
z = 0
mylist = [' '] * 10
def test():
global z
if z == 0:
z += 1
return "X"
else:
z -= 1
return "O"
def rewrite(i):
global mylist
global write
global c
if mylist[i] == " ":
write = True
mylist[i] = c
else:
write = False
c = test() #lehet hiba van
def getPlayerMove(c):
if c == ord('7'):
i = 7
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6),int(dims[1]/6), test())
elif c == ord('8'):
i = 8
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6),int(dims[1]/2),test())
elif c == ord('9'):
i = 9
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6),int(dims[1]/6*5),test())
elif c == ord('4'):
i = 4
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6*3),int(dims[1]/6),test())
elif c == ord('5'):
i = 5
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6*3),int(dims[1]/2),test())
elif c == ord('6'):
i = 6
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6*3),int(dims[1]/6*5),test())
elif c == ord('1'):
i = 1
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6*5),int(dims[1]/6),test())
elif c == ord('2'):
i = 2
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6*5),int(dims[1]/2),test())
elif c == ord('3'):
i = 3
rewrite(i)
if write == True:
screen.addstr(int(dims[0]/6*5),int(dims[1]/6*5),test())
return()
screen = curses.initscr()
#bo = curses.initscr()
dims = screen.getmaxyx()
screen = curses.newwin(int(dims[0]), int(dims[1]),0 ,0)
screen.box()
for i in range (0, int(dims[0])):
screen.addstr(i, int(dims[1]/3), '|')
screen.addstr(i, int(dims[1]/3*2), '|')
for i in range (0, int(dims[1])):
screen.addstr(int(dims[0]/3), i, '_')
screen.addstr(int(dims[0]/3*2), i, '_')
#screen.addstr(i, int(dims[1]), '|')
#screen = curses.newwin(int(dims[0]/3),int(dims[1]/3),int(dims[0]-dims[0]/3) ,int(dims[1]-dims[1]/3))
curses.noecho()
curses.cbreak()
screen.keypad(True)
curses.curs_set(0)
# print ("Use the number keys to place the symbols or press 'q' to quit.")
while True:
c = screen.getch()
if c != ord('q'):
getPlayerMove(c)
else:
break # Exit the while loop:
# mvaddstr() moves to a given y,x coordinate first before displaying the string.
#form: y, x, str or ch Move to position y,x within the window, and display str or ch
curses.nocbreak()
screen.keypad(False)
curses.echo()
curses.endwin()