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