public static Coords idToCoords(int id) { int y = id / 100000; return new Coords(id - (y * 100000), y); }
public static Coords idToCoords(int id) { int idNoType = id - Targetable.TYPE_BUILDING * 1000000; int y = (idNoType) / 1000; return new Coords(idNoType - (y * 1000), y); }
public static Coords idToCoords(int id) { int y = id / 100000; return new Coords(id - (y * 100000), y); }
/** Constructs clean, plain hex at specified level. */ public Hex(int level) { this(level, new ITerrain[Terrains.SIZE], null, new Coords(0, 0)); }
public Hex(int level, String terrain, String theme) { this(level, terrain, theme, new Coords(0, 0)); }
public Hex(int level, ITerrain[] terrains, String theme) { this(level, terrains, theme, new Coords(0, 0)); }
/** * "Selects" the specified Coords. * * @param x the x coordinate. * @param y the y coordinate. */ public void select(int x, int y) { select(new Coords(x, y)); }
/** * Highlights the specified Coords. * * @param x the x coordinate. * @param y the y coordinate. */ public void highlight(int x, int y) { highlight(new Coords(x, y)); }
/** * "Cursors" the specified Coords. * * @param x the x coordinate. * @param y the y coordinate. */ public void cursor(int x, int y) { cursor(new Coords(x, y)); }
public void setOffScreen() { bounds.setLocation(-100, -100); hexLoc = new Coords(-2, -2); }
public final int distance(int distx, int disty) { return distance(new Coords(distx, disty)); }
@Override public Coords getCenter() { return new Coords(getWidth() / 2, getHeight() / 2); }
private void findGeysers() { IBoard b = server.getGame().getBoard(); int height = b.getHeight(); int width = b.getWidth(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (b.getHex(x, y).containsTerrain(Terrains.GEYSER)) { geysers.add(new GeyserInfo(new Coords(x, y))); } } } }
private void initializeHex(int x, int y, boolean event) { IHex hex = getHex(x, y); if (hex == null) { return; } hex.clearExits(); for (int i = 0; i < 6; i++) { IHex other = getHexInDir(x, y, i); hex.setExits(other, i, roadsAutoExit); } if (event) { processBoardEvent(new BoardEvent(this, new Coords(x, y), BoardEvent.BOARD_CHANGED_HEX)); } }
private MovePath generateMockPath(int x, int y, Entity mockEntity) { final MovePath mockPath = Mockito.mock(MovePath.class); Mockito.when(mockPath.getEntity()).thenReturn(mockEntity); final Coords mockMyCoords = new Coords(x, y); Mockito.when(mockPath.getFinalCoords()).thenReturn(mockMyCoords); Mockito.when(mockPath.getFinalFacing()).thenReturn(0); return mockPath; }
@Override public String run(String[] args) { if (args.length == 1) { getClient().getBoard(); return "The legal deployment zone is: " + legalDeploymentZone(); } else if (args.length == 5) { int id = Integer.parseInt(args[1]); Coords coord = new Coords(Integer.parseInt(args[2]) - 1, Integer .parseInt(args[3]) - 1); int nFacing = getDirection(args[4]); getClient().deploy(id, coord, nFacing, 0); return "Unit " + id + " deployed to " + coord.toFriendlyString() + ". (this is assuming it worked. No error checking done.)"; } return "Wrong number of arguments supplied. No deployment done."; }
private double potentialBuildingDamage(int x, int y, Entity entity) { Coords coords = new Coords(x, y); Building building = game.getBoard().getBuildingAt(coords); if (building == null) { return 0; } int potentialDmg = (int) Math.ceil((double) building.getCurrentCF(coords) / 10); boolean aptGunnery = entity.hasAbility(OptionsConstants.PILOT_APTITUDE_GUNNERY); double oddsTakeDmg = 1 - (Compute.oddsAbove(entity.getCrew().getPiloting(), aptGunnery) / 100); return potentialDmg * oddsTakeDmg; }
public final Coords translated(int dir, int distance) { int newx = xInDir(getX(), getY(), dir, distance); int newy = yInDir(getX(), getY(), dir, distance); return new Coords(newx, newy); }
private Coords selectNextGrid(int dir, Coords coords) { int x = Coords.xInDir(coords.getX(), coords.getY(), dir); int y = Coords.yInDir(coords.getX(), coords.getY(), dir); if (dir == E) { x++; } if (dir == W) { x--; } return new Coords(x, y); }
/** * Adds an Road to the map. Goes from one border to another, and has one * turn in it. Map must be at least 3x3. */ private void addGenericRoad() { Coords c = new Coords(Compute.randomInt(board.getWidth()), Compute .randomInt(board.getHeight())); int side0 = Compute.randomInt(6); int side1 = Compute.randomInt(5); if (side1 >= side0) { side1++; } buildStraightRoad(c, side0, 1); buildStraightRoad(c, side1, 1); } }