/**
 * <p>
 * Copyright © 2009-2010, Bruce-Robert Pocock
 * </p>
 * <p>
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * </p>
 * <p>
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * </p>
 * <p>
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * </p>
 * 
 * @author brpocock
 */
package org.starhope.appius.game;

import org.json.JSONException;
import org.json.JSONObject;
import org.starhope.appius.except.NotFoundException;
import org.starhope.appius.user.AbstractUser;
import org.starhope.appius.user.User;

/**
 * 
 * WRITEME: The documentation for this type (PreLoginCommands) is
 * incomplete. (brpocock, Dec 7, 2009)
 * 
 * @author brpocock
 * 
 */
public class PreLoginCommands {
	/**
	 * TODO: document this method (brpocock, Dec 7, 2009)
	 * 
	 * @param jso The JSON parameters passed to the finger command. The
	 *        only parameter interpreted is “id,” which must be the user
	 *        ID number whose public information is to be returned.
	 * @param u The user who WRITEME
	 * @param room WRITEME
	 * @return WRITEME
	 * @throws JSONException WRITEME
	 * @throws NotFoundException WRITEME
	 */
	public static JSONObject do_finger (final JSONObject jso,
			final AbstractUser u, final AbstractRoom room)
	throws JSONException, NotFoundException {
		final int userID = jso.getInt ("id");
		final AbstractUser userByID = User.getByID (userID);
		if (null == userByID) {
			final JSONObject fail = new JSONObject ();
			fail.put ("from", "finger");
			fail.put ("status", "false");
			fail.put ("msg", "user.notfound");
			fail.put ("userID", userID);
			return fail;
		}
		return userByID.getPublicInfo ();
	}

	/**
	 * TODO: document this method (brpocock, Dec 10, 2009)
	 * 
	 * @return WRITEME
	 */
	public static String getRev () {
		return "$Rev$";
	}
}
