Search in sources :

Example 6 with PcgCombatant

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

the class EncounterPlugin method handleTransferToTracker.

/**
	 * Handles the <b>Begin Combat</b> button.
	 */
public void handleTransferToTracker() {
    int i;
    PlayerCharacter aPC;
    JFrame oldRoot = Globals.getRootFrame();
    Globals.setRootFrame(GMGenSystem.inst);
    theModel.setPCs(theModel.size());
    try {
        for (i = 0; i < theModel.size(); i++) {
            aPC = theModel.getPCs()[i];
            aPC.setImporting(false);
            if (!handleRace(aPC, i)) {
                continue;
            }
            LevelCommandFactory lcf = aPC.getDisplay().getRace().get(ObjectKey.MONSTER_CLASS);
            if (lcf != null) {
                handleMonster(aPC, lcf);
            } else {
                handleNonMonster(aPC);
            }
            handleEquipment(aPC);
            aPC.setPCAttribute(PCAttribute.PLAYERSNAME, "Enemy");
            theList.add(new PcgCombatant(aPC, "Enemy", messageHandler));
        }
        JOptionPane.showMessageDialog(null, "You will now be returned to PCGen so that you can finalise your selected combatants.\nOnce they are finalised, return to the GMGen Initiative tab to begin the combat!", "Combatant Setup Complete", JOptionPane.INFORMATION_MESSAGE);
        messageHandler.handleMessage(new TransmitInitiativeValuesBetweenComponentsMessage(this, theList));
        removeAll();
    } catch (Throwable e) {
        e.printStackTrace();
    }
    Globals.setRootFrame(oldRoot);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PcgCombatant(gmgen.plugin.PcgCombatant) JFrame(javax.swing.JFrame) TransmitInitiativeValuesBetweenComponentsMessage(pcgen.pluginmgr.messages.TransmitInitiativeValuesBetweenComponentsMessage)

Example 7 with PcgCombatant

use of gmgen.plugin.PcgCombatant 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 8 with PcgCombatant

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

the class Initiative method addPcgCombatant.

/**
	 * Add a new pcg combatant
	 * @param pc
	 * @param type
	 */
public void addPcgCombatant(PlayerCharacter pc, String type) {
    String name = initList.getUniqueName(pc.getDisplay().getName());
    //Changed from != to .equals 10/21/06 thpr
    if (!name.equals(pc.getDisplay().getName())) {
        //Means this one is already loaded, so it should be considered a new pc.
        pc.setName(name);
        //TODO:  Is this necessary?  Exactly why?
        pc.setFileName("");
    }
    final PcgCombatant pcgcbt = new PcgCombatant(pc, type, messageHandler);
    initList.add(pcgcbt);
    addTab(pcgcbt);
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant)

Example 9 with PcgCombatant

use of gmgen.plugin.PcgCombatant 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 10 with PcgCombatant

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

the class SavingThrowDialog method setDefaults.

/**
	 * <p>
	 * Sets all field defaults based on the combatant, dc, save type, etc.
	 * </p>
	 * @param saveType
	 */
private void setDefaults(int saveType) {
    int base = 0;
    int ability = 0;
    int magic = 0;
    int misc = 0;
    if (cbt instanceof PcgCombatant) {
        PcgCombatant pcgcbt = (PcgCombatant) cbt;
        PlayerCharacter pc = pcgcbt.getPC();
        new PlayerCharacterOutput(pc);
        List<PCCheck> checkList = Globals.getContext().getReferenceContext().getOrderSortedCDOMObjects(PCCheck.class);
        if (saveType == FORT_SAVE) {
            PCCheck fort = checkList.get(0);
            base = pc.calculateSaveBonus(fort, "BASE");
            ability = pc.calculateSaveBonus(fort, "STATMOD");
            magic = pc.calculateSaveBonus(fort, "MAGIC");
            misc = pc.calculateSaveBonus(fort, "MISC.NOMAGIC.NOSTAT");
        } else if (saveType == REF_SAVE) {
            PCCheck ref = checkList.get(1);
            base = pc.calculateSaveBonus(ref, "BASE");
            ability = pc.calculateSaveBonus(ref, "STATMOD");
            magic = pc.calculateSaveBonus(ref, "MAGIC");
            misc = pc.calculateSaveBonus(ref, "MISC.NOMAGIC.NOSTAT");
        } else if (saveType == WILL_SAVE) {
            PCCheck will = checkList.get(2);
            base = pc.calculateSaveBonus(will, "BASE");
            ability = pc.calculateSaveBonus(will, "STATMOD");
            magic = pc.calculateSaveBonus(will, "MAGIC");
            misc = pc.calculateSaveBonus(will, "MISC.NOMAGIC.NOSTAT");
        }
    } else if (cbt instanceof XMLCombatant) {
        XMLCombatant xmlcbt = (XMLCombatant) cbt;
        if (saveType == FORT_SAVE) {
            int mod = new SystemAttribute("Constitution", xmlcbt.getAttribute("Constitution")).getModifier();
            ability = mod;
            base = xmlcbt.getSave("Fortitude") - mod;
        } else if (saveType == REF_SAVE) {
            int mod = new SystemAttribute("Dexterity", xmlcbt.getAttribute("Dexterity")).getModifier();
            ability = mod;
            base = xmlcbt.getSave("Reflex") - mod;
        } else if (saveType == WILL_SAVE) {
            int mod = new SystemAttribute("Wisdom", xmlcbt.getAttribute("Wisdom")).getModifier();
            ability = mod;
            base = xmlcbt.getSave("Will") - mod;
        }
        magic = parseInt(saveMagic.getText());
        misc = parseInt(saveMisc.getText());
    }
    setDefaults(base, ability, magic, misc, parseInt(saveTemp.getText()));
}
Also used : SystemAttribute(gmgen.plugin.SystemAttribute) PlayerCharacterOutput(gmgen.plugin.PlayerCharacterOutput) PcgCombatant(gmgen.plugin.PcgCombatant) PlayerCharacter(pcgen.core.PlayerCharacter) PCCheck(pcgen.core.PCCheck) XMLCombatant(plugin.initiative.XMLCombatant)

Aggregations

PcgCombatant (gmgen.plugin.PcgCombatant)15 InitHolder (gmgen.plugin.InitHolder)8 XMLCombatant (plugin.initiative.XMLCombatant)5 PlayerCharacter (pcgen.core.PlayerCharacter)4 InitHolderList (gmgen.plugin.InitHolderList)3 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Combatant (gmgen.plugin.Combatant)1 Event (gmgen.plugin.Event)1 PlayerCharacterOutput (gmgen.plugin.PlayerCharacterOutput)1 Spell (gmgen.plugin.Spell)1 SystemAttribute (gmgen.plugin.SystemAttribute)1 SystemHP (gmgen.plugin.SystemHP)1 SystemInitiative (gmgen.plugin.SystemInitiative)1 ActionEvent (java.awt.event.ActionEvent)1 Iterator (java.util.Iterator)1 Vector (java.util.Vector)1 JFormattedTextField (javax.swing.JFormattedTextField)1 JFrame (javax.swing.JFrame)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1