public bool Execute(ControlBlocks controlBlocks)
    {
        if (CollisionDetection.IsCollisionPutPosition(controlBlocks))
        {
            var adjustedControlBlocks = Adjuster.AdjustBlocksByPutBlocks(controlBlocks);
            var addBlocks             = Board.PutBlocks(adjustedControlBlocks);
            BoardPresenter.AddBlocks(addBlocks);
            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    public ControlBlocks Execute(IMoveControlBlocksService moveService, int playerId, ControlBlocks controlBlocks)
    {
        var movedControlBlocks = moveService.Execute(controlBlocks);

        if (PutControlBlocksService.Execute(movedControlBlocks))
        {
            EraseLineService.Execute();
            if (Board.IsGameOver())
            {
                GameOverEvent.EmitGameOver();
            }
            else
            {
                var newControlBlocks = GetNextControlBlocksService.Execute(playerId);
                return(newControlBlocks);
            }
        }
        var adjustedControlBlocks = Adjuster.AdjustBlocksByPutBlocks(movedControlBlocks);

        ControlBlocksPresenter.ChangeControlBlocks(adjustedControlBlocks);
        return(adjustedControlBlocks);
    }