/*
 *  RPGeneration - A role playing utility generate interesting things
 *  Copyright (C) 2002 Devon D Jones
 *
 *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  The author of this program grants you the ability to use this code
 *  in conjunction with code that is covered under the Open Gaming License
 *
 * Effect.java
 *
 * Created on October 24, 2002, 2:10 PM
 */

package org.evilsoft.gaming.RPGeneration;

import org.jdom.*;

/**
 *
 * @author  devon
 */
public class Effect {
    private VariableHashMap allVars;

    private String text = "";
    private String type = "";
    private String trait = "";
    private String detail = "";
    private String detailData = "";
    private Integer die;
    private Integer num;
    private Integer bonus;
    private Integer multiplier;
    private Integer min;
    private Integer max;
    private boolean absolute = true;
    private int modifier = 0;
    private boolean eBool = true;

    public Effect(Element effectElement, VariableHashMap allVars) {
        this.allVars = allVars;
        try {
            if(effectElement.getAttribute("Boolean") != null) {
                eBool = effectElement.getAttribute("Boolean").getBooleanValue();
            }
            if(effectElement.getAttribute("Modifier") != null) {
                modifier = effectElement.getAttribute("Modifier").getIntValue();
            }
            if(effectElement.getAttribute("Type") != null) {
                type = effectElement.getAttribute("Type").getValue();
            }
            if(effectElement.getAttribute("Trait") != null) {
                trait = effectElement.getAttribute("Trait").getValue();
            }
            if(effectElement.getAttribute("Detail") != null) {
                detail = effectElement.getAttribute("Detail").getValue();
            }
            if(effectElement.getAttribute("DetailData") != null) {
                detailData = effectElement.getAttribute("DetailData").getValue();
            }
            if(effectElement.getAttribute("Die") != null) {
                die = new Integer(effectElement.getAttribute("Die").getIntValue());
            }
            if(effectElement.getAttribute("Num") != null) {
                num = new Integer(effectElement.getAttribute("Num").getIntValue());
            }
            if(effectElement.getAttribute("Bonus") != null) {
                bonus = new Integer(effectElement.getAttribute("Bonus").getIntValue());
            }
            if(effectElement.getAttribute("Multiplier") != null) {
                multiplier = new Integer(effectElement.getAttribute("Multiplier").getIntValue());
            }
            if(effectElement.getAttribute("Min") != null) {
                min = new Integer(effectElement.getAttribute("Min").getIntValue());
            }
            if(effectElement.getAttribute("Max") != null) {
                max = new Integer(effectElement.getAttribute("Max").getIntValue());
            }
            if(effectElement.getAttribute("Absolute") != null) {
                absolute = effectElement.getAttribute("Absolute").getBooleanValue();
            }
        }
        catch(Exception e) {
            System.out.println("XML ERROR");
            e.printStackTrace();
        }
    }

    public Effect(String text, String type, String trait, String detail, String detailData, int modifier, boolean eBool, VariableHashMap allVars) {
        this.allVars = allVars;
        this.text = text;
        this.type = type;
        this.trait = trait;
        this.detail = detail;
        this.detailData = detailData;
        this.modifier = modifier;
        this.eBool = eBool;
    }

    public String getType() {
        return type;
    }

    public String getTrait() {
        return trait;
    }

    public String getDetail() {
        return detail;
    }

    public String getDetailData() {
        return detailData;
    }

    public int getModifierValue() {
        return modifier;
    }

    public boolean getBooleanValue() {
        return eBool;
    }

    public Integer getDie() {
        return die;
    }

    public Integer getNum() {
        return num;
    }

    public Integer getBonus() {
        return bonus;
    }

    public Integer getMultiplier() {
        return multiplier;
    }

    public Integer getMin() {
        return min;
    }

    public Integer getMax() {
        return max;
    }

    public boolean getAbsolute() {
        return absolute;
    }

    public String toString() {
        return text;
    }
}
