/** * Lazy-loading accessor for the artillery targeting control. * @return */ public ArtilleryTargetingControl getArtilleryTargetingControl() { if(atc == null) { atc = new ArtilleryTargetingControl(); } return atc; }
if(getDamageValue(damage, coords) != null) { return getDamageValue(damage, coords); double totalDamage = calculateDamageValueForHex(damage, coords, shooter, game, owner); totalDamage += calculateDamageValueForHex(currentDamage, currentCoords, shooter, game, owner); cacheDamageValue(damage, coords, totalDamage); return totalDamage;
buildTargetList(shooter, game, owner); double damageValue = calculateDamageValue(damage, hexTarget.getPosition(), shooter, game, owner); WeaponFireInfo wfi = new WeaponFireInfo(shooter, hexTarget, currentWeapon, game, false, owner); WeaponFireInfo actualFireInfo = topValuedFireInfos.get(Compute.randomInt(topValuedFireInfos.size())); ArtilleryAttackAction aaa = (ArtilleryAttackAction) actualFireInfo.buildWeaponAttackAction(); int ammoID = findAmmo(shooter, currentWeapon, game); aaa.setAmmoId(ammoID); actualFireInfo.setAction(aaa); WeaponFireInfo tagInfo = getTAGInfo(currentWeapon, shooter, game, owner);
/** * Calculate an indirect artillery "fire plan", taking into account the possibility of rotating the turret. * @param shooter Entity doing the shooting * @param game Game pointer * @param owner Princess pointer * @return Firing plan */ public FiringPlan calculateIndirectArtilleryPlan(Entity shooter, IGame game, Princess owner) { FiringPlan bestPlan = calculateIndirectArtilleryPlan(shooter, game, owner, 0); // simply loop through all possible facings and see if any of those is better than the no-turning plan if(!shooter.isOffBoard()) { for(int facingChange : FireControl.getValidFacingChanges(shooter)) { FiringPlan twistPlan = calculateIndirectArtilleryPlan(shooter, game, owner, facingChange); if(twistPlan.getUtility() > bestPlan.getUtility()) { bestPlan = twistPlan; } } } return bestPlan; }
addHexDonuts(e.getPosition(), targetSet, game); addHexDonuts(coords, targetSet, game);
friendlyArtilleryDamage = ArtilleryTargetingControl.evaluateIncomingArtilleryDamage(path.getFinalCoords(), getOwner()); artyDamage.put(path.getFinalCoords(), friendlyArtilleryDamage); } else {
/** * 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); }