Search in sources :

Example 16 with InitHolder

use of gmgen.plugin.InitHolder 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 17 with InitHolder

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

the class Initiative method pasteNew.

/**  pastes the copied combatant
	 * @param toPaste
	 */
private void pasteNew(InitHolder toPaste) {
    if (toPaste instanceof XMLCombatant) {
        XMLCombatant cb = (XMLCombatant) toPaste;
        SystemInitiative init = cb.getInitiative();
        SystemHP hitPoints = cb.getHP();
        String name = initList.getUniqueName(cb.getName());
        InitHolder newCbt = new XMLCombatant(name, toPaste.getPlayer(), init.getAttribute().getValue(), hitPoints.getAttribute().getValue(), hitPoints.getMax(), hitPoints.getCurrent(), hitPoints.getSubdual(), init.getBonus(), cb.getCombatantType(), cb.getCR());
        initList.add(newCbt);
    }
    if (toPaste instanceof PcgCombatant) {
    //			PcgCombatant cb = (PcgCombatant) toPaste;
    //			PCGen_Frame1.getInst().loadPCFromFile(
    //				new File(cb.getPC().getFileName()), false, true);
    // As character exists in pcgen it is automatically added in to the init list
    }
    refreshTable();
}
Also used : SystemInitiative(gmgen.plugin.SystemInitiative) PcgCombatant(gmgen.plugin.PcgCombatant) SystemHP(gmgen.plugin.SystemHP) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 18 with InitHolder

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

the class Initiative method killCombatant.

/**  Kills the selected combatants */
private void killCombatant() {
    final List<InitHolder> selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            cbt.kill();
            combatantDied(cbt);
            combatantUpdated(cbt);
        }
    }
    initList.sort();
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 19 with InitHolder

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

the class Initiative method doSubdual.

/**
	 *  Do an amount of subdual damage to the selected combatants
	 *
	 *@param  damage  The amount of damage to do
	 */
private void doSubdual(int damage) {
    final List<InitHolder> selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        doSubdual(damage, iH);
    }
    initList.sort();
    refreshTable();
}
Also used : InitHolder(gmgen.plugin.InitHolder)

Example 20 with InitHolder

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

the class Initiative method rerollCombatant.

/**  Re-rolls the selected combatant's initiatives */
private void rerollCombatant() {
    final List<InitHolder> selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            cbt.init.check(0);
            writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Rerolled");
            combatantUpdated(cbt);
        }
    }
    initList.sort();
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Aggregations

InitHolder (gmgen.plugin.InitHolder)31 PcgCombatant (gmgen.plugin.PcgCombatant)18 XMLCombatant (plugin.initiative.XMLCombatant)13 Combatant (gmgen.plugin.Combatant)11 InitHolderList (gmgen.plugin.InitHolderList)7 ArrayList (java.util.ArrayList)7 Event (gmgen.plugin.Event)6 ActionEvent (java.awt.event.ActionEvent)6 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 ListSelectionEvent (javax.swing.event.ListSelectionEvent)6 List (java.util.List)5 Vector (java.util.Vector)2 Element (org.jdom2.Element)2 SaveModel (plugin.initiative.SaveModel)2 Spell (gmgen.plugin.Spell)1 SystemHP (gmgen.plugin.SystemHP)1 SystemInitiative (gmgen.plugin.SystemInitiative)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1