jackson databind import

- and some reowrk to use Position more than (x,y) parameters
This commit is contained in:
philippe lhardy
2021-11-03 08:30:30 +01:00
parent 02fda1fc2e
commit 619e9b9f19
9 changed files with 126 additions and 75 deletions

View File

@@ -19,6 +19,34 @@ bcd is within 'H' or ' '
public class Brick
{
// order matters index is same as bits order
public static final Position[] AllMoves = {
new Position(0,0).doReverseTranslate(Position.stepX),
new Position(Position.stepY),
new Position(Position.stepX),
new Position(0,0).doReverseTranslate(Position.stepY),
// last is no move
new Position(0,0)
};
// flag is in Brick settings
static int getDirectionIndex(short flag)
{
// short a = (short) (flag >> FLAGLENGTH);
for (int index = 0; index < AllMoves.length - 1; index ++) {
if (isFlagSet((short) (1 << index), flag)) {
return index;
}
}
// return last index which is no move.
return AllMoves.length - 1;
}
public static Position getDirectionMove(short direction) {
return AllMoves[getDirectionIndex(direction)];
}
public final static short LEFT = 1;
public final static short DOWN = 2;
public final static short RIGHT = 4;