import { BoardSelectors } from "@shoki/board" ; import { PlayerStatus } from "@creature-chess/models" ; import { PlayerState } from ".." ; export const getPlayerBoard = ( state ) => state . board ; export const isPlayerBoardLocked = ( state ) => state . board . locked ; export const getPlayerBench = ( state ) => state . bench ; export const getPlayerMoney = ( state ) : number => state . playerInfo . money ; export const getPlayerHealth = ( state ) : number => state . playerInfo . health ; export const getPlayerLevel = ( state ) : number => state . playerInfo . level ; export const getPlayerXp = ( state ) : number => state . playerInfo . xp ; export const getPlayerBattle = ( state ) => state . playerInfo . battle ; export const getPlayerStatus = ( state ) => state . playerInfo . status ; export const isNotQuit = ( state ) => state . playerInfo . status !== PlayerStatus . QUIT ; export const getPlayerStreak = ( state ) => state . playerInfo . streak ; export const isPlayerReady = ( state ) => state . playerInfo . ready ; export const getOpponentId = ( state ) => state . playerInfo . opponentId ; export const isPlayerAlive = ( state ) : boolean => state . playerInfo . health > 0 ; export const getPlayerCards = ( state ) => state . cardShop . cards ; export const isPlayerShopLocked = ( state ) : boolean => state . cardShop . locked ; export const getAllPieceCount = ( state ) => [ ... BoardSelectors . getAllPieces ( state . board ) , ... BoardSelectors . getAllPieces ( state . bench ) ] . length ; export const getPlayerBelowPieceLimit = ( state , playerId ) : boolean => { const ownedBoardPieceCount = BoardSelectors . getAllPieces ( state . board ) . filter ( p => p . ownerId === playerId ) . length ; const level = getPlayerLevel ( state ) ; return ownedBoardPieceCount < level ; } ; export const getMostExpensiveBenchPiece = ( state ) => { const benchPieces = Object . values ( state . bench . pieces ) ; if ( ! benchPieces . length ) { return null ; } benchPieces . sort ( ( a , b ) => b . definition . cost - a . definition . cost ) ; return benchPieces [ 0 ] ; } ;