public void getGameTurn(String gameId, int turn) { GameEngine.showLoading(); ServerDriver.getGameTurn(GameController.getInstance().getUser().getId(), gameId, turn); }
@Override public void onEvent(int type, Object data) { if (type == YES) GameController.getInstance().logOut(); }
public void surrenderGame(String gameId) { ServerDriver.sendGameTurn( GameController.getInstance().getUser().getId(), gameId, "ended", "defeat"); }
public void getGamesList() { GameEngine.showLoading(); ServerDriver.getListGames(GameController.getInstance().getUser().getId()); }
public void enableRandom() { ServerDriver.enableRandom(GameController.getInstance().getUser().getId()); }
/** @author sailfish */ public class View { private Rect viewingRect; private Rect outputRect; private final GameController controller = GameController.getInstance(); private double scale; private double translateX, translateY; private final Rect idealViewingRect; private static final Logger LOG = Logger.getLogger(View.class.getName()); public View(Rect viewingRect, Rect outputRect) { assert (viewingRect != null && !viewingRect.hasZeroArea()); assert (outputRect != null && !outputRect.hasZeroArea()); this.idealViewingRect = viewingRect; this.viewingRect = viewingRect.expandToAspectRatio(outputRect); this.outputRect = outputRect; setScale(); } public double view(double length) { return length * scale; } public double project(double length) { return length / scale; } public void updateOutputRect(Rect r) { if (r.hasZeroArea()) { this.outputRect = new Rect(new Point2d(), 10, 10); } else { this.outputRect = r; } viewingRect = idealViewingRect.expandToAspectRatio(outputRect); viewingRect = viewingRect.centerOn(idealViewingRect); setScale(); } public Point2d view(Point2d p) { return new Point2d(view(p.getX() + translateX), view(p.getY() + translateY)); } public Point2d project(Point2d p) { return new Point2d(project(p.getX()) - translateX, project(p.getY()) - translateY); } public ImmutableSet<ViewedDrawable> getViewed() { ImmutableSet<Drawable> draw = controller.watch(viewingRect); ImmutableSet.Builder<ViewedDrawable> viewed = ImmutableSet.builder(); for (Drawable d : draw) { viewed.add(ViewedDrawable.wrap(d, this)); } LOG.log(Level.INFO, viewed.build().toString()); return viewed.build(); } @Override public String toString() { return "View{" + "viewingRect=" + viewingRect + ", outputRect=" + outputRect + '}'; } private void setScale() { scale = outputRect.width / viewingRect.width; translateX = outputRect.topLeft.getX() - viewingRect.topLeft.getX(); translateY = outputRect.topLeft.getY() - viewingRect.topLeft.getY(); } // public static View viewSelectedItems(ObservableSet<Drawable> d){ // // return null; // } }