package de.mrunde.bachelorthesis.instructions;

import de.mrunde.bachelorthesis.basics.Landmark;
import de.mrunde.bachelorthesis.basics.LandmarkCategory;
import de.mrunde.bachelorthesis.basics.Maneuver;

/**
 * This is a now instruction.
 * 
 * @author Marius Runde
 */
public class NowInstruction extends Instruction {

	/**
	 * The global landmark of a <code>GlobalInstruction</code> to be used
	 */
	private Landmark global;

	/**
	 * Is the global landmark of the category sightseeing or not?
	 */
	private boolean sightseeingLandmark;

	/**
	 * Is the global landmark on the left or right from the user's perspective?
	 */
	private boolean leftTurn;

	/**
	 * Constructor of the LandmarkInstruction class
	 * 
	 * @param instruction
	 *            The current instruction
	 */
	public NowInstruction(Instruction instruction) {
		super(instruction.getDecisionPoint(), instruction.getManeuverType());
		if (instruction.getClass() == GlobalInstruction.class) {
			this.global = ((GlobalInstruction) instruction).getGlobal();
			this.sightseeingLandmark = ((GlobalInstruction) instruction)
					.getGlobal().getCategory() == LandmarkCategory.SIGHTSEEING;
			this.leftTurn = ((GlobalInstruction) instruction).getLeftTurn();
		} else {
			this.global = null;
		}
	}

	/**
	 * @return The instruction as a verbal text
	 */
	public String toString() {
		if (this.global != null) {
			// Global now instruction
			String instruction = "You pass the ";
			if (this.sightseeingLandmark) {
				instruction += this.global.getTitle();
			} else {
				instruction += this.global.getCategory();
			}
			if (this.leftTurn) {
				instruction += " now on your left";
			} else {
				instruction += " now on your right";
			}
			return instruction;
		} else if (Maneuver.isTurnAction(super.getManeuverType())) {
			// Local now instruction
			String instruction = super.getManeuver() + " now";
			return instruction;
		} else {
			// No turn action happens, can be ignored
			return null;
		}
	}
}

@@ -1481,11 +1481,20 @@
  = %22
-You
+Now you will
  pas
@@ -1686,36 +1686,32 @@
 instruction += %22
- now
  on your left%22;%0D
@@ -1744,20 +1744,16 @@
 ion += %22
- now
  on your
@@ -1908,16 +1908,25 @@
 uction =
+ %22Now %22 +
  super.g
@@ -1941,17 +1941,8 @@
 er()
- + %22 now%22
 ;%0D%0A%09

Change structure of NowInstruction (preposition now moved to the front)