/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package scriptbuilder.structures.events;

import java.util.ArrayList;
import scriptbuilder.structures.ELEMENT;
import scriptbuilder.structures.I_XML_Writable;
import scriptbuilder.structures.ScriptEvent;
import scriptbuilder.structures.XMLWriter;

/**
 * Data model for a CHP radio event. A CHP radio transmission has a
 * conversation, with dialog between a field unit and a dispatch center. It also
 * has an audio file which has that conversation acted out.
 *
 * @author Bryan McGuffin
 */
public class CHPRadioEvent extends ScriptEvent implements I_XML_Writable
{

    /**
     * Constructor.
     */
    public CHPRadioEvent()
    {
        super(ScriptEventType.CHP_RADIO_EVENT);
    }

    /**
     * List of the lines of dialog in this event.
     */
    public ArrayList<String> lines = new ArrayList<String>();

    /**
     * List of the corresponding roles for each line of dialog.
     */
    public ArrayList<String> roles = new ArrayList<String>();

    /**
     * Path for the audio file to be played during this event.
     */
    public String radioFile = "";

    @Override
    public String toXML()
    {
        String output = XMLWriter.openTag(ELEMENT.CHP_RADIO.tag + " RadioFile=\"" + radioFile + "\"");
        output += XMLWriter.openTag(ELEMENT.DIALOG.tag);

        for (int i = 0; i < lines.size(); i++)
        {
            output += XMLWriter.openTag(ELEMENT.LINE.tag + " Role=\"" + roles.get(i) + "\"");
            output += lines.get(i);
            output += XMLWriter.closeTag(ELEMENT.LINE.tag);
        }

        output += XMLWriter.closeTag(ELEMENT.DIALOG.tag);
        output += XMLWriter.closeTag(ELEMENT.CHP_RADIO.tag);

        return output;
    }
}
