@Override public Position reArrangeRelativePosition(Player oldPlayerPos, Player newPlayerPos) { int different = this.ordinal() + getDeviation(oldPlayerPos); if (different < 0) { different = ELEMENTSINCYCLE - different; } return Button.values()[(different % ELEMENTSINCYCLE)].getRelativePosition(newPlayerPos); }
public Button getRelativePosition(Player myPos) { Button answer = this; switch (myPos) { case TOP: { answer = Button.values()[(this.ordinal() + TOPDEVIATION) % ELEMENTSINCYCLE]; break; } case RIGHT: { answer = Button.values()[(this.ordinal() + RIGHTDEVIATION) % ELEMENTSINCYCLE]; break; } case LEFT: { answer = Button.values()[(this.ordinal() + LEFTDEVIATION) % ELEMENTSINCYCLE]; break; } default: { } } return answer; }