22from kivy .uix .screenmanager import Screen
33
44from Data_Conversion .position_of_mouse import find_position
5- from Data_Conversion .position_of_pieces import teams_turn
65from Data_Conversion .position_of_pieces import position_dic
7-
86from Data_Conversion .chess_coords_to_real_coords import convert_coordinates
7+
98from valid_move import is_valid_move
109
1110class Scatter_Text_widget (Screen ):
1211
12+
1313 def __init__ (self , ** kwargs ):
1414 #Initializes the class with variables
1515 super (Scatter_Text_widget , self ).__init__ (** kwargs )
1616
17+ self .position = find_position ()
18+ self .position_piece = position_dic
1719 def on_touch_down (self , touch ):
1820 #This function gets called when the mouse is pressed
1921
2022 res = super (Scatter_Text_widget , self ).on_touch_down (touch )
2123 #This makes sure the labels keep their Scatter Property and the mouse input can be obtained
2224
2325 if res :
24- position_piece = position_dic
25- position = find_position ()
2626
2727 #Gets the chess coord of where the mouse pressed
28- pos_chess = position .chess_position (touch .pos )
28+ pos_chess = self . position .chess_position (touch .pos )
2929
3030 #Saves the input to a text file
3131 #Probably a bad way to do this, especially for security concerns
32- clicked_input = [pos_chess ,position_piece [str (pos_chess )]]
32+ clicked_input = [pos_chess ,self . position_piece [str (pos_chess )]]
3333
3434 #Writes twrites the input into the file
3535 with open ('Data_Conversion\saved_input.txt' , 'w' ) as f :
@@ -41,12 +41,10 @@ def on_touch_up(self, touch):
4141 res = super (Scatter_Text_widget , self ).on_touch_up (touch )
4242 #Makes sure Scatter properties and touch input work alligned
4343 if res :
44- position = find_position ()
45- position_piece = position_dic
4644 conversion = convert_coordinates
4745
4846 #Gets the position of the mouse, and translates it into a chess corrd
49- pos_chess = position .chess_position (touch .pos )
47+ pos_chess = self . position .chess_position (touch .pos )
5048
5149 #opens the text file, to get the previous data
5250 with open ('Data_Conversion\saved_input.txt' , 'r' ) as f :
@@ -67,7 +65,7 @@ def on_touch_up(self, touch):
6765 Checks with another python file to see if the move was valid or not, against all rules of Chess
6866 '''
6967 st = is_valid_move ()
70- valid_or_not = st .main (chess_position_numerical , position_piece , pos_chess , piece_that_moved )
68+ valid_or_not = st .main (chess_position_numerical , self . position_piece , pos_chess , piece_that_moved )
7169
7270 #IF THE MOVE WAS VALID
7371 if valid_or_not == "True" :
@@ -80,7 +78,7 @@ def on_touch_up(self, touch):
8078
8179 elif valid_or_not == "True, Captured" :
8280 #If the move was valid, and a capture occured
83- piece_occupied = str (position_piece [pos_chess ])
81+ piece_occupied = str (self . position_piece [pos_chess ])
8482
8583 #Deletes the piece that was captured
8684 self .ids [piece_occupied ].pos = (1000 ,1000 )
0 commit comments