/**
 * <p>
 * Copyright © 2010, Bruce-Robert Pocock &amp; Edward Winkelman &amp;
 * Res Interactive, LLC
 * </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 <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.
 * </p>
 *
 * @author brpocock@star-hope.org
 * @author edward.winkelman@gmail.com
 */
package com.tootsville.game;

import org.json.JSONObject;
import org.starhope.appius.except.GameLogicException;
import org.starhope.appius.except.NotFoundException;
import org.starhope.appius.game.AppiusClaudiusCaecus;
import org.starhope.appius.game.GameEvent;
import org.starhope.appius.game.GameStateFlag;
import org.starhope.appius.game.Zone;
import org.starhope.appius.room.Room;
import org.starhope.appius.user.AbstractUser;

/**
 * @author ewinkelman
 */
public class VITOnly extends GameEvent {

    private static String [] roomList = { "superWorld",
            "superWorldAlley" };
	
	/**
	 * WRITEME brpocock@star-hope.org Sep 28, 2010
	 * 
	 * @param z Zone in which haunted organ is placed
	 * @throws NotFoundException WRITEME
	 * @throws GameLogicException WRITEME
	 */
    public VITOnly (final Zone z) throws NotFoundException,
            GameLogicException {
        super (z, 'S');

        gameState = GameStateFlag.GAME_SOLO;

        for (String element : VITOnly.roomList) {
            Room room = z.getRoomByName (element);
            if (null == room) {
                AppiusClaudiusCaecus.reportBug ("VIT Only can't find "
                        + element);
                throw new GameLogicException ("Can't find " + element,
                        this, z);
            } else {
                room.setVariable ("paidOnly", "true");
            }
        }
    }

	/**
	 * @see org.starhope.appius.room.RoomListener#acceptGameAction(org.starhope.appius.user.AbstractUser,
	 *      org.json.JSONObject)
	 */
	@Override
	public void acceptGameAction (final AbstractUser u, final JSONObject action) {
		// No op

	}

	/**
	 * @see org.starhope.appius.room.RoomListener#acceptOutOfBandMessage(org.starhope.appius.user.AbstractUser,
	 *      org.starhope.appius.room.Room, org.json.JSONObject)
	 */
	@Override
	public void acceptOutOfBandMessage (final AbstractUser sender, final Room room,
			final JSONObject body) {
		// No op

	}

	/**
	 * @see org.starhope.appius.room.RoomListener#acceptPublicMessage(org.starhope.appius.user.AbstractUser,
	 *      java.lang.String)
	 */
	@Override
	public void acceptPublicMessage (final AbstractUser from, final String message) {
		// No op

	}

	/**
	 * @see org.starhope.appius.room.RoomListener#acceptUserAction(org.starhope.appius.room.Room,
	 *      org.starhope.appius.user.AbstractUser)
	 */
	@Override
	public void acceptUserAction (final Room r, final AbstractUser u) {
		// no op
	}

	/**
	 * @see org.starhope.appius.game.GameEvent#destroySelf()
	 */
	@Override
	public void destroySelf () {
		super.destroySelf ();
		AppiusClaudiusCaecus.remove (this);
	}

	/**
	 * @see org.starhope.appius.game.GameEvent#getGameEventPrefix()
	 */
	@Override
	public String getGameEventPrefix () {
        return "VITOnly";
	}

	/**
	 * @see org.starhope.appius.util.HasName#getName()
	 */
	@Override
	public String getName () {
        return "VIT Only in "
				+ (rooms.isEmpty () ? "no rooms" : rooms.first ()
						.getZone ().getName ());
	}


}
