/*
 *  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
 *
 * Detail.java
 *
 * Created on October 22, 2002, 5:23 PM
 */

package org.evilsoft.gaming.RPGeneration;

import java.util.ArrayList;

/**
 *
 * @author  devon
 */
public class Detail {
    private VariableHashMap allVars;
    private ArrayList information = new ArrayList();
    private String type;
    private String trait;
    private boolean print;
    private boolean infoConvert = false;

    /** Creates a new instance of Detail */
    public Detail(String type, String trait, VariableHashMap allVars) {
        this.type = type;
        this.trait = trait;
        this.allVars = allVars;
    }

    public Detail(String type, String trait, ArrayList information, boolean print, boolean infoConvert, VariableHashMap allVars) {
        this.type = type;
        this.trait = trait;
        this.print = print;
		this.infoConvert = infoConvert;
        if(information.size() > 0) {
            for(int i = 0; i < information.size(); i++) {
                Information info = (Information)information.get(i);
                this.information.add(new Information(info.getType(), info.getData(), allVars));
            }
        }
        this.allVars = allVars;
    }

    public void addInformation(Information info) {
        this.information.add(new Information(info.getType(), info.getData(), allVars));
    }

    public void addInformation(ArrayList information) {
        if(information.size() > 0) {
            for(int i = 0; i < information.size(); i++) {
                Information info = (Information)information.get(i);
                this.information.add(new Information(info.getType(), info.getData(), allVars));
            }
        }
    }

    public String getType() {
        return allVars.parse(type);
    }

    public String getTrait() {
        return allVars.parse(trait);
    }

    public ArrayList getInformation() {
		return getInformation(false);
	}
	
    public ArrayList getInformation(boolean getInfoParse) {
		ArrayList alInformation = new ArrayList();
		alInformation.addAll(information);
		if(infoConvert && getInfoParse) {
			alInformation.add(new Information(type, trait, allVars));
		}
        return alInformation;
    }

    public boolean isPrintable() {
        return print;
    }

    public void switchPrintable(boolean print) {
        if(!print) {
            this.print = print;
        }
    }
}

