/*
Tiamat - a role-playing game framework
Target.java - represents the target of a Skill or Item
 
 Copyright  (C) 2004-2005 Hugues Johnson
 
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 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

package com.huguesjohnson.tiamat;

import java.lang.String;
import java.lang.StringBuffer;

/** Target - represents the target of a Skill or Item
 * @author Hugues Johnson
 */
public class Target{

/* begin public constants */
    /**
     * AFFECTED_ENTITY constants specify who this target effects.
     * AFFECTED_ENTITY_USER - the character that used the item.
     */
    public final static int AFFECTED_ENTITY_USER=0;
    /**
     * AFFECTED_ENTITY constants specify who this target effects.
     * AFFECTED_ENTITY_PARTY_SINGLE - a single member of the character’s party.
     */
    public final static int AFFECTED_ENTITY_PARTY_SINGLE=1;
    /**
     * AFFECTED_ENTITY constants specify who this target effects.
     * AFFECTED_ENTITY_PARTY_ALL - all members of the character’s party.
     */
    public final static int AFFECTED_ENTITY_PARTY_ALL=2;
    /**
     * AFFECTED_ENTITY constants specify who this target effects.
     * AFFECTED_ENTITY_ENEMY_SINGLE - a single enemy.
     */
    public final static int AFFECTED_ENTITY_ENEMY_SINGLE=3;
    /**
     * AFFECTED_ENTITY constants specify who this target effects.
     * AFFECTED_ENTITY_ENEMY_ALL - all enemies.
     */
    public final static int AFFECTED_ENTITY_ENEMY_ALL=4;
    /**
     * AFFECTED_ENTITY constants specify who this target effects.
     * AFFECTED_ENTITY_EVERYONE - everyone is effected.
     */
    public final static int AFFECTED_ENTITY_EVERYONE=5;
    /**
     * AFFECTED_ENTITY constants specify who this target effects.
     * DEFAULT_AFFECTED_ENTITY - AFFECTED_ENTITY_USER.
     */
    public final static int DEFAULT_AFFECTED_ENTITY=AFFECTED_ENTITY_USER;
/* end public constants */

/* begin public properties */
    //describes the path of the item or attribute being modified
    private String targetPath;
    /** 
     * Sets the path of the item or attribute being modified.
     * @param targetPath The path of the item or attribute being modified.
     */
    public void setTargetPath(String targetPath){ this.targetPath=new String(targetPath); }
    /**
     * Returns the path of the item or attribute being modified.
     * @return The path of the item or attribute being modified.
     */
    public String getTargetPath(){ return(this.targetPath); }
    //how much to modify the target, used differently for items & skills
    private long value;
    /**
     * Sets how much to modify the target.
     * @param value How much to modify the target.
     */
    public void setValue(long value){ this.value=value; }
    /**
     * Returns how much to modify the target.
     * @return How much to modify the target.
     */
    public long getValue(){ return(this.value); }
    //who this target affects    
    private int affectedEntity;
    /**
     * Sets who this target affects.
     * @param affectedEntity Who this Target effects, see AFFECTED_ENTITY constants.
     */
    public void setAffectedEntity(int affectedEntity){ this.affectedEntity=affectedEntity; }
    /**
     * Returns who this target affects.
     * @return Who this target affects, see AFFECTED_ENTITY constants.
     */
    public int getAffectedEntity(){ return(this.affectedEntity); }
/* end public properties */

    
/* begin constructors */
    /**
     * Create a new Target, uses DEFAULT_AFFECTED_ENTITY.
     * @param targetPath The path of the item or attribute being modified.
     * @param value How much to modify the target.
     */
    public Target(String targetPath,long value){
        this.setTargetPath(targetPath);
        this.value=value;
        this.affectedEntity=DEFAULT_AFFECTED_ENTITY;
    } 
    /**
     * Create a new Target, uses DEFAULT_AFFECTED_ENTITY.
     * @param targetPath The path of the item or attribute being modified.
     * @param value How much to modify the target.
     * @param affectedEntity Who this Target effects, see AFFECTED_ENTITY constants.
     */
    public Target(String targetPath,long value,int affectedEntity){
        this.setTargetPath(targetPath);
        this.value=value;
        this.affectedEntity=affectedEntity;
    }
/* end constructors */

    
/* begin public methods */    
    /** 
     * Returns a string representation of the object.
     * @return A string representation of the object. 
     */
    public String toString(){
        StringBuffer tostring=new StringBuffer(this.getClass().getName());
        tostring.append("\n  targetPath="+this.targetPath);
        tostring.append("\n  value="+this.value);
        tostring.append("\n  affectedEntity="+this.affectedEntity);
        return(tostring.toString());
    }
/* end public methods */    
}