Search in sources :

Example 86 with Race

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

the class SizeFacet method update.

/**
	 * Forces a complete update of the size information for the Player Character
	 * identified by the given CharID.
	 * 
	 * @param id
	 *            The CharID indicating the Player Character on which to update
	 *            the size information
	 */
public void update(CharID id) {
    SizeFacetInfo info = getConstructingInfo(id);
    int iSize = calcRacialSizeInt(id);
    Race race = raceFacet.get(id);
    if (race != null) {
        // Now check and see if a class has modified
        // the size of the character with something like:
        // BONUS:SIZEMOD|NUMBER|+1
        iSize += (int) bonusCheckingFacet.getBonus(id, "SIZEMOD", "NUMBER");
        // Now see if there is a HD advancement in size
        // (Such as for Dragons)
        iSize += sizesToAdvance(id, race);
        //
        // Must still be a valid size
        //
        int maxIndex = Globals.getContext().getReferenceContext().getConstructedObjectCount(SIZEADJUSTMENT_CLASS) - 1;
        iSize = Math.min(maxIndex, Math.max(0, iSize));
    }
    info.sizeInt = iSize;
    SizeAdjustment oldSize = info.sizeAdj;
    SizeAdjustment newSize = Globals.getContext().getReferenceContext().getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER).get(sizeInt(id));
    info.sizeAdj = newSize;
    if (oldSize != newSize) {
        if (oldSize != null) {
            fireDataFacetChangeEvent(id, oldSize, DataFacetChangeEvent.DATA_REMOVED);
        }
        fireDataFacetChangeEvent(id, newSize, DataFacetChangeEvent.DATA_ADDED);
    }
}
Also used : Race(pcgen.core.Race) SizeAdjustment(pcgen.core.SizeAdjustment)

Example 87 with Race

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

the class ReachFacet method getReach.

/**
	 * Returns the Reach for a Player Character represented by the given CharID.
	 * 
	 * @param id
	 *            The CharID representing the Player Character for which the
	 *            Reach should be returned.
	 * @return The Reach for the Player Character represented by the given
	 *         CharID
	 */
public int getReach(CharID id) {
    final Race aRace = raceFacet.get(id);
    int reach = 0;
    if (aRace != null) {
        reach = aRace.getSafe(IntegerKey.REACH);
    }
    // Scan templates for any overrides
    for (PCTemplate template : templateFacet.getSet(id)) {
        Integer r = template.get(IntegerKey.REACH);
        if (r != null) {
            reach = r;
        }
    }
    reach += (int) bonusCheckingFacet.getBonus(id, "COMBAT", "REACH");
    return reach;
}
Also used : Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate)

Example 88 with Race

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

the class UnarmedDamageFacet method getUDamForRace.

/**
	 * Returns the unarmed damage String for the Race of the Player Character
	 * identified by the given CharID.
	 * 
	 * @param id
	 *            The CharID identifying the Player Character
	 * @return The unarmed damage String for the Race of the Player Character
	 *         identified by the given CharID
	 */
public String getUDamForRace(CharID id) {
    Race race = raceFacet.get(id);
    int iSize = formulaResolvingFacet.resolve(id, race.getSafe(FormulaKey.SIZE), race.getQualifiedKey()).intValue();
    SizeAdjustment defAdj = SizeUtilities.getDefaultSizeAdjustment();
    SizeAdjustment sizAdj = Globals.getContext().getReferenceContext().getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER).get(iSize);
    if (sizAdj != null) {
        return Globals.adjustDamage("1d3", defAdj, sizAdj);
    }
    return "1d3";
}
Also used : Race(pcgen.core.Race) SizeAdjustment(pcgen.core.SizeAdjustment)

Example 89 with Race

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

the class RaceInputFacet method remove.

public void remove(CharID id) {
    Race r = raceFacet.remove(id);
    PlayerCharacter pc = trackingFacet.getPC(id);
    if (pc.isAllowInteraction() && (r != null)) {
        raceSelectionFacet.remove(id, r);
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Race(pcgen.core.Race)

Example 90 with Race

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

the class ChooseLst method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
    if (obj instanceof Ungranted) {
        return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName(), context);
    }
    if (obj instanceof NonInteractive) {
        return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Non-Interactive object type: " + obj.getClass().getSimpleName(), context);
    }
    String key;
    String val;
    int pipeLoc = value.indexOf(Constants.PIPE);
    if (value.startsWith("FEAT=")) {
        key = "FEATEQ";
        val = value.substring(5);
    } else if (value.startsWith("LANGAUTO:")) {
        key = "LANGAUTO";
        val = value.substring(9);
    } else if (pipeLoc == -1) {
        key = value;
        val = null;
    } else {
        key = value.substring(0, pipeLoc);
        val = value.substring(pipeLoc + 1);
    }
    if (!((obj instanceof Ability) || (obj instanceof Domain) || (obj instanceof Race) || (obj instanceof PCTemplate) || (obj instanceof Skill) || (obj instanceof EquipmentModifier))) {
        //Allow TEMPBONUS related choose
        if (!"NUMBER".equals(key)) {
            return new ParseResult.Fail(getTokenName() + " is not supported for " + obj.getClass().getSimpleName(), context);
        }
    }
    if (key.startsWith("NUMCHOICES=")) {
        String maxCount = key.substring(11);
        if (maxCount == null || maxCount.isEmpty()) {
            return new ParseResult.Fail("NUMCHOICES in CHOOSE must be a formula: " + value, context);
        }
        Formula f = FormulaFactory.getFormulaFor(maxCount);
        if (!f.isValid()) {
            return new ParseResult.Fail("Number of Choices in " + getTokenName() + " was not valid: " + f.toString(), context);
        }
        context.getObjectContext().put(obj, FormulaKey.NUMCHOICES, f);
        pipeLoc = val.indexOf(Constants.PIPE);
        if (pipeLoc == -1) {
            key = val;
            val = null;
        } else {
            key = val.substring(0, pipeLoc);
            val = val.substring(pipeLoc + 1);
        }
    }
    return context.processSubToken(obj, getTokenName(), key, val);
}
Also used : Ability(pcgen.core.Ability) Formula(pcgen.base.formula.Formula) Skill(pcgen.core.Skill) EquipmentModifier(pcgen.core.EquipmentModifier) Race(pcgen.core.Race) NonInteractive(pcgen.cdom.base.NonInteractive) Domain(pcgen.core.Domain) PCTemplate(pcgen.core.PCTemplate) Ungranted(pcgen.cdom.base.Ungranted)

Aggregations

Race (pcgen.core.Race)167 Test (org.junit.Test)78 PCTemplate (pcgen.core.PCTemplate)66 PlayerCharacter (pcgen.core.PlayerCharacter)28 CDOMObject (pcgen.cdom.base.CDOMObject)16 LoadContext (pcgen.rules.context.LoadContext)16 PCClass (pcgen.core.PCClass)15 ArrayList (java.util.ArrayList)10 SizeAdjustment (pcgen.core.SizeAdjustment)10 ParseResult (pcgen.rules.persistence.token.ParseResult)10 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)10 PCStat (pcgen.core.PCStat)9 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)8 Equipment (pcgen.core.Equipment)8 BonusObj (pcgen.core.bonus.BonusObj)7 Formula (pcgen.base.formula.Formula)6 WieldCategory (pcgen.core.character.WieldCategory)6 GameMode (pcgen.core.GameMode)5 Skill (pcgen.core.Skill)5 CompanionList (pcgen.cdom.list.CompanionList)4