use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterFacadeImpl method refreshAvailableTempBonuses.
void refreshAvailableTempBonuses() {
List<TempBonusFacadeImpl> tempBonuses = new ArrayList<>();
// first objects on the PC
for (CDOMObject cdo : theCharacter.getCDOMObjectList()) {
scanForTempBonuses(tempBonuses, cdo);
}
//
// next do all abilities to get TEMPBONUS:ANYPC only
GameMode game = (GameMode) dataSet.getGameMode();
for (AbilityCategory cat : game.getAllAbilityCategories()) {
if (cat.getParentCategory() == cat) {
for (Ability aFeat : Globals.getContext().getReferenceContext().getManufacturer(Ability.class, cat).getAllObjects()) {
scanForAnyPcTempBonuses(tempBonuses, aFeat);
}
}
}
// Do all the PC's spells
for (Spell aSpell : theCharacter.aggregateSpellList("", "", "", 0, 9)) {
scanForTempBonuses(tempBonuses, aSpell);
}
// Do all the pc's innate spells.
Collection<CharacterSpell> innateSpells = theCharacter.getCharacterSpells(charDisplay.getRace(), Constants.INNATE_SPELL_BOOK_NAME);
for (CharacterSpell aCharacterSpell : innateSpells) {
if (aCharacterSpell == null) {
continue;
}
scanForTempBonuses(tempBonuses, aCharacterSpell.getSpell());
}
// Next do all spells to get TEMPBONUS:ANYPC or TEMPBONUS:EQUIP
for (Spell spell : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(Spell.class)) {
scanForNonPcTempBonuses(tempBonuses, spell);
}
// do all Templates to get TEMPBONUS:ANYPC or TEMPBONUS:EQUIP
for (PCTemplate aTemp : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(PCTemplate.class)) {
scanForNonPcTempBonuses(tempBonuses, aTemp);
}
Collections.sort(tempBonuses);
availTempBonuses.updateContents(tempBonuses);
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class VariableReport method runReport.
/**
* Produce the variable report in the requested formats.
*
* @param reportNameMap A map of formats to be output and the names of
* the files to contain the report for the format.
* @throws IOException If the template cannot be accessed or the file cannot be written to.
* @throws TemplateException If there is an error in processing the template.
*/
public void runReport(Map<ReportFormat, String> reportNameMap) throws IOException, TemplateException {
List<GameMode> games = SystemCollections.getUnmodifiableGameModeList();
Map<String, List<VarDefine>> gameModeVarMap = new TreeMap<>();
Map<String, Integer> gameModeVarCountMap = new TreeMap<>();
for (GameMode gameMode : games) {
List<VarDefine> varList = new ArrayList<>();
Map<String, Integer> varCountMap = new HashMap<>();
Set<File> processedLstFiles = new HashSet<>();
List<Campaign> campaignsForGameMode = getCampaignsForGameMode(gameMode);
for (Campaign campaign : campaignsForGameMode) {
processCampaign(campaign, varList, varCountMap, processedLstFiles);
}
Collections.sort(varList);
gameModeVarMap.put(gameMode.getName(), varList);
gameModeVarCountMap.put(gameMode.getName(), varCountMap.size());
}
for (Entry<ReportFormat, String> reportRequest : reportNameMap.entrySet()) {
Writer file = new FileWriter(new File(reportRequest.getValue()));
try {
outputReport(gameModeVarMap, gameModeVarCountMap, reportRequest.getKey(), file);
} finally {
IOUtils.closeQuietly(file);
}
}
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class ClassLevelCommand method run.
/**
* Runs classlevel on the inStack. The parameter is popped
* off the {@code inStack}, and the variable's value is
* pushed back to the top of {@code inStack}.
* @param inStack the jep stack
* @throws ParseException
*/
//Uses JEP, which doesn't use generics
@SuppressWarnings("unchecked")
@Override
public void run(final Stack inStack) throws ParseException {
// check the stack
checkStack(inStack);
// get the parameter from the stack
int paramCount = curNumberOfParameters;
String applied = null;
String className = null;
if (paramCount > 2) {
throw new ParseException("Invalid number of parameters");
}
if (paramCount >= 2) {
String p2 = inStack.pop().toString();
if (p2.startsWith("APPLIEDAS=")) {
applied = p2.substring(10);
}
}
if (paramCount >= 1) {
String p1 = inStack.pop().toString();
if (p1.startsWith("APPLIEDAS=")) {
if (applied != null) {
throw new ParseException("Formula had two APPLIEDAS= entries");
}
applied = p1.substring(10);
} else {
//Should be a class name
className = p1;
}
}
/*
* If there was no parameter showing the class, and this is used in a
* CLASS file, then use the class name
*/
if (className == null) {
String src = variableSource;
if (src.startsWith("CLASS:")) {
className = src.substring(6);
}
}
if (className == null) {
throw new ParseException("Unable to determine class name");
}
PlayerCharacter pc = getPC();
String cl = className;
if (applied != null) {
if ("NONEPIC".equalsIgnoreCase(applied)) {
GameMode mode = SettingsHandler.getGame();
//Add 1 since game mode is inclusive, but BEFORELEVEL is not!
int limit = mode.getMaxNonEpicLevel() + 1;
if (limit == Integer.MAX_VALUE) {
throw new ParseException("Game Mode has no EPIC limit");
}
cl += ";BEFORELEVEL=" + limit;
} else {
throw new ParseException("Did not understand APPLIEDAS=" + applied);
}
}
Double result = new Double(pc.getClassLevelString(cl, false));
inStack.push(result);
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class PrerequisiteWriterTest method setUp.
@Override
protected void setUp() throws Exception {
TestHelper.loadPlugins();
Globals.setUseGUI(false);
Globals.emptyLists();
GameMode gamemode = new GameMode("3.5");
SystemCollections.addToGameModeList(gamemode);
GameModeFileLoader.addDefaultTabInfo(gamemode);
SettingsHandler.setGame("3.5");
Alignment.createAllAlignments();
TestHelper.makeSizeAdjustments();
FactKey.getConstant("IsPC", STR_MGR);
FactKey.getConstant("LEGS", STR_MGR);
FactSetKey.getConstant("PANTHEONS", STR_MGR);
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class PreAlignParserTest method setUp.
@Before
public void setUp() throws Exception {
Globals.setUseGUI(false);
Globals.emptyLists();
GameMode gamemode = new GameMode("3.5");
GameModeFileLoader.addDefaultTabInfo(gamemode);
SystemCollections.addToGameModeList(gamemode);
SettingsHandler.setGame("3.5");
Alignment.createAllAlignments();
}
Aggregations