"""Module contains logic for pieces""" from utils.logger import LOGGER from utils.bases import Piece # pylint: disable=too-few-public-methods logger = LOGGER.get_logger('pieces') logger.debug('Hello from pieces') class Pawn(Piece): """Contains logic for pawn""" def __init__(self, row, col, color): super().__init__(row, col, 0x265f, color, "Pawn") self.has_not_moved = True def get_possible_moves(self): """Get possible moves for pawn""" if self.color == "white": diagonals = [(self.row - 1, self.col + 1), (self.row - 1, self.col - 1)] straight = [(self.row - 1, self.col)] if self.has_not_moved: straight.append((self.row - 2, self.col)) else: diagonals = [(self.row + 1, self.col + 1), (self.row + 1, self.col - 1)] straight = [(self.row + 1, self.col)] if self.has_not_moved: straight.append((self.row + 2, self.col))
"""Module contains chess board logic""" import tkinter as tk import json from utils.logger import LOGGER from utils.bases import Square from utils.pieces import Pawn, Rook, Knight, Bishop, Queen, King # pylint: disable=too-many-instance-attributes # pylint: disable=too-many-public-methods logger = LOGGER.get_logger('board') class Board: """Contains logic to render and resize board""" turn = 0 board_size = 600 @classmethod def inc_turn(cls): """Increments turn""" cls.turn += 1 @classmethod def update_board_size(cls, size): """Updates board size based on size input""" cls.board_size = size
"""Module contains square and piece logic""" import sys from utils.logger import LOGGER logger = LOGGER.get_logger('bases') logger.debug('Hello from bases') class Square: """Contains logic and properties for square""" length = 75 colors = ("#455a64", "#bdbdbd") # dark blue/grey, light grey selectedColor = "#ffff00" # Gold possibleColor = "#00e000" # Green threatColor = "#c62828" # Red @classmethod def update_length(cls, length): """Updates square length based on input""" cls.length = int(length) def __init__(self, row, col): (self.row, self.col) = (row, col) self.color = self.colors[(self.row + self.col) % 2] self.is_selected = False self.is_possible = False self.is_threat = False