package com.example.model.command.util;

import com.example.model.Board;
import com.example.model.Point;

import java.util.ArrayList;
import java.util.IntSummaryStatistics;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by zonoise on 2016/02/16.
 */
public class Reverser {
    private final Board board;
    private final Point point;
    private final Integer color; //Colorもどうにかしたい

    public Reverser(Board board, Point point, Integer color) {
        this.board = board;
        this.point = point;
        this.color = color;
    }

    public List reversed(){

//        System.out.println("reversed start");

        LinkedList<Point> list = new LinkedList<Point>();
        list.addAll(this.reversePoint(0, 1)); //12:00

        list.addAll(this.reversePoint(1, 1)); //1:30
        list.addAll(this.reversePoint(1, 0)); //3:00
        list.addAll(this.reversePoint(1, -1)); //4:39
        list.addAll(this.reversePoint(-1, 0)); //6:00
        list.addAll(this.reversePoint(-1, -1)); //7:30
        list.addAll(this.reversePoint(-1, 0)); //9:00
        list.addAll(this.reversePoint(-1, -1)); //10:30


        return list;
    }


    private List<Point> reversePoint(int directX,int directY){

        Point p = new Point(point);

        ReverseQueue queue = new ReverseQueue(color);
        boolean status = false;
        do {
            p.translate(directX, directY);
            Integer i = board.getValue(p);
            status = queue.push(new Point(p),i);
        } while (status)  ;

        if(queue.isReverse()) {
            return queue.getPoints();
        }else{
            return new LinkedList<Point>();
        }
    }

}

@@ -586,58 +586,8 @@
 ()%7B%0A
-%0A//        System.out.println(%22reversed start%22);%0A%0A
     
@@ -681,16 +681,17 @@
 oint(0, 
+-
 1)); //1
@@ -695,17 +695,16 @@
 //12:00%0A
-%0A
         
@@ -735,17 +735,17 @@
 Point(1,
- 
+-
 1)); //1
@@ -842,17 +842,16 @@
 oint(1, 
--
 1)); //4
@@ -852,17 +852,17 @@
 ); //4:3
-9
+0
 %0A       
@@ -888,29 +888,28 @@
 eversePoint(
--1, 0
+0, 1
 )); //6:00%0A 
@@ -945,25 +945,24 @@
 sePoint(-1, 
--
 1)); //7:30%0A

fix direction