Search in sources :

Example 46 with PCStat

use of pcgen.core.PCStat in project pcgen by PCGen.

the class DefineStatLst method unparse.

@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
    Changes<StatLock> lockChanges = context.getObjectContext().getListChanges(obj, ListKey.STAT_LOCKS);
    Changes<CDOMSingleRef<PCStat>> ulchanges = context.getObjectContext().getListChanges(obj, ListKey.UNLOCKED_STATS);
    Changes<CDOMSingleRef<PCStat>> nonStatChanges = context.getObjectContext().getListChanges(obj, ListKey.NONSTAT_STATS);
    Changes<CDOMSingleRef<PCStat>> nonStatToStatChanges = context.getObjectContext().getListChanges(obj, ListKey.NONSTAT_TO_STAT_STATS);
    Changes<StatLock> minValueChanges = context.getObjectContext().getListChanges(obj, ListKey.STAT_MINVALUE);
    Changes<StatLock> maxValueChanges = context.getObjectContext().getListChanges(obj, ListKey.STAT_MAXVALUE);
    TreeSet<String> set = new TreeSet<>();
    if (lockChanges != null && !lockChanges.isEmpty()) {
        if (lockChanges.includesGlobalClear()) {
            context.addWriteMessage("DEFINE:LOCK does not support .CLEAR");
            return null;
        }
        if (lockChanges.hasAddedItems()) {
            for (StatLock sl : lockChanges.getAdded()) {
                set.add("LOCK|" + sl.getLSTformat() + Constants.PIPE + sl.getLockValue());
            }
        }
    }
    if (ulchanges != null && !ulchanges.isEmpty()) {
        if (ulchanges.includesGlobalClear()) {
            context.addWriteMessage("DEFINE:UNLOCK " + "does not support .CLEAR");
            return null;
        }
        if (ulchanges.hasAddedItems()) {
            for (CDOMSingleRef<PCStat> st : ulchanges.getAdded()) {
                set.add("UNLOCK|" + st.getLSTformat(false));
            }
        }
    }
    if (nonStatChanges != null && !nonStatChanges.isEmpty()) {
        if (nonStatChanges.hasAddedItems()) {
            for (CDOMSingleRef<PCStat> st : nonStatChanges.getAdded()) {
                set.add("NONSTAT|" + st.getLSTformat(false));
            }
        }
    }
    if (nonStatToStatChanges != null && !nonStatToStatChanges.isEmpty()) {
        if (nonStatToStatChanges.hasAddedItems()) {
            for (CDOMSingleRef<PCStat> st : nonStatToStatChanges.getAdded()) {
                set.add("STAT|" + st.getLSTformat(false));
            }
        }
    }
    if (minValueChanges != null && !minValueChanges.isEmpty()) {
        if (minValueChanges.hasAddedItems()) {
            for (StatLock sl : minValueChanges.getAdded()) {
                set.add("MINVALUE|" + sl.getLSTformat() + Constants.PIPE + sl.getLockValue());
            }
        }
    }
    if (maxValueChanges != null && !maxValueChanges.isEmpty()) {
        if (maxValueChanges.hasAddedItems()) {
            for (StatLock sl : maxValueChanges.getAdded()) {
                set.add("MAXVALUE|" + sl.getLSTformat() + Constants.PIPE + sl.getLockValue());
            }
        }
    }
    if (set.isEmpty()) {
        return null;
    }
    return set.toArray(new String[set.size()]);
}
Also used : TreeSet(java.util.TreeSet) PCStat(pcgen.core.PCStat) CDOMSingleRef(pcgen.cdom.reference.CDOMSingleRef) StatLock(pcgen.cdom.helper.StatLock)

Example 47 with PCStat

use of pcgen.core.PCStat in project pcgen by PCGen.

the class GlobalQualifyTest method testFromStat.

@Override
@Test
public void testFromStat() throws PersistenceLayerException {
    PCStat source = create(PCStat.class, "Source");
    ParseResult result = token.parseToken(context, source, "RACE|Dwarf");
    assertFalse(result.passed());
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCStat(pcgen.core.PCStat) Test(org.junit.Test) AbstractContentTokenTest(tokencontent.testsupport.AbstractContentTokenTest)

Example 48 with PCStat

use of pcgen.core.PCStat in project pcgen by PCGen.

the class PcgSystemInitiative method getBonus.

@Override
public int getBonus() {
    String initiativeVar = ControlUtilities.getControlToken(Globals.getContext(), CControl.INITIATIVE);
    String initiativeStatVar = ControlUtilities.getControlToken(Globals.getContext(), CControl.INITIATIVESTAT);
    if (initiativeVar == null) {
        PCStat dex = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCStat.class, "DEX");
        return display.processOldInitiativeMod() - pc.getStatModFor(dex) + incrementalBonus;
    }
    return ((Number) pc.getGlobal(initiativeVar)).intValue() - ((Number) pc.getGlobal(initiativeStatVar)).intValue() + incrementalBonus;
}
Also used : PCStat(pcgen.core.PCStat)

Example 49 with PCStat

use of pcgen.core.PCStat in project pcgen by PCGen.

the class PlayerCharacterOutput method getInitMiscMod.

String getInitMiscMod() {
    String initiativeVar = ControlUtilities.getControlToken(Globals.getContext(), CControl.INITIATIVEMISC);
    if (initiativeVar == null) {
        PCStat dex = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCStat.class, "DEX");
        int statMod = pc.getStatModFor(dex);
        return "+" + (display.processOldInitiativeMod() - statMod);
    }
    return Delta.toString(((Number) pc.getGlobal(initiativeVar)).intValue());
}
Also used : PCStat(pcgen.core.PCStat)

Example 50 with PCStat

use of pcgen.core.PCStat in project pcgen by PCGen.

the class NPCGenerator method generateStats.

private void generateStats(final PlayerCharacter aPC, final PCClass aClass, final RollMethod aRollMethod) {
    final List<PCStat> statOrder = getStatWeights(aPC, aClass);
    //$NON-NLS-1$
    Logging.debugPrint("NPCGenerator: Stat order is " + statOrder);
    aPC.rollStats(Constants.CHARACTER_STAT_METHOD_ROLLED, statOrder, aRollMethod, true);
    for (PCStat stat : aPC.getStatSet()) {
        Logging.debugPrint("NPCGenerator: Setting stat " + stat.getKeyName() + " to " + //$NON-NLS-1$//$NON-NLS-2$
        aPC.getStat(stat));
        aPC.setStat(stat, aPC.getStat(stat));
    }
}
Also used : PCStat(pcgen.core.PCStat)

Aggregations

PCStat (pcgen.core.PCStat)78 CDOMObject (pcgen.cdom.base.CDOMObject)10 GameMode (pcgen.core.GameMode)10 Before (org.junit.Before)9 Race (pcgen.core.Race)9 PCClass (pcgen.core.PCClass)7 PlayerCharacter (pcgen.core.PlayerCharacter)7 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)7 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)6 PCTemplate (pcgen.core.PCTemplate)6 Skill (pcgen.core.Skill)6 ArrayList (java.util.ArrayList)5 StatLock (pcgen.cdom.helper.StatLock)5 BonusObj (pcgen.core.bonus.BonusObj)5 Test (org.junit.Test)4 Formula (pcgen.base.formula.Formula)4 CharID (pcgen.cdom.enumeration.CharID)4 LoadContext (pcgen.rules.context.LoadContext)4 StringTokenizer (java.util.StringTokenizer)3 Type (pcgen.cdom.enumeration.Type)3