import { PieceModel } from "@creature-chess/models" ; import { BoardSelectors , BoardState } from "@shoki/board" ; import { PlayerState } from "../entities/player" ; export const getPiece = ( state , pieceId ) : PieceModel | null => BoardSelectors . getPiece ( state . board , pieceId ) || BoardSelectors . getPiece ( state . bench , pieceId ) || null ; type PieceFilter = ( value : PieceModel , index : number , array : PieceModel [ ] ) => boolean ; export const getAllPieces = ( state , filter ? ) : PieceModel [ ] => { const allPieces = [ ... BoardSelectors . getAllPieces ( state . board ) , ... BoardSelectors . getAllPieces ( state . bench ) ] ; return filter ? allPieces . filter ( filter ) : allPieces ; } ; export const getPiecesForDefinition = ( state , definitionId ) => BoardSelectors . getAllPieces ( state ) . filter ( p => p . definitionId === definitionId ) ;