/**
 * Copyright © 2010, Res Interactive, LLC. All Rights Reserved.
 */
package com.tootsville.user;

import org.starhope.appius.except.NotFoundException;
import org.starhope.appius.util.SimpleDataRecord;

/**
 * WRITEME: Document this type.
 *
 * @author brpocock@star-hope.org
 */
public class TootUserTrailer extends SimpleDataRecord <TootUserTrailer> {
	
	/**
	 * Java serialisation unique ID
	 */
	private static final long serialVersionUID = -5294630506765346172L;
	
	/**
	 * The Toot from the Basic 8 that they originally chose.
	 */
	int basic8Choice = 1;


	/**
	 * The number of hours remaining of this user's Toot Timer
	 */
	private int tootTimeLeft;

	/**
	 * The number of minutes (beyond the hour) remaining of this user's
	 * Toot Timer
	 */
	private int tootTimeLeftMinutes;

	/**
	 * If true, the user's Toot Timer will refill every day CV
	 * {@link #tootTimerMonth}
	 */
	private boolean tootTimerDay;

	/**
	 * The number of hours which are added to the Toot Timer on each
	 * refill.
	 */
	private int tootTimeRefill;

	/**
	 * If true, the user's Toot Timer will refill every month. CV
	 * {@link #tootTimerDay}
	 */
	private boolean tootTimerMonth;

	/**
	 * user ID
	 */
	private int id;

	/**
	 * WRITEME: Document this constructor brpocock@star-hope.org
	 *
	 */
	public TootUserTrailer () {
		super (TootUserTrailer.class);
	}
	
	/**
	 * WRITEME: Document this constructor brpocock@star-hope.org
	 * 
	 * @param loader WRITEME
	 */
	public TootUserTrailer (final TootUserTrailerLoader loader) {
		super (loader);
	}

	/**
	 * @return the basic8Choice
	 */
	public int getBasic8Choice () {
		return basic8Choice;
	}

	/**
	 * @see org.starhope.appius.util.DataRecord#getCacheableID()
	 */
	@Override
	public int getCacheableID () throws NotFoundException {
		return id;
	}

	/**
	 * @see org.starhope.appius.util.DataRecord#getCacheableIdent()
	 */
	@Override
	public String getCacheableIdent () {
		return String.valueOf (id);
	}

	/**
	 * @return the user ID for which this is a trailer record
	 */
	public int getID () {
		return id;
	}

	/**
	 * @see org.starhope.util.HasSubversionRevision#getSubversionRevision()
	 */
	@Override
	public String getSubversionRevision () {
		return "$Rev: 4032 $";
	}

	/**
	 * @return the tootTimeLeft
	 */
	public int getTootTimeLeft () {
		return tootTimeLeft;
	}

	/**
	 * @return the tootTimeLeftMinutes
	 */
	public int getTootTimeLeftMinutes () {
		return tootTimeLeftMinutes;
	}

	/**
	 * @return the tootTimeRefill
	 */
	public int getTootTimeRefill () {
		return tootTimeRefill;
	}

	/**
	 * @return the tootTimerDay
	 */
	public boolean isTootTimerDay () {
		return tootTimerDay;
	}

	/**
	 * @return the tootTimerMonth
	 */
	public boolean isTootTimerMonth () {
		return tootTimerMonth;
	}

	/**
	 * @param choice the basic8Choice to set
	 */
	public void setBasic8Choice (final int choice) {
		basic8Choice = choice;
		changed ();
	}

	/**
	 * @param userID the new user ID
	 */
	public void setID (final int userID) {
		id = userID;
	}

	/**
	 * @param hours the tootTimeLeft to set
	 */
	public void setTootTimeLeft (final int hours) {
		tootTimeLeft = hours;
		tootTimeLeftMinutes = 0;
		changed ();
	}

	/**
	 * @param minutesToSet the tootTimeLeftMinutes to set
	 */
	public void setTootTimeLeftMinutes (final int minutesToSet) {
		tootTimeLeftMinutes = minutesToSet % 60;
		tootTimeLeft = minutesToSet / 60;
		changed ();
	}

	/**
	 * @param timeTootsByDay the tootTimerDay to set
	 */
	public void setTootTimerDay (final boolean timeTootsByDay) {
		tootTimerDay = timeTootsByDay;
		tootTimerMonth = !timeTootsByDay;
		changed ();
	}

	/**
	 * @param refillAmount the tootTimeRefill to set
	 */
	public void setTootTimeRefill (final int refillAmount) {
		tootTimeRefill = refillAmount;
		changed ();
	}

	/**
	 * @param timeTootsByMonth the tootTimerMonth to set
	 */
	public void setTootTimerMonth (final boolean timeTootsByMonth) {
		tootTimerMonth = timeTootsByMonth;
		tootTimerDay = !timeTootsByMonth;
		changed ();
	}

}
