/*
 * 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.XMLBuilder;

/**
 * Data model for a telephone conversation. A conversation is made up of lines
 * of dialog; each line of dialog in the conversation has some text to be
 * spoken, and a role for the speaker.
 *
 * @author Bryan McGuffin
 */
public class TelephoneEvent extends ScriptEvent implements I_XML_Writable
{

    /**
     * Constructor.
     */
    public TelephoneEvent()
    {
        super(ScriptEventType.TELEPHONE_EVENT);
    }

    public ArrayList<String> lines = new ArrayList<String>();

    public ArrayList<String> roles = new ArrayList<String>();

    @Override
    public String toXML()
    {
        String output = XMLBuilder.openTag(ELEMENT.TELEPHONE.tag);
        for (int i = 0; i < lines.size(); i++)
        {
            if (roles.get(i).equalsIgnoreCase(ELEMENT.STUDENT.tag))
            {
                output += XMLBuilder.simpleTag(lines.get(i), ELEMENT.STUDENT);
            }
            else
            {
                output += XMLBuilder.openTag(ELEMENT.INSTRUCTOR.tag + " Role=\"" + roles.get(i) + "\"");
                output += lines.get(i);
                output += XMLBuilder.closeTag(ELEMENT.INSTRUCTOR.tag);
            }
        }
        output += XMLBuilder.closeTag(ELEMENT.TELEPHONE.tag);
        return output;
    }
}
