public boolean passedThrough(Coords c) { for (Coords crd : passedThrough) { if (crd.equals(c)) { return true; } } return false; }
@Override public boolean equals(final Object obj) { if (!(obj instanceof Key)) { return false; } final Key s1 = (Key) obj; return (type == s1.type) && (facing == s1.facing) && coords.equals(s1.coords); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof RankedCoords)) { return false; } RankedCoords coords1 = (RankedCoords) o; if (Double.compare(coords1.fitness, fitness) != 0) { return false; } //noinspection RedundantIfStatement if (!coords.equals(coords1.coords)) { return false; } return true; }
public static void testCoords(Coords expected, Coords actual) { System.out.print("The entity should be deployed at "); System.out.print(expected); if (expected.equals(actual)) { System.out.println(" and it is."); } else { System.out.print(" but it is at "); System.out.print(actual); System.out.println("!"); } } }
public boolean shouldStop(MovePath e) { return destination.equals(e.getFinalCoords()); } }
/** * What coords were passed through previous to the given one */ public Coords passedThroughPrevious(Coords c) { if (passedThrough.size() == 0) { return getPosition(); } Coords prevCrd = passedThrough.get(0); for (Coords crd : passedThrough) { if (crd.equals(c)) { break; } prevCrd = crd; } return prevCrd; }
/** * Search the given vector of modifires for the modifier which coords equals * to the given coords * * @param modifiers <code>Vector</code> of the modifiers to process * @param coords coordinates of the modifire looked for * @return modifier with coords equals to the given on <code>null</code> * if not found */ protected ArtilleryModifier getModifierByCoords(Vector<ArtilleryModifier> modifiers, Coords coords) { for (ArtilleryModifier mod : modifiers) { if (mod.getCoords().equals(coords)) { return mod; } } return null; }
/** * Method that determines if this Entity passed over another entity during * its current path * * @param t * @return */ public boolean passedOver(Targetable t) { for (Coords crd : passedThrough) { if (crd.equals(t.getPosition())) { return true; } for (Coords secondary : t.getSecondaryPositions().values()) { if (crd.equals(secondary)) { return true; } } } return false; }
private ArrayList<ArtilleryAttackAction> getArtilleryAttacksAtLocation( Coords c) { ArrayList<ArtilleryAttackAction> v = new ArrayList<ArtilleryAttackAction>(); for (Enumeration<ArtilleryAttackAction> attacks = game .getArtilleryAttacks(); attacks.hasMoreElements(); ) { ArtilleryAttackAction a = attacks.nextElement(); if (a.getTarget(game).getPosition().equals(c)) { v.add(a); } } return v; }
/** * Returns the first entity at the given coordinate, if any. Only returns * targetable (non-dead) entities. * * @param c the coordinates to search at */ public Entity getFirstEntity(Coords c) { for (Entity entity : entities) { if (c.equals(entity.getPosition()) && entity.isTargetable()) { return entity; } } return null; }
/** * Checks if a target lies under a move path, to see if an aero unit can attack it. * * @param flightPath move path to check * @param targetState used for targets position * @return TRUE if the target is under the path. */ boolean isTargetUnderFlightPath(final MovePath flightPath, final EntityState targetState) { final Coords targetCoords = targetState.getPosition(); for (final Enumeration<MoveStep> step = flightPath.getSteps(); step.hasMoreElements(); ) { final Coords stepCoords = step.nextElement().getPosition(); if (targetCoords.equals(stepCoords)) { return true; } } return false; }
public boolean accept(Entity entity) { if (coords.equals(entity.getPosition()) && entity.isTargetable() && entity.isEnemyOf(friendly)) { return true; } return false; } });
private JMenu touchOffExplosivesMenu() { JMenu menu = new JMenu("Touch off explosives"); Building bldg = client.getBoard().getBuildingAt(coords); if ((bldg != null)) { for (final DemolitionCharge charge : bldg.getDemolitionCharges()) { if (charge.playerId == client.getLocalPlayer().getId() && coords.equals(charge.pos)) { JMenuItem item = new JMenuItem(charge.damage + " Damage"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { client.sendExplodeBuilding(charge); } }); menu.add(item); } } } return menu; }
public boolean accept(Entity entity) { if (coords.equals(entity.getPosition()) && entity.isTargetable() && !entity.isEnemyOf(friendly)) { return true; } return false; } });
/** * Returns the first enemy entity at the given coordinate, if any. Only * returns targetable (non-dead) entities. * * @param c the coordinates to search at * @param currentEntity the entity that is firing */ public Entity getFirstEnemyEntity(Coords c, Entity currentEntity) { for (Entity entity : entities) { if (c.equals(entity.getPosition()) && entity.isTargetable() && entity.isEnemyOf(currentEntity)) { return entity; } } return null; }
@Override public boolean equals(Object o) { if (!(o instanceof CoordFacingCombo)) { return false; } CoordFacingCombo c = (CoordFacingCombo) o; return !(getCoords() == null || !getCoords().equals(c.getCoords())) && getFacing() == c.getFacing(); }
private synchronized void drawHexSpritesForHex(Coords c, Graphics g, ArrayList<? extends HexSprite> spriteArrayList) { Rectangle view = g.getClipBounds(); for (HexSprite sprite : spriteArrayList) { Coords cp = sprite.getPosition(); // This can potentially be an expensive operation Rectangle spriteBounds = sprite.getBounds(); if (cp.equals(c) && view.intersects(spriteBounds) && !sprite.isHidden()) { if (!sprite.isReady()) { sprite.prepare(); } sprite.drawOnto(g, spriteBounds.x, spriteBounds.y, this, false); } } }
@Override public void hexSelected(BoardViewEvent b) { // Are we ignoring events? if (isIgnoringEvents()) { return; } Coords evtCoords = b.getCoords(); if (clientgui.isProcessingPointblankShot() && (evtCoords != null) && (ce() != null)) { if (!evtCoords.equals(ce().getPosition())){ if (shiftheld) { updateFlipArms(false); torsoTwist(b.getCoords()); } } } }
@Override public void hexMoused(BoardViewEvent b) { Coords c = b.getCoords(); if ((c == null) || c.equals(lastClicked)) { return; } lastClicked = c; bv.cursor(c); if ((b.getModifiers() & InputEvent.ALT_MASK) != 0) { setCurrentHex(board.getHex(b.getCoords())); } else if ((b.getModifiers() & InputEvent.CTRL_MASK) != 0) { if (!board.getHex(b.getCoords()).equals(curHex)) { paintHex(b.getCoords()); } } else if ((b.getModifiers() & InputEvent.SHIFT_MASK) != 0) { addToHex(b.getCoords()); } else if ((b.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { resurfaceHex(b.getCoords()); } } });
public PilotingRollData checkBogDown(MoveStep step, IHex curHex, Coords lastPos, Coords curPos, boolean isPavementStep) { PilotingRollData roll = new PilotingRollData(getId(), 4, "entering boggy terrain"); int bgMod = curHex.getBogDownModifier(getMovementMode(), false); final boolean onBridge = (curHex.terrainLevel(Terrains.BRIDGE) > 0) && (getElevation() == curHex.terrainLevel(Terrains.BRIDGE_ELEV)); if (!lastPos.equals(curPos) && (bgMod != TargetRoll.AUTOMATIC_SUCCESS) && (step.getMovementType(false) != EntityMovementType.MOVE_JUMP) && (getMovementMode() != EntityMovementMode.HOVER) && (getMovementMode() != EntityMovementMode.VTOL) && (getMovementMode() != EntityMovementMode.WIGE) && (step.getElevation() == 0) && !isPavementStep && !onBridge) { roll.append(new PilotingRollData(getId(), bgMod, "avoid bogging down")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, "Check false: Not entering bog-down terrain, " + "or jumping/hovering over such terrain"); } return roll; }