def get_block(self, block_pos: Position) -> Block: if block_pos.get_row() < 0 or block_pos.get_column() < 0: raise MoveError('use positive notch numbers please') try: return self.__blocks[block_pos.get_row()][block_pos.get_column()] except IndexError: raise MoveError('block does not exist')
def play(self, marble: Marble, pos: Position): new_notches = deepcopy(self.__notches) if pos.get_row() < 0 or pos.get_column() < 0: raise MoveError('use positive notch numbers please') try: new_notches[pos.get_row()][pos.get_column()] = new_notches[pos.get_row()][pos.get_column()].play(marble) except IndexError: raise MoveError('notch does not exist') return Block(new_notches)
def __update_block(self, block_pos: Position, new_block: Block) -> 'Board': new_blocks = deepcopy(self.__blocks) new_blocks[block_pos.get_row()][block_pos.get_column()] = new_block return Board(new_blocks)
def get_notch(self, pos: Position): return self.get_row(pos.get_row())[pos.get_column()]