@Test public void testGetEntityActionVector() { Vector<EntityAction> expected; // Test a no-twist plan. Mockito.when(testFiringPlan.getTwist()).thenReturn(0); expected = new Vector<>(3); expected.add(mockWeaponAttackActionMG); expected.add(mockWeaponAttackActionPPC); expected.add(mockWeaponAttackActionERML); Assert.assertEquals(expected, testFiringPlan.getEntityActionVector()); // todo Test torso-twists. // Test an empty firing plan. //noinspection MismatchedQueryAndUpdateOfCollection FiringPlan emptyPlan = new FiringPlan(mockTarget); expected = new Vector<>(0); Assert.assertEquals(expected, emptyPlan.getEntityActionVector()); }
/** * 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); }
sendAttackData(shooter.getId(), plan.getEntityActionVector()); return; } else {
/** * 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(); }