package rubys.ninja.experiments.zahlenpuzzle.view;

import rubys.ninja.experiments.zahlenpuzzle.board.HardcodedInitializer;
import rubys.ninja.experiments.zahlenpuzzle.game.Game;
import rubys.ninja.experiments.zahlenpuzzle.game.InputRequester;
import rubys.ninja.experiments.zahlenpuzzle.game.OneEmptyAndSortedNumericRuleEnforcer;
import rubys.ninja.experiments.zahlenpuzzle.game.SinglePlayerGame;

/**
 * Created by jn_fe on 30.01.2017.
 */
public class DirectionController {
    Game game;



    public DirectionController(InputRequester inputRequester) {
        game = new SinglePlayerGame(new HardcodedInitializer, inputRequester, new OneEmptyAndSortedNumericRuleEnforcer());
    }

    public InputRequester.SwapRequest ConvertDirectionToSwapRequest(DirectionRequester.Direction direction) {
        
    }

}

@@ -95,36 +95,21 @@
 e.board.
-H
+Bo
 ard
-codedInitializer
 ;%0Aimport
@@ -150,16 +150,22 @@
 zle.
-game.Gam
+board.BoardSiz
 e;%0Ai
@@ -211,25 +211,32 @@
 zle.
-game.InputRequest
+board.HardcodedInitializ
 er;%0A
@@ -288,156 +288,130 @@
 ame.
-OneEmptyAndSortedNumericRuleEnforcer;%0Aimport rubys.ninja.experiments.zahlenpuzzle.game.SinglePlayerGame;%0A%0A/**%0A * Created by jn_fe on 30.01.2017.%0A */
+*;%0Aimport rubys.ninja.experiments.zahlenpuzzle.token.EmptyToken;%0Aimport rubys.ninja.experiments.zahlenpuzzle.token.Token;%0A
 %0Apub
@@ -446,16 +446,24 @@
 r %7B%0A    
+private 
 Game gam
@@ -466,18 +466,16 @@
  game;%0A%0A
-%0A%0A
     publ
@@ -497,21 +497,25 @@
 troller(
-Input
+Direction
 Requeste
@@ -521,25 +521,16 @@
 er input
-Requester
 ) %7B%0A    
@@ -589,24 +589,69 @@
 izer
-, inputRequester
+(), () -%3E convertDirectionToSwapRequest(input.getDirection())
 , ne
@@ -738,17 +738,17 @@
 Request 
-C
+c
 onvertDi
@@ -818,16 +818,1590 @@
         
+BoardSize emptyPos = null;%0A        Board board = game.getBoard();%0A        BoardSize boardSize = board.getSize();%0A%0A        outerLoop:%0A        for (int i = 0; i %3C boardSize.getHeight(); i++) %7B%0A            for (int j = 0; j %3C boardSize.getWidth(); j++) %7B%0A                BoardSize pos = new BoardSize(j, i);%0A                Token token = board.getTokenAt(pos);%0A                if (token instanceof EmptyToken)%7B%0A                    emptyPos = pos;%0A                    break outerLoop;%0A                %7D%0A            %7D%0A        %7D%0A%0A        if (emptyPos == null)%7B%0A            throw new RuntimeException(%22No empty token found%22);%0A        %7D%0A%0A        BoardSize otherPos = null;%0A        switch (direction) %7B%0A            case up:%0A                otherPos = new BoardSize(emptyPos.getWidth(), emptyPos.getHeight() - 1);%0A                break;%0A            case right:%0A                otherPos = new BoardSize(emptyPos.getWidth() + 1, emptyPos.getHeight());%0A                break;%0A            case down:%0A                otherPos = new BoardSize(emptyPos.getWidth(), emptyPos.getHeight() + 1);%0A                break;%0A            case left:%0A                otherPos = new BoardSize(emptyPos.getWidth() - 1, emptyPos.getHeight());%0A                break;%0A        %7D%0A%0A        InputRequester.SwapRequest swapRequest = new InputRequester.SwapRequest();%0A        swapRequest.pos1 = emptyPos;%0A        swapRequest.pos2 = otherPos;%0A        return swapRequest;%0A    %7D%0A%0A    public Game.UpdateResult update() %7B%0A        return game.update();%0A    %7D%0A%0A    public Board getBoard() %7B%0A        return game.getBoard();
 %0A    %7D%0A%0A

Implement Controller