boolean getBooleanOption(final String name) { return getGame().getOptions().booleanOption(name); }
public void addStrategicBuildingTarget(final Coords coords) { if (null == coords) { throw new NullPointerException("Coords is null."); } if (!getGame().getBoard().contains(coords)) { log(getClass(), "addStrategicBuildingTarget(Coords)", LogLevel.WARNING, "Board does not contain " + coords.toFriendlyString()); return; } getStrategicBuildingTargets().add(coords); }
void addCoordFacingCombos(Iterator<CoordFacingCombo> cfit) { final String METHOD_NAME = "addCoordFacingCombos(Iterator<CoordFacingCombo>)"; owner.methodBegin(getClass(), METHOD_NAME); try { while (cfit.hasNext()) { CoordFacingCombo cf = cfit.next(); if(cf != null && owner.getGame().getBoard().contains(cf.coords)) { expandToInclude(cf.getCoords()); } } } finally { owner.methodEnd(getClass(), METHOD_NAME); } }
/** * Calculates the targeting/offboard turn * This includes firing TAG and non-direct-fire artillery */ @Override protected void calculateTargetingOffBoardTurn() { Entity entityToFire = getGame().getFirstEntity(getMyTurn()); FiringPlan firingPlan = getArtilleryTargetingControl().calculateIndirectArtilleryPlan(entityToFire, getGame(), this); sendAttackData(entityToFire.getId(), firingPlan.getEntityActionVector()); sendDone(true); }
final int targetHP = Compute.getTargetTotalHP(owner.getGame(), target); final double damageFraction = (existingDamage + expectedDamage) / ((double) targetHP); final double previousDamageFraction = existingDamage / ((double) targetHP); || owner.getGame().getEntity(target.getTargetId()) instanceof Infantry || owner.getGame().getEntity(target.getTargetId()) instanceof BattleArmor) { return 0;
/** * Returns the first set of valid deployment coordinates for the given unit out of the given deployment coordinates. * It's possible to return null, which indicates that there are no valid hexes for the given unit to deploy into. */ @Nullable @Override protected Coords getFirstValidCoords(final Entity deployedUnit, final List<Coords> possibleDeployCoords) { if (Entity.ETYPE_GUN_EMPLACEMENT == (deployedUnit.getEntityType() & Entity.ETYPE_GUN_EMPLACEMENT)) { final List<Coords> validCoords = calculateTurretDeploymentLocations((GunEmplacement) deployedUnit, possibleDeployCoords); if (0 < validCoords.size()) { return validCoords.get(0); } return null; } else if(getGame().useVectorMove()) { return calculateAdvancedAerospaceDeploymentCoords(deployedUnit, possibleDeployCoords); } else { return super.getFirstValidCoords(deployedUnit, possibleDeployCoords); } }
double sum = 0; for(Enumeration<ArtilleryAttackAction> attackEnum = operator.getGame().getArtilleryAttacks(); attackEnum.hasMoreElements();) { ArtilleryAttackAction aaa = attackEnum.nextElement(); Mounted weapon = aaa.getEntity(operator.getGame()).getEquipment(aaa.getWeaponId()); int damage = ((WeaponType) weapon.getType()).getRackSize(); Coords attackDestination = aaa.getTarget(operator.getGame()).getPosition(); int distance = coords.distance(attackDestination); int artySkill = aaa.getEntity(operator.getGame()).getCrew().getGunnery(); if(operator.getGame().getOptions().booleanOption(OptionsConstants.RPG_ARTILLERY_SKILL)) { artySkill = aaa.getEntity(operator.getGame()).getCrew().getArtillery();
/** * Worker method that calculates a point blank shot action vector given a firing entity ID and a target ID. * * @param firingEntityID the ID of the entity taking the point blank shot * @param targetID the ID of the entity being shot at potentially */ protected Vector<EntityAction> calculatePointBlankShot(int firingEntityID, int targetID) { Entity shooter = getGame().getEntity(firingEntityID); Targetable target = getGame().getEntity(targetID); final FiringPlanCalculationParameters fccp = new FiringPlanCalculationParameters.Builder().buildExact(shooter, target, calcAmmoConservation(shooter)); FiringPlan plan = getFireControl(shooter).determineBestFiringPlan(fccp); getFireControl(shooter).loadAmmo(shooter, plan); plan.sortPlan(); return plan.getEntityActionVector(); }
final Entity entity = getGame().getEntity(id); if (null == entity) { continue;
final Enumeration<Building> buildings = getGame().getBoard() .getBuildings(); while (buildings.hasMoreElements()) {
Mockito.doReturn(mockGame).when(mockPrincess).getGame(); Mockito.doReturn(true).when(mockPrincess).connect(); Mockito.doReturn(new HashSet<Coords>()).when(mockPrincess).getStrategicBuildingTargets();
getGame(), fireControlState); for (final Targetable target : potentialTargets) {
Mockito.when(mockPrincess.getHomeEdge(Mockito.any(Entity.class))).thenReturn(CardinalEdge.NORTH); IGame mockGame = Mockito.mock(IGame.class); Mockito.when(mockPrincess.getGame()).thenReturn(mockGame);
getGame(), fireControlState); for (final Targetable target : potentialTargets) {
noTwistPlan = getBestFiringPlan(shooter, target, owner.getGame(), ammoConservation); break; case GUESS: targetState, maxHeat, owner.getGame()); break; switch (params.getCalculationType()) { case GET: twistPlan = getBestFiringPlan(shooter, target, owner.getGame(), ammoConservation); break; case GUESS: targetState, maxHeat, owner.getGame());
boolean mustFleeBoard(final Entity entity) { if (!isFallingBack(entity)) { return false; } if (!entity.canFlee()) { return false; } if (0 < getPathRanker(entity).distanceToHomeEdge(entity.getPosition(), getHomeEdge(entity), getGame())) { return false; } //noinspection RedundantIfStatement if (!getFleeBoard() && !(entity.isCrippled() && getForcedWithdrawal())) { return false; } return true; }
Entity closestEnemy = getPathRanker(movingEntity).findClosestEnemy(movingEntity, pathEndpoint, getGame()); boolean unloadFatal = loadedEntity.isBoardProhibited(getGame().getBoard().getType()) || loadedEntity.isLocationProhibited(pathEndpoint); boolean unloadIllegal = Compute.stackingViolation(getGame(), loadedEntity, pathEndpoint, movingEntity) != null;
if(selectedEntity != null) { Princess princess = new Princess("test", "localhost", 2020, LogLevel.DEBUG); princess.getGame().setBoard(this.game.getBoard()); PathEnumerator pathEnum = new PathEnumerator(princess, this.game); pathEnum.recalculateMovesFor(this.selectedEntity);
final MovePath movePath = new MovePath(getGame(), mover);