use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterLevelsFacadeImplTest method setGameSkillRankData.
private void setGameSkillRankData(boolean crossClassCostTwo) {
GameMode game = SettingsHandler.getGame();
final XPTable xpTable = game.getLevelInfo(game.getDefaultXPTableName());
LevelInfo levelInfo = xpTable.getLevelInfo(1);
levelInfo.setLevelString("LEVEL");
if (crossClassCostTwo) {
levelInfo.setMaxClassSkillString("LEVEL+3");
levelInfo.setMaxCrossClassSkillString("(LEVEL+3)/2");
game.setSkillCost_CrossClass(2);
} else {
levelInfo.setMaxClassSkillString("LEVEL");
levelInfo.setMaxCrossClassSkillString("LEVEL");
game.setSkillCost_CrossClass(1);
}
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterFacadeImpl method save.
/**
* Save the character to disc using its filename. Note this method is not
* part of the CharacterFacade and should only be used by the
* ChracterManager class.
*
* @throws NullPointerException
* @throws IOException If the write fails
*/
public void save() throws NullPointerException, IOException {
GameMode mode = (GameMode) dataSet.getGameMode();
List<CampaignFacade> campaigns = ListFacades.wrap(dataSet.getCampaigns());
(new PCGIOHandler()).write(theCharacter, mode, campaigns, file.get());
theCharacter.setDirty(false);
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterFacadeImpl method initForCharacter.
/**
*
*/
private void initForCharacter() {
// Calculate any active bonuses
theCharacter.preparePCForOutput();
todoManager = new TodoManager();
infoFactory = new Gui2InfoFactory(theCharacter);
characterAbilities = new CharacterAbilities(theCharacter, delegate, dataSet, todoManager);
descriptionFacade = new DescriptionFacadeImpl(theCharacter);
spellSupportFacade = new SpellSupportFacadeImpl(theCharacter, delegate, dataSet, todoManager, this);
name = new DefaultReferenceFacade<>(charDisplay.getName());
file = new DefaultReferenceFacade<>(new File(charDisplay.getFileName()));
companionSupportFacade = new CompanionSupportFacadeImpl(theCharacter, todoManager, name, file, this);
availTempBonuses = new DefaultListFacade<>();
refreshAvailableTempBonuses();
appliedTempBonuses = new DefaultListFacade<>();
buildAppliedTempBonusList();
kitList = new DefaultListFacade<>();
refreshKitList();
statScoreMap = new HashMap<>();
for (StatFacade stat : dataSet.getStats()) {
if (stat instanceof PCStat) {
statScoreMap.put(stat, ChannelCompatibility.getStatScore(theCharacter.getCharID(), (PCStat) stat));
} else {
statScoreMap.put(stat, new DefaultReferenceFacade<>());
}
}
File portraitFile = null;
if (!StringUtils.isEmpty(charDisplay.getPortraitPath())) {
portraitFile = new File(charDisplay.getPortraitPath());
}
portrait = new DefaultReferenceFacade<>(portraitFile);
cropRect = new RectangleReference(charDisplay.getPortraitThumbnailRect());
characterType = new DefaultReferenceFacade<>(charDisplay.getCharacterType());
previewSheet = new DefaultReferenceFacade<>(charDisplay.getPreviewSheet());
skillFilter = new DefaultReferenceFacade<>(charDisplay.getSkillFilter());
tabName = new DefaultReferenceFacade<>(charDisplay.getTabName());
playersName = new DefaultReferenceFacade<>(charDisplay.getPlayersName());
race = new DefaultReferenceFacade<>(charDisplay.getRace());
raceList = new DefaultListFacade<>();
if (charDisplay.getRace() != null && charDisplay.getRace() != Globals.s_EMPTYRACE) {
raceList.addElement(charDisplay.getRace());
}
handedness = new DefaultReferenceFacade<>();
gender = new DefaultReferenceFacade<>();
availHands = new DefaultListFacade<>();
availGenders = new DefaultListFacade<>();
for (Handed handed : Handed.values()) {
availHands.addElement(handed);
}
for (Gender gender : Gender.values()) {
availGenders.addElement(gender);
}
if (charDisplay.getRace() != null) {
for (HandedFacade handsFacade : availHands) {
if (handsFacade.equals(charDisplay.getHandedObject())) {
handedness.set(handsFacade);
break;
}
}
for (GenderFacade pcGender : availGenders) {
if (pcGender.equals(charDisplay.getGenderObject())) {
gender.set(pcGender);
break;
}
}
}
alignment = new DefaultReferenceFacade<>(charDisplay.getPCAlignment());
age = new DefaultReferenceFacade<>(charDisplay.getAge());
ageCategory = new DefaultReferenceFacade<>();
updateAgeCategoryForAge();
currentXP = new DefaultReferenceFacade<>(charDisplay.getXP());
xpListener = new XPListener();
FacetLibrary.getFacet(XPFacet.class).addDataFacetChangeListener(xpListener);
xpForNextlevel = new DefaultReferenceFacade<>(charDisplay.minXPForNextECL());
xpTableName = new DefaultReferenceFacade<>(charDisplay.getXPTableName());
hpRef = new DefaultReferenceFacade<>(theCharacter.hitPoints());
skinColor = new DefaultReferenceFacade<>(charDisplay.getSafeStringFor(PCStringKey.SKINCOLOR));
hairColor = new DefaultReferenceFacade<>(charDisplay.getSafeStringFor(PCStringKey.HAIRCOLOR));
eyeColor = new DefaultReferenceFacade<>(charDisplay.getSafeStringFor(PCStringKey.EYECOLOR));
weightRef = new DefaultReferenceFacade<>();
heightRef = new DefaultReferenceFacade<>();
refreshHeightWeight();
purchasedEquip = new EquipmentListFacadeImpl(theCharacter.getEquipmentMasterList());
autoEquipListener = new AutoEquipListener();
FacetLibrary.getFacet(AutoEquipmentFacet.class).addDataFacetChangeListener(autoEquipListener);
carriedWeightRef = new DefaultReferenceFacade<>();
loadRef = new DefaultReferenceFacade<>();
weightLimitRef = new DefaultReferenceFacade<>();
equipSet = new DefaultReferenceFacade<>();
equipmentSets = new DefaultListFacade<>();
initEquipSet();
GameMode game = (GameMode) dataSet.getGameMode();
rollMethodRef = new DefaultReferenceFacade<>(game.getRollMethod());
charLevelsFacade = new CharacterLevelsFacadeImpl(theCharacter, delegate, todoManager, dataSet, this);
pcClasses = new ArrayList<>();
pcClassLevels = new DefaultListFacade<>();
refreshClassLevelModel();
charLevelsFacade.addHitPointListener(this);
deity = new DefaultReferenceFacade<>(charDisplay.getDeity());
domains = new DefaultListFacade<>();
maxDomains = new DefaultReferenceFacade<>(theCharacter.getMaxCharacterDomains());
remainingDomains = new DefaultReferenceFacade<>(theCharacter.getMaxCharacterDomains() - domains.getSize());
availDomains = new DefaultListFacade<>();
buildAvailableDomainsList();
templates = new DefaultListFacade<>(charDisplay.getDisplayVisibleTemplateList());
templateListener = new TemplateListener();
FacetLibrary.getFacet(TemplateFacet.class).addDataFacetChangeListener(templateListener);
initTodoList();
statTotalLabelText = new DefaultReferenceFacade<>();
statTotalText = new DefaultReferenceFacade<>();
modTotalLabelText = new DefaultReferenceFacade<>();
modTotalText = new DefaultReferenceFacade<>();
updateScorePurchasePool(false);
languages = new DefaultListFacade<>();
numBonusLang = new DefaultReferenceFacade<>(0);
numSkillLang = new DefaultReferenceFacade<>(0);
refreshLanguageList();
langListener = new LanguageListener();
FacetLibrary.getFacet(LanguageFacet.class).addDataFacetChangeListener(langListener);
purchasedEquip.addListListener(spellSupportFacade);
purchasedEquip.addEquipmentListListener(spellSupportFacade);
fundsRef = new DefaultReferenceFacade<>(theCharacter.getGold());
wealthRef = new DefaultReferenceFacade<>(theCharacter.totalValue());
gearBuySellSchemeRef = new DefaultReferenceFacade<>(findGearBuySellRate());
allowDebt = false;
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class FacadeFactory method initGameModes.
private static void initGameModes(List<GameMode> modes) {
for (GameMode mode : modes) {
String title = mode.getDefaultSourceTitle();
if (SettingsHandler.getGame().equals(mode) && title == null && !mode.getDefaultDataSetList().isEmpty()) {
title = mode.getName();
}
if (title != null && !"".equals(title)) {
DefaultListFacade<CampaignFacade> qcamps = new DefaultListFacade<>();
List<String> sources = mode.getDefaultDataSetList();
for (String string : sources) {
Campaign camp = Globals.getCampaignKeyed(string);
if (camp != null) {
qcamps.addElement(camp);
} else {
Logging.log(Logging.WARNING, "Unable to find source " + string + " used in default source " + title + " for game mode " + mode + ". " + title + " might not work correctly.");
}
}
if (qcamps.isEmpty()) {
Logging.log(Logging.WARNING, "Unable to load default source '" + title + "'. All of its sources are missing.");
continue;
}
quickSources.addElement(new BasicSourceSelectionFacade(mode.getDefaultSourceTitle(), qcamps, mode));
}
}
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class FacadeFactory method initCustomSourceSelections.
private static void initCustomSourceSelections() {
String[] keys = sourcesContext.getStringArray("selectionNames");
if (keys == null) {
return;
}
for (String name : keys) {
PropertyContext context = sourcesContext.createChildContext(name);
String modeName = context.getProperty("gamemode");
GameMode mode = SystemCollections.getGameModeNamed(modeName);
if (mode == null) {
Logging.errorPrint("Unable to load quick source '" + name + "'. Game mode '" + modeName + "' is missing");
continue;
}
String[] selectionArray = context.getStringArray("campaigns");
List<CampaignFacade> sources = new ArrayList<>();
boolean error = false;
for (String campaign : selectionArray) {
CampaignFacade c = campaignMap.get(campaign);
if (c != null) {
sources.add(c);
} else {
error = true;
Logging.log(Logging.WARNING, '\'' + campaign + '\'' + " campaign not found, custom quick source '" + name + "' might not work correctly.");
}
}
if (sources.isEmpty()) {
Logging.errorPrint("Unable to load quick source '" + name + "'. All of its sources are missing");
continue;
}
CustomSourceSelectionFacade selection = new CustomSourceSelectionFacade(name);
selection.setGameMode(mode);
selection.setCampaigns(sources);
if (error) {
selection.setLoadingState(LoadingState.LOADED_WITH_ERRORS);
selection.setErrorMessage("Some campaigns are missing");
}
customSources.addElement(selection);
quickSources.addElement(selection);
}
}
Aggregations