/**
 * FountainWishDamage.java (com.tootsville.actions) TODO: Describe this
 * file... Project: Server Copyright © 2010, Bruce-Robert Pocock 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. 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. You
 * should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author brpocock@star-hope.org Created Sep 28, 2010
 */
package com.tootsville.actions;

import org.starhope.appius.except.NotFoundException;
import org.starhope.appius.game.AppiusClaudiusCaecus;
import org.starhope.appius.game.DamageArea;
import org.starhope.appius.game.DamageTypeRanks;
import org.starhope.appius.game.RunCommands;
import org.starhope.appius.game.Zone;
import org.starhope.appius.room.Room;
import org.starhope.appius.user.AbstractUser;
import org.starhope.appius.user.Nomenclator;
import org.starhope.appius.user.events.ActionHandler;
import org.starhope.appius.user.events.ActionMethod;
import org.starhope.appius.user.events.EventRecord;
import org.starhope.appius.user.events.Quaestor;

/**
 * @author brpocock@star-hope.org
 */
public class FountainWishDamage implements RunCommands, ActionMethod {

    /**
     * WRITEME brpocock@star-hope.org
     */
    public FountainWishDamage () {
		// no a no-op
    }

    /**
     * @see org.starhope.appius.user.events.ActionMethod#acceptAction(org.starhope.appius.room.Room,
     *      org.starhope.appius.user.AbstractUser, java.lang.String,
     *      org.starhope.appius.user.AbstractUser, java.lang.String,
     *      java.lang.Object[])
     */
    @Override
    public boolean acceptAction (final Room where,
            final AbstractUser subject, final String verb,
            final AbstractUser object, final String indirectObject,
            final Object ... trailer)
    {
        if ( !indirectObject.startsWith ("fountain/")) {
            return false;
        }
		DamageTypeRanks thisWish = new DamageTypeRanks ();
		try {
			thisWish.add (Nomenclator.getDataRecord (DamageArea.class,
					"Wish"), ((EventRecord) trailer [1])
					.getCurrencyAmountEarned ().intValue ());
		} catch (final NotFoundException e) {
			AppiusClaudiusCaecus
					.reportBug (
							"Caught a NotFoundException in FountainWishDamage.acceptAction ",
							e);
		}
		subject.takeAttack (thisWish);
        return true;
    }

    /**
     * @see org.starhope.appius.game.RunCommands#newZone(org.starhope.appius.game.Zone)
     */
    @Override
    public void newZone (final Zone z) {
        // no op
    }

    /**
     * @see org.starhope.appius.game.RunCommands#run()
     */
    @Override
    public void run () {
        try {
            Quaestor.listen (new ActionHandler ((Room) null,
					(AbstractUser) null, "event.end", null, this));
        } catch (final Exception e) {
            AppiusClaudiusCaecus.reportBug (e);
        }
    }

}
