public Position.Public getRelativePosition(Position.Player playerPos) { Public answer = this; if (!answer.equals(MID)) { switch (playerPos) { case TOP: { answer = Public.values()[ ((this.ordinal() + TOPDEVIATION) % ELEMENTSINCYCLE) + (ELEMENTSINCYCLE * (int) (this.ordinal() / ROWS))]; break; } case RIGHT: { answer = Public.values()[ ((this.ordinal() + RIGHTDEVIATION) % ELEMENTSINCYCLE) + (ELEMENTSINCYCLE * (int) (this.ordinal() / ROWS))]; break; } case LEFT: { answer = Public.values()[ ((this.ordinal() + LEFTDEVIATION) % ELEMENTSINCYCLE) + (ELEMENTSINCYCLE * (int) (this.ordinal() / ROWS))]; break; } default: { } } } return answer; }
public Position reArrangeRelativePosition(Player oldPlayerPos, Player newPlayerPos) { Public answer = this; if (!this.equals(Position.Public.MID)) { int diff = oldPlayerPos.ordinal() - newPlayerPos.ordinal(); if (diff < 0) { diff = 4 + diff; } answer = Public.values()[ ((this.ordinal() + diff) % ELEMENTSINCYCLE) + (ELEMENTSINCYCLE * (int) (this.ordinal() / ROWS))]; } return answer; }
public static void logout() { Session.current().clear(); Public.index(); }
@Before static void checkAuthentification() { if (session.get("user") == null) Public.login(null, null); }