expandBoard not finished
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -147,6 +148,7 @@ public class GomokuBoard{
|
||||
return output;
|
||||
|
||||
}
|
||||
//------------------Methods--------------------------
|
||||
|
||||
/**
|
||||
* This method return a Map of number aligned cells.
|
||||
@@ -183,6 +185,85 @@ public class GomokuBoard{
|
||||
return max;
|
||||
}
|
||||
|
||||
public void expandBoard(Cardinal direction){
|
||||
switch (direction) {
|
||||
case Cardinal.SE:
|
||||
this.expandBoard(Cardinal.S);
|
||||
this.expandBoard(Cardinal.E);
|
||||
return;
|
||||
|
||||
case Cardinal.NE:
|
||||
this.expandBoard(Cardinal.N);
|
||||
this.expandBoard(Cardinal.E);
|
||||
return;
|
||||
|
||||
case Cardinal.SW:
|
||||
this.expandBoard(Cardinal.S);
|
||||
this.expandBoard(Cardinal.W);
|
||||
return;
|
||||
|
||||
case Cardinal.NW:
|
||||
this.expandBoard(Cardinal.N);
|
||||
this.expandBoard(Cardinal.W);
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
List<Cardinal> cardinals = Arrays.asList(Cardinal.values());
|
||||
Cardinal topDirection = cardinals.get((cardinals.indexOf(direction) + 4)%8);
|
||||
Cardinal topMinus = cardinals.get((cardinals.indexOf(topDirection) + 2)%8);
|
||||
Cardinal topPlus = cardinals.get((cardinals.indexOf(topDirection) - 2)%8);
|
||||
|
||||
GomokuCell act = new GomokuCell(Color.NIL);
|
||||
int maxLen = 0;
|
||||
GomokuCell top = null;
|
||||
GomokuCell newOrigin = null;
|
||||
switch (direction) {
|
||||
case Cardinal.N:
|
||||
top = this.get(0, 0);
|
||||
maxLen = this.boardWidth;
|
||||
newOrigin = act;
|
||||
break;
|
||||
|
||||
case Cardinal.W:
|
||||
top = this.get(0,0);
|
||||
maxLen = this.boardHeight;
|
||||
newOrigin = act;
|
||||
break;
|
||||
|
||||
case Cardinal.S:
|
||||
top = this.get(this.boardHeight-1, 0);
|
||||
maxLen = this.boardWidth;
|
||||
newOrigin = this.get(0, 0);
|
||||
break;
|
||||
|
||||
case Cardinal.E:
|
||||
top = this.get(0, this.boardWidth-1);
|
||||
maxLen = this.boardHeight;
|
||||
newOrigin = this.get(0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("Why are you here ?");
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < maxLen; i++) {
|
||||
if (top != null) {
|
||||
GomokuCell.link(act, top.getNeighbour(Cardinal.W), Cardinal.NW);
|
||||
GomokuCell.link(act, top, Cardinal.N);
|
||||
top = top.getNeighbour(Cardinal.E);
|
||||
GomokuCell.link(act, top , Cardinal.NE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//------------------Overides--------------------------
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user