CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
nl/tudelft/pogamut/ut2004/agent/module/shooting/weapon/AssaultRifleShooting.java49
nl/tudelft/pogamut/ut2004/agent/module/shooting/weapon/BioRifleShooting.java48
		if (!(target instanceof Player)) {
			shootTarget(target, facing, safe);
		}

		Player player = (Player) target;

		if (weaponPref.isPrimary()) {
			shootPrimary(player, facing, safe);
		} else {
			shootSecondary(player, facing, safe);
		}
	}

	/**
	 * Shoots primary mode at the target, if we are facing it. Secondary mode
	 * makes no sense. Will not blow a secondary charge if it is not safe to do
	 * so.
	 * 
	 * @param target
	 * @param facing
	 */
	protected void shootTarget(ILocated target, boolean facing, boolean safe) {
		if (facing && safe) {
			shoot.shootPrimary(target);
		} else if (!info.isSecondaryShooting()) {
			shoot.stopShoot();
		}
	}

	/**
	 * Starts shooting secondary mode.
	 */
	protected void chargeSecondary() {
		shoot.shootSecondary();
	}

	/**
	 * Shoots a visible player we are facing with the primary mode, otherwise
	 * charges up using secondary.
	 * 
	 * @param player
	 * @param facing
	 */
	protected void shootSecondary(Player player, boolean facing, boolean safe) {
		// Use primary to shoot visible players.
		// This will cause the first shot to be a charged shot.
		if (player.isVisible() && facing && safe) {
			shoot.shootPrimary(player);