tools module¶
-
class
tools.Color[source]¶ Bases:
objectStatic Enum class used form marking colors of pieces
In main program values are stored as int. This class is used only as static enum class to make code cleaner and to avoid magic numbers.
-
black= 0¶
-
static
opposite(color)[source]¶ - Returns opposite color.
param int color: value representing color return: opposite color rtype: int
-
static
to_str(color)[source]¶ Changes color to readable string
Parameters: color (int) – value representing color Returns: name of color Return type: str
-
white= 1¶
-
-
class
tools.ListOfPieces(black_pieces: list, white_pieces: list)[source]¶ Bases:
objectNew class intended to replace old way of storing info about pieces Old way of storing was a tuple two_pieces - (black_pieces, white_pieces) where:
black_pieces - list of cords of black pieces white_pieces - list of cords of white pieces
-
class
tools.Move(cords: tuple, dest: tuple, destroyed: list)[source]¶ Bases:
objectNew class intended to replace old way of storing ‘move’ data Old way of storing ‘move’ was a tuple - (cords, dest, destroyed) where:
cords - cords of moving piece dest - destination cords destroyed - list of cords of destroyed pieces
-
tools.cords_list_to_str(list_of_white_pieces: list, list_of_black_pieces: list)[source]¶ Creates nice looking string to visalize list of cords on the board, usefull for debugging and tests
Parameters: Returns: str_board
Return type:
-
tools.str_to_cords(str_board: str)[source]¶ Creates list od cords out of string visual representation. Does opposite of
cords_list_to_str()Parameters: str_board (str) – string with visual representation of board :return two lists of pieces :rtype: tuple