use of pcgen.core.PCStat in project pcgen by PCGen.
the class DefineStatIntegrationTest method setUp.
@Override
public void setUp() throws PersistenceLayerException, URISyntaxException {
super.setUp();
PCStat ps = BuildUtilities.createStat("Strength", "STR");
primaryContext.getReferenceContext().importObject(ps);
PCStat pi = BuildUtilities.createStat("Intelligence", "INT");
primaryContext.getReferenceContext().importObject(pi);
PCStat ss = BuildUtilities.createStat("Strength", "STR");
secondaryContext.getReferenceContext().importObject(ss);
PCStat si = BuildUtilities.createStat("Intelligence", "INT");
secondaryContext.getReferenceContext().importObject(si);
}
use of pcgen.core.PCStat in project pcgen by PCGen.
the class AbstractTokenModelTest method setUpContext.
protected void setUpContext() throws PersistenceLayerException {
ChooserFactory.pushChooserClassname(RandomChooser.class.getName());
TokenRegistration.clearTokens();
TokenRegistration.register(AUTO_LANG_TOKEN);
TokenRegistration.register(ABILITY_VISIBLE_TOKEN);
TokenRegistration.register(AUTO_TOKEN);
TokenRegistration.register(CHOOSE_TOKEN);
TokenRegistration.register(CHOOSE_LANG_TOKEN);
TokenRegistration.register(ABILITY_MULT_TOKEN);
TokenRegistration.register(EQUIP_TYPE_TOKEN);
TokenRegistration.register(EQUIP_PROFICIENCY_TOKEN);
TokenRegistration.register(LANGBONUS_PRIM);
TokenRegistration.register(PC_QUAL);
TokenRegistration.register(getToken());
TokenRegistration.register(plugin.bonustokens.Feat.class);
directAbilityFacet = FacetLibrary.getFacet(DirectAbilityFacet.class);
activeEqModFacet = FacetLibrary.getFacet(ActiveEqModFacet.class);
alignmentFacet = FacetLibrary.getFacet(AlignmentFacet.class);
bioSetFacet = FacetLibrary.getFacet(BioSetFacet.class);
checkFacet = FacetLibrary.getFacet(CheckFacet.class);
classFacet = FacetLibrary.getFacet(ClassFacet.class);
classLevelFacet = FacetLibrary.getFacet(ClassLevelFacet.class);
companionModFacet = FacetLibrary.getFacet(CompanionModFacet.class);
deityFacet = FacetLibrary.getFacet(DeityFacet.class);
domainFacet = FacetLibrary.getFacet(DomainFacet.class);
expandedCampaignFacet = FacetLibrary.getFacet(ExpandedCampaignFacet.class);
languageFacet = FacetLibrary.getFacet(LanguageFacet.class);
raceFacet = FacetLibrary.getFacet(RaceInputFacet.class);
sizeFacet = FacetLibrary.getFacet(SizeFacet.class);
skillFacet = FacetLibrary.getFacet(SkillFacet.class);
statFacet = FacetLibrary.getFacet(StatFacet.class);
templateInputFacet = FacetLibrary.getFacet(TemplateInputFacet.class);
templateConsolidationFacet = FacetLibrary.getFacet(TemplateFacet.class);
weaponProfModelFacet = FacetLibrary.getFacet(WeaponProfModelFacet.class);
Globals.createEmptyRace();
Globals.setUseGUI(false);
Globals.emptyLists();
GameMode gamemode = SettingsHandler.getGame();
gamemode.clearLoadContext();
str = BuildUtilities.createStat("Strength", "STR");
str.put(VariableKey.getConstant("LOADSCORE"), FormulaFactory.getFormulaFor("STRSCORE"));
str.put(VariableKey.getConstant("OFFHANDLIGHTBONUS"), FormulaFactory.getFormulaFor(2));
dex = BuildUtilities.createStat("Dexterity", "DEX");
PCStat con = BuildUtilities.createStat("Constitution", "CON");
intel = BuildUtilities.createStat("Intelligence", "INT");
wis = BuildUtilities.createStat("Wisdom", "WIS");
cha = BuildUtilities.createStat("Charisma", "CHA");
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
lg = BuildUtilities.createAlignment("Lawful Good", "LG");
ref.importObject(lg);
ln = BuildUtilities.createAlignment("Lawful Neutral", "LN");
ref.importObject(ln);
le = BuildUtilities.createAlignment("Lawful Evil", "LE");
ref.importObject(le);
ng = BuildUtilities.createAlignment("Neutral Good", "NG");
ref.importObject(ng);
tn = BuildUtilities.createAlignment("True Neutral", "TN");
ref.importObject(tn);
ne = BuildUtilities.createAlignment("Neutral Evil", "NE");
ref.importObject(ne);
cg = BuildUtilities.createAlignment("Chaotic Good", "CG");
ref.importObject(cg);
cn = BuildUtilities.createAlignment("Chaotic Neutral", "CN");
ref.importObject(cn);
ce = BuildUtilities.createAlignment("Chaotic Evil", "CE");
ref.importObject(ce);
ref.importObject(BuildUtilities.createAlignment("None", "NONE"));
ref.importObject(BuildUtilities.createAlignment("Deity's", "Deity"));
gamemode.setBonusFeatLevels("3|3");
SettingsHandler.setGame("3.5");
ref.importObject(str);
ref.importObject(dex);
ref.importObject(con);
ref.importObject(intel);
ref.importObject(wis);
ref.importObject(cha);
fine = BuildUtilities.createSize("Fine", 0);
diminutive = BuildUtilities.createSize("Diminutive", 1);
tiny = BuildUtilities.createSize("Tiny", 2);
small = BuildUtilities.createSize("Small", 3);
medium = BuildUtilities.createSize("Medium", 4);
medium.put(ObjectKey.IS_DEFAULT_SIZE, true);
large = BuildUtilities.createSize("Large", 5);
huge = BuildUtilities.createSize("Huge", 6);
gargantuan = BuildUtilities.createSize("Gargantuan", 7);
colossal = BuildUtilities.createSize("Colossal", 8);
context = Globals.getContext();
create(Language.class, "Common");
BuildUtilities.createFact(context, "ClassType", PCClass.class);
FactDefinition<?, String> fd = BuildUtilities.createFact(context, "SpellType", PCClass.class);
fd.setSelectable(true);
context.getReferenceContext().importObject(AbilityCategory.FEAT);
SourceFileLoader.createLangBonusObject(Globals.getContext());
}
use of pcgen.core.PCStat in project pcgen by PCGen.
the class UnlockedStatFacet method dataAdded.
/**
* Adds a PCStat to this facet if the PCStat was unlocked by a CDOMObject
* which has been added to a Player Character.
*
* Triggered when one of the Facets to which UnlockedStatFacet listens fires
* a DataFacetChangeEvent to indicate a CDOMObject was added to a Player
* Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
CDOMObject cdo = dfce.getCDOMObject();
List<CDOMSingleRef<PCStat>> unlocked = cdo.getListFor(ListKey.UNLOCKED_STATS);
if (unlocked != null) {
CharID charID = dfce.getCharID();
for (CDOMSingleRef<PCStat> ref : unlocked) {
add(charID, ref.get(), cdo);
}
}
}
use of pcgen.core.PCStat in project pcgen by PCGen.
the class CharacterFacadeImpl method updateScorePurchasePool.
/**
* This method updates the purchase point pool and the stat total text. The
* stat total text will be updated whether we are in purchase mode or not.
* displayed
* @param checkPurchasePoints boolean true if the pool should be checked
* for available points before doing the update.
*/
private void updateScorePurchasePool(boolean checkPurchasePoints) {
int usedStatPool = getUsedStatPool();
// Handle purchase mode for stats
if (SettingsHandler.getGame().isPurchaseStatMode()) {
// Let them dink on stats at 0th or 1st PC levels
if (canChangePurchasePool()) {
theCharacter.setCostPool(usedStatPool);
theCharacter.setPoolAmount(usedStatPool);
}
final String bString = Integer.toString(theCharacter.getCostPool());
// int availablePool = SettingsHandler.getPurchaseModeMethodPool();
int availablePool = theCharacter.getPointBuyPoints();
if (availablePool < 0) {
availablePool = RollingMethods.roll(SettingsHandler.getGame().getPurchaseModeMethodPoolFormula());
theCharacter.setPointBuyPoints(availablePool);
}
if (availablePool != 0) {
statTotalLabelText.set(LanguageBundle.getFormattedString("in_sumStatCost", //$NON-NLS-1$
SettingsHandler.getGame().getPurchaseModeMethodName()));
statTotalText.set(LanguageBundle.getFormattedString("in_sumStatPurchaseDisplay", bString, //$NON-NLS-1$
availablePool));
modTotalLabelText.set("");
modTotalText.set("");
}
if (checkPurchasePoints && (availablePool != 0)) {
//
if (canChangePurchasePool() && (availablePool > 0) && (usedStatPool > availablePool)) {
delegate.showInfoMessage(Constants.APPLICATION_NAME, LanguageBundle.getFormattedString(//$NON-NLS-1$
"in_sumYouHaveExcededTheMaximumPointsOf", String.valueOf(availablePool), SettingsHandler.getGame().getPurchaseModeMethodName()));
}
}
}
// Non-purchase mode for stats
if (!SettingsHandler.getGame().isPurchaseStatMode() || (theCharacter.getPointBuyPoints() == 0)) {
int statTotal = 0;
int modTotal = 0;
for (PCStat aStat : charDisplay.getStatSet()) {
if (charDisplay.isNonAbility(aStat) || !aStat.getSafe(ObjectKey.ROLLED)) {
continue;
}
final int currentStat = theCharacter.getBaseStatFor(aStat);
final int currentMod = theCharacter.getStatModFor(aStat);
statTotal += currentStat;
modTotal += currentMod;
}
//$NON-NLS-1$
statTotalLabelText.set(LanguageBundle.getString("in_sumStatTotalLabel"));
statTotalText.set(LanguageBundle.getFormattedString("in_sumStatTotal", Integer.toString(statTotal)));
modTotalLabelText.set(LanguageBundle.getString("in_sumModTotalLabel"));
modTotalText.set(LanguageBundle.getFormattedString("in_sumModTotal", Integer.toString(modTotal)));
}
if (charLevelsFacade.getSize() == 0 && (allAbilitiesAreZero() || (SettingsHandler.getGame().isPurchaseStatMode() && (theCharacter.getPointBuyPoints() != getUsedStatPool())))) {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Ability Scores", "in_sumTodoStats", 50));
} else {
todoManager.removeTodo("in_sumTodoStats");
}
}
use of pcgen.core.PCStat in project pcgen by PCGen.
the class CharacterFacadeImpl method getScoreRaceBonus.
/**
* @see pcgen.core.facade.CharacterFacade#getScoreRaceBonus(pcgen.core.facade.StatFacade)
*/
@Override
public int getScoreRaceBonus(StatFacade stat) {
if (!(stat instanceof PCStat)) {
return 0;
}
PCStat activeStat = (PCStat) stat;
if (charDisplay.isNonAbility(activeStat)) {
return 0;
}
//return Integer.valueOf(currentStatAnalysis.getTotalStatFor(aStat) - currentStatAnalysis.getBaseStatFor(aStat));
//$NON-NLS-1$
int rBonus = (int) theCharacter.getRaceBonusTo("STAT", activeStat.getKeyName());
rBonus += (int) theCharacter.getBonusDueToType("STAT", activeStat.getKeyName(), "RACIAL");
return rBonus;
}
Aggregations