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);
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations