Entity e = (Entity) spottersAfter.nextElement(); if ( bestSpotter == null || e.crew.getGunnery() <
Entity ent = (Entity) spottersAfter.nextElement(); if ( bestSpotter == null || ent.crew.getGunnery() <
    private void resolveIndirectArtilleryAttacks()  {        Vector results = new Vector(game.getArtillerySize());        Vector attacks = new Vector(game.getArtillerySize());        // loop thru received attack actions, getting weapon results        for (Enumeration i = game.getArtilleryAttacks(); i.hasMoreElements();) {            ArtilleryAttackAction aaa = (ArtilleryAttackAction) i.nextElement();            if (aaa.turnsTilHit <= 0) {                final WeaponResult wr = aaa.getWR();                //HACK, for correct hit table resolution.                wr.artyAttackerCoords=aaa.getCoords();                final Vector spottersBefore=aaa.getSpotterIds();                Entity bestSpotter=null;                // Are there any valid spotters?                if ( null != spottersBefore ) {                    //fetch possible spotters now                    Enumeration spottersAfter=                        game.getSelectedEntities( new EntitySelector() {                                public int player =                                    wr.waa.getEntity(game).getOwnerId();                                public Targetable target =                                    wr.waa.getTarget(game);                                public boolean accept(Entity entity) {                                    Integer id = new Integer( entity.getId() );                                    if ( player == entity.getOwnerId() &&                                         spottersBefore.contains(id) &&                                         !( LosEffects.calculateLos                                            (game, entity.getId(), target)                                            ).isBlocked() &&                                         entity.isActive() ) {                                        return true;                                    }                                    return false;                                }                            } );                    //Out of any valid spotters, pick the best.                    while ( spottersAfter.hasMoreElements() ) {                        Entity e = (Entity) spottersAfter.nextElement();                        if ( bestSpotter == null || e.crew.getGunnery() <                             bestSpotter.crew.getGunnery() ){                            bestSpotter=e;                        }                    }                } // End have-valid-spotters                //If at least one valid spotter, then get the benefits thereof.                if(bestSpotter!=null) {                    int mod=(bestSpotter.crew.getGunnery()-4)/2;                    wr.toHit.addModifier(mod,"Spotting modifier");                }                // TODO : break into 80 column lines.                //HACK...but I gotta know HERE whether it hits, for purposes of adjusting fire.                if(wr.roll >= wr.toHit.getValue()) {                    wr.waa.getEntity(game).aTracker.setModifier(wr.waa.getEntity(game).getEquipment(wr.waa.getWeaponId()),ToHitData.AUTOMATIC_SUCCESS,wr.waa.getTarget(game).getPosition());                } else {                    wr.waa.getEntity(game).aTracker.setModifier(wr.waa.getEntity(game).getEquipment(wr.waa.getWeaponId()),wr.waa.getEntity(game).aTracker.getModifier(wr.waa.getEntity(game).getEquipment(wr.waa.getWeaponId()),wr.waa.getTarget(game).getPosition())-1,wr.waa.getTarget(game).getPosition());                }                results.addElement(wr);                attacks.addElement( aaa );            }            aaa.turnsTilHit--;        }        // loop through weapon results and resolve        int lastEntityId = Entity.NONE;        for (Enumeration i = results.elements();i.hasMoreElements();) {            WeaponResult wr = (WeaponResult) i.nextElement();            resolveWeaponAttack(wr, lastEntityId);            lastEntityId = wr.waa.getEntityId();        }        // Clear out all resolved attacks.        for (Enumeration i = attacks.elements(); i.hasMoreElements();) {            game.removeArtilleryAttack                ( (ArtilleryAttackAction) i.nextElement() );        }    }