private bool IsValidDrop(ref DropPrepStepState token, List <PieceEV> piecesAtLocation, PieceSide side, IEntitiesDB entitiesDB)
 {
     return((IsEmptyTile(piecesAtLocation) || IsValidEarthLinkDrop(piecesAtLocation, side) || IsValidEarthLinkDrop(piecesAtLocation, null)) &&
            DoesNotViolateDoubleFileDrop(ref token, side, entitiesDB) &&
            DoesNotViolateTerritoryDrop(ref token, side, entitiesDB) &&
            DoesNotViolateForcedRearrangementFrontDrop(ref token, side, entitiesDB));
 }
        private bool DoesNotViolateTerritoryDrop(ref DropPrepStepState token, PieceSide side, IEntitiesDB entitiesDB)
        {
            TurnEV turnPlayer = turnService.GetCurrentTurnEV(entitiesDB);

            return(!HasDropAbility(ref token.HandPiece, side, DropAbility.TERRITORY_DROP) ||
                   turnService.IsRankWithinTerritory(turnPlayer, token.DestinationTile.Location.Location.y));
        }
        private void NextActionDropPiece(HandPieceEV handPiece, TileEV destinationTile)
        {
            var dropInfo = new DropPrepStepState
            {
                HandPiece       = handPiece,
                DestinationTile = destinationTile
            };

            boardPressSequence.Next(this, ref dropInfo, (int)BoardPress.DROP);
        }
        private bool NoOtherSameTypesInFile(ref DropPrepStepState token, PieceSide side, IEntitiesDB entitiesDB)
        {
            PlayerColor playerColor = token.HandPiece.PlayerOwner.PlayerColor;

            return(pieceFindService.FindPiecesByTypeAndFile(
                       GetPieceType(ref token.HandPiece, side),
                       token.DestinationTile.Location.Location.x,
                       entitiesDB
                       ).Where(piece => piece.PlayerOwner.PlayerColor == playerColor).ToList()
                   .Count == 0);
        }
 private bool DoesNotViolateDoubleFileDrop(ref DropPrepStepState token, PieceSide side, IEntitiesDB entitiesDB)
 {
     return(!HasDropAbility(ref token.HandPiece, side, DropAbility.DOUBLE_FILE_DROP) ||
            NoOtherSameTypesInFile(ref token, side, entitiesDB));
 }
        private bool DoesNotViolateForcedRearrangementFrontDrop(ref DropPrepStepState token, PieceSide side, IEntitiesDB entitiesDB)
        {
            TurnEV currentTurn = turnService.GetCurrentTurnEV(entitiesDB);

            return(currentTurn.ForcedRearrangementStatus.ForcedRearrangmentActive && side == PieceSide.BACK ? false : true);
        }
 public bool IsValidBackDrop(ref DropPrepStepState token, List <PieceEV> piecesAtLocation, IEntitiesDB entitiesDB)
 {
     return(IsValidDrop(ref token, piecesAtLocation, PieceSide.BACK, entitiesDB));
 }