Search in sources :

Example 1 with Event

use of gmgen.plugin.Event in project pcgen by PCGen.

the class Initiative method getUnSelected.

/**
	 *  Looks at each line in the table, and returns an ArrayList of lines that are not Selected.
	 *
	 *@return    An ArrayList of currently selected InitHolders
	 */
private List<InitHolder> getUnSelected() {
    final List<InitHolder> retList = new ArrayList<>();
    int j = -1;
    for (int i = 0; i < combatantTable.getRowCount(); i++) {
        j++;
        InitHolder iH = initList.get(j);
        if ((iH.getStatus() == State.Dead) && !showDead.isSelected()) {
            i--;
            continue;
        }
        if ((iH instanceof Event) && !showEvents.isSelected()) {
            i--;
            continue;
        }
        if (!combatantTable.isRowSelected(i)) {
            retList.add(iH);
        }
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ActionEvent(java.awt.event.ActionEvent) Event(gmgen.plugin.Event) InitHolder(gmgen.plugin.InitHolder)

Example 2 with Event

use of gmgen.plugin.Event in project pcgen by PCGen.

the class Initiative method nextInit.

/**  Moves to the next active initiative */
private void nextInit() {
    int oldInit = currentInit;
    setCurrentInit(currentInit - 1);
    int bleedingTime = SettingsHandler.getGMGenOption(InitiativePlugin.LOG_NAME + ".Damage.Dying", PreferencesDamagePanel.DAMAGE_DYING_END);
    for (int i = 0; i < initList.size(); i++) {
        InitHolder iH = initList.get(i);
        if (iH instanceof Event) {
            Event e = (Event) iH;
            int eInit = e.getInitiative().getCurrentInitiative();
            if (oldInit == eInit) {
                int duration = e.decDuration();
                if (duration < 0) {
                    writeToCombatTabWithRound(e.getPlayer() + "'s " + e.getName() + " ended");
                    if (e.isAlert()) {
                        JOptionPane.showMessageDialog(this, e.getEndText());
                    }
                    initList.remove(i);
                }
            }
        } else if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            int cInit = cbt.getInitiative().getCurrentInitiative();
            if (oldInit == cInit) {
                cbt.decDuration();
                if (bleedingTime == PreferencesDamagePanel.DAMAGE_DYING_INITIATIVE) {
                    bleed((Combatant) iH);
                }
            }
        }
    }
    if (currentInit <= 0) {
        int maxInit = initList.getMaxInit();
        setCurrentInit(maxInit);
        for (InitHolder anInitList : initList) {
            if (bleedingTime == PreferencesDamagePanel.DAMAGE_DYING_END) {
                if (anInitList instanceof Combatant) {
                    bleed((Combatant) anInitList);
                }
            }
            anInitList.endRound();
        }
        round++;
        writeToCombatTab("Round " + round);
        setCurrentInit(maxInit);
    } else if (!initList.initValid(currentInit)) {
        nextInit();
    }
    refreshTable();
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ActionEvent(java.awt.event.ActionEvent) Event(gmgen.plugin.Event) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 3 with Event

use of gmgen.plugin.Event in project pcgen by PCGen.

the class Initiative method getSelected.

/**
	 *  Looks at each line in the table, and returns an ArrayList of lines that are Selected.
	 *
	 *@return    An ArrayList of currently selected InitHolders
	 */
private List<InitHolder> getSelected() {
    final List<InitHolder> retList = new ArrayList<>();
    int j = -1;
    for (int i = 0; i < combatantTable.getRowCount(); i++) {
        j++;
        InitHolder iH = initList.get(j);
        if ((iH.getStatus() == State.Dead) && !showDead.isSelected()) {
            i--;
            continue;
        }
        if ((iH instanceof Event) && !showEvents.isSelected()) {
            i--;
            continue;
        }
        if (combatantTable.isRowSelected(i)) {
            retList.add(iH);
        }
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ActionEvent(java.awt.event.ActionEvent) Event(gmgen.plugin.Event) InitHolder(gmgen.plugin.InitHolder)

Example 4 with Event

use of gmgen.plugin.Event in project pcgen by PCGen.

the class Initiative method loadFromDocument.

/**
	 *  Loads a character or party from an XML document
	 *
	 *@param  character  XML document containing a character or a party
	 * @param comp
	 */
private void loadFromDocument(Document character, PCGenMessageHandler comp) {
    if (character.getRootElement().getName().equals("Party")) {
        Element party = character.getRootElement();
        List xmlList = party.getChildren("Character");
        for (Object aXmlList : xmlList) {
            Element eCharacter = (Element) aXmlList;
            InitHolder combatant = new XMLCombatant(eCharacter);
            initList.add(combatant);
        }
        List pcgList = party.getChildren("PcgCombatant");
        for (Object aPcgList : pcgList) {
            Element eCharacter = (Element) aPcgList;
            final PcgCombatant combatant = new PcgCombatant(eCharacter, comp, messageHandler);
            initList.add(combatant);
            addTab(combatant);
        }
        List eventList = party.getChildren("Event");
        for (Object anEventList : eventList) {
            Element eCharacter = (Element) anEventList;
            InitHolder combatant = new Event(eCharacter);
            initList.add(combatant);
        }
        List spellList = party.getChildren("Spell");
        for (Object aSpellList : spellList) {
            Element eCharacter = (Element) aSpellList;
            InitHolder combatant = new Spell(eCharacter);
            initList.add(combatant);
        }
        initList.calculateNumberField();
    } else if (character.getRootElement().getName().equals("Character")) {
        Element eCharacter = character.getRootElement();
        InitHolder combatant = new XMLCombatant(eCharacter);
        initList.add(combatant);
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) Element(org.jdom2.Element) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ActionEvent(java.awt.event.ActionEvent) Event(gmgen.plugin.Event) List(java.util.List) InitHolderList(gmgen.plugin.InitHolderList) ArrayList(java.util.ArrayList) InitHolder(gmgen.plugin.InitHolder) XMLCombatant(plugin.initiative.XMLCombatant) Spell(gmgen.plugin.Spell)

Example 5 with Event

use of gmgen.plugin.Event in project pcgen by PCGen.

the class StartEvent method save.

protected void save() {
    initiative.initList.add(new Event(tName.getText(), tPlayer.getText(), tEffect.getText(), ((Integer) lDuration.getValue()).intValue(), ((Integer) lInit.getValue()).intValue(), cbAlert.isSelected()));
    initiative.writeToCombatTabWithRound(" Event Timer " + tName.getText() + " Started");
    initiative.refreshTable();
    initiative.grabFocus();
    initiative.focusNextInit();
    setVisible(false);
    dispose();
}
Also used : Event(gmgen.plugin.Event) ActionEvent(java.awt.event.ActionEvent)

Aggregations

Event (gmgen.plugin.Event)7 ActionEvent (java.awt.event.ActionEvent)7 InitHolder (gmgen.plugin.InitHolder)6 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 ListSelectionEvent (javax.swing.event.ListSelectionEvent)6 ArrayList (java.util.ArrayList)3 PcgCombatant (gmgen.plugin.PcgCombatant)2 XMLCombatant (plugin.initiative.XMLCombatant)2 Combatant (gmgen.plugin.Combatant)1 InitHolderList (gmgen.plugin.InitHolderList)1 Spell (gmgen.plugin.Spell)1 List (java.util.List)1 Vector (java.util.Vector)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 Element (org.jdom2.Element)1