Search in sources :

Example 1 with Gender

use of pcgen.cdom.enumeration.Gender in project pcgen by PCGen.

the class CharacterFacadeImpl method setGender.

/**
	 * @see pcgen.core.facade.CharacterFacade#setGender(pcgen.cdom.enumeration.Gender)
	 */
@Override
public void setGender(GenderFacade gender) {
    theCharacter.setGender((Gender) gender);
    Gender newGender = charDisplay.getGenderObject();
    this.selectedGender = newGender.toString();
    this.gender.set(newGender);
    refreshLanguageList();
}
Also used : Gender(pcgen.cdom.enumeration.Gender)

Example 2 with Gender

use of pcgen.cdom.enumeration.Gender in project pcgen by PCGen.

the class Configuration method getGenderOptions.

public List<GenderGeneratorOption> getGenderOptions() {
    final List<GenderGeneratorOption> ret = new ArrayList<>();
    for (final GeneratorOption opt : theGeneratorOptions) {
        if (opt instanceof GenderGeneratorOption) {
            ret.add((GenderGeneratorOption) opt);
        }
    }
    for (final Gender gender : Gender.values()) {
        final GenderGeneratorOption opt = new GenderGeneratorOption();
        opt.setName(gender.toString());
        opt.addChoice(1, gender.toString());
        ret.add(opt);
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) Gender(pcgen.cdom.enumeration.Gender)

Example 3 with Gender

use of pcgen.cdom.enumeration.Gender in project pcgen by PCGen.

the class GenderToken method unparse.

@Override
public String[] unparse(LoadContext context, KitBio kitGender) {
    Collection<Gender> genders = kitGender.getGenders();
    if (genders == null) {
        return null;
    }
    String[] g = new String[genders.size()];
    int i = 0;
    for (Gender gender : genders) {
        g[i++] = gender.name();
    }
    return new String[] { StringUtil.join(g, Constants.PIPE) };
}
Also used : Gender(pcgen.cdom.enumeration.Gender)

Example 4 with Gender

use of pcgen.cdom.enumeration.Gender in project pcgen by PCGen.

the class NPCGenerator method generate.

/**
	 * Generate a new NPC
	 * 
	 * @param aPC The PlayerCharacter to fill in options for
	 * @param align Alignment options to choose from
	 * @param aRace Race options to choose from
	 * @param aGender Gender options to choose from
	 * @param classList <tt>List</tt> of class options to choose from
	 * @param levels <tt>List</tt> of level choices
	 * @param aRollMethod the RollMethod to use for stats
	 */
public void generate(final PlayerCharacter aPC, final AlignGeneratorOption align, final RaceGeneratorOption aRace, final GenderGeneratorOption aGender, final List<ClassGeneratorOption> classList, final List<LevelGeneratorOption> levels, final RollMethod aRollMethod) {
    // Force a more quiet process
    ChooserFactory.pushChooserClassname(//$NON-NLS-1$
    "pcgen.util.chooser.RandomChooser");
    boolean tempShowHP = SettingsHandler.getShowHPDialogAtLevelUp();
    SettingsHandler.setShowHPDialogAtLevelUp(false);
    int tempChoicePref = UIPropertyContext.getSingleChoiceAction();
    UIPropertyContext.setSingleChoiceAction(Constants.CHOOSER_SINGLE_CHOICE_METHOD_SELECT_EXIT);
    try {
        final int MAX_RETRIES = 5;
        for (int i = 0; i < MAX_RETRIES; i++) {
            PCAlignment randAlign = getAlignment(align);
            if (randAlign != null) {
                Logging.debugPrint(//$NON-NLS-1$//$NON-NLS-2$
                "NPCGenerator: Selected " + randAlign + " for alignment " + align);
                aPC.setAlignment(randAlign);
            }
            final Race r = getRace(aRace);
            if (r == null) {
                //$NON-NLS-1$
                Logging.debugPrint("NPCGenerator: Got null race.  Retrying.");
                continue;
            }
            //$NON-NLS-1$ //$NON-NLS-2$
            Logging.debugPrint("NPCGenerator: Selected " + r + " for race " + aRace);
            if (r.qualifies(aPC, r)) {
                //$NON-NLS-1$
                Logging.debugPrint("NPCGenerator: PC qualifies for race " + r);
                aPC.setRace(r);
                break;
            }
        }
        if (aPC.getRace() == Globals.s_EMPTYRACE) {
            Logging.errorPrint("Unable to select race");
            return;
        }
        final Gender gender = getGender(aGender);
        //$NON-NLS-1$ //$NON-NLS-2$
        Logging.debugPrint("NPCGenerator: Selecting " + gender + " for gender " + aGender);
        aPC.setGender(gender);
        boolean doneRacialClasses = false;
        for (int i = 0; i < classList.size(); i++) {
            int numLevels = getLevel(levels.get(i));
            //$NON-NLS-1$ //$NON-NLS-2$
            Logging.debugPrint("NPCGenerator: Selecting " + numLevels + " for level " + levels.get(i));
            PCClass aClass = null;
            if (!doneRacialClasses && aPC.hasClass()) {
                aClass = aPC.getClassList().get(0);
                numLevels = aPC.getLevel(aClass);
                doneRacialClasses = true;
                i--;
            } else {
                doneRacialClasses = true;
                for (; ; ) {
                    aClass = getClass(classList.get(i));
                    if (aClass == null) {
                        break;
                    }
                    if (aClass.getSafe(ObjectKey.VISIBILITY).equals(Visibility.DEFAULT) && aClass.qualifies(aPC, aClass)) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        Logging.debugPrint("NPCGenerator: Selecting " + aClass + " for class " + classList.get(i));
                        break;
                    }
                    // TODO Remove a failed class from the list.
                    Logging.errorPrint("Counld not add a level of " + aClass);
                    aClass = null;
                    break;
                }
            }
            if (aClass == null) {
                continue;
            }
            final PCClass classCopy = aClass.clone();
            if (classCopy.containsListFor(ListKey.SUB_CLASS)) {
                selectSubClass(aPC, classCopy);
            }
            if (i == 0) {
                generateStats(aPC, classCopy, aRollMethod);
                selectDeity(aPC, classCopy);
            }
            int highestSpellLevel = aPC.getSpellSupport(aClass).getHighestLevelSpell(aPC);
            final int[] selectedSpells = new int[highestSpellLevel + 1];
            for (int k = 0; k < highestSpellLevel; k++) {
                selectedSpells[k] = 0;
            }
            final int[] bonusSpells = new int[highestSpellLevel + 1];
            for (int k = 0; k < highestSpellLevel; k++) {
                bonusSpells[k] = 0;
            }
            // Make a copy of the list because we are going to modify it.
            WeightedCollection<SkillChoice> skillList = new WeightedCollection<>(getSkillWeights(classCopy, aPC));
            WeightedCollection<Ability> featList = new WeightedCollection<>(getFeatWeights(classCopy));
            for (int j = 0; j < numLevels; j++) {
                if (i >= 0) {
                    aPC.incrementClassLevel(1, classCopy, true);
                }
                final PCClass pcClass = aPC.getClassKeyed(classCopy.getKeyName());
                selectSkills(aPC, skillList, pcClass, j + 1);
                selectFeats(aPC, featList);
                selectDomains(aPC, pcClass);
                if (pcClass.get(FactKey.valueOf("SpellType")) != null) {
                    // spells of some sort (known or prepared).
                    if (aPC.getSpellSupport(pcClass).hasKnownList() || aPC.getSpellSupport(pcClass).hasKnownSpells(aPC)) {
                        //$NON-NLS-1$
                        Logging.debugPrint("NPCGenerator: known spells to select");
                        for (int lvl = 0; lvl <= highestSpellLevel; ++lvl) {
                            if (aPC.availableSpells(lvl, pcClass, Globals.getDefaultSpellBook(), true, true)) {
                                final int a = aPC.getSpellSupport(pcClass).getKnownForLevel(lvl, aPC);
                                //final int bonus = aPC.getSpellSupport(pcClass).getSpecialtyKnownForLevel(lvl, aPC);
                                //$NON-NLS-1$ //$NON-NLS-2$
                                Logging.debugPrint("NPCGenerator: " + a + "known spells to select");
                                final WeightedCollection<Spell> spellChoices = getKnownSpellWeights(aPC, pcClass, lvl);
                                final int numToSelect = a - selectedSpells[lvl];
                                for (int sp = 0; sp < numToSelect; sp++) {
                                    selectSpell(aPC, pcClass, null, Globals.getDefaultSpellBook(), spellChoices, lvl);
                                    selectedSpells[lvl]++;
                                }
                            }
                        }
                    } else {
                        // Prepared spells?
                        //$NON-NLS-1$
                        Logging.debugPrint("NPCGenerator: prepared spells to select");
                        aPC.addSpellBook("Prepared Spells");
                        for (int lvl = 0; lvl <= highestSpellLevel; ++lvl) {
                            final int castTot = aPC.getSpellSupport(pcClass).getCastForLevel(lvl, "Prepared Spells", true, true, aPC);
                            final int castNon = aPC.getSpellSupport(pcClass).getCastForLevel(lvl, "Prepared Spells", false, true, aPC);
                            final int castSpec = castTot - castNon;
                            //$NON-NLS-1$ //$NON-NLS-2$
                            Logging.debugPrint("NPCGenerator: " + castTot + "+" + castSpec + " prepared spells to select");
                            if (castSpec - bonusSpells[lvl] > 0) {
                                selectDomainSpell(aPC, pcClass, lvl);
                                bonusSpells[lvl]++;
                            }
                            if (castTot > 0) {
                                final WeightedCollection<Spell> spellChoices = getPreparedSpellWeights(aPC, pcClass, lvl);
                                final int numToSelect = castNon - selectedSpells[lvl];
                                for (int sp = 0; sp < numToSelect; sp++) {
                                    selectSpell(aPC, pcClass, null, "Prepared Spells", spellChoices, lvl);
                                    selectedSpells[lvl]++;
                                }
                            }
                        }
                    }
                }
            }
        }
        //$NON-NLS-1$
        final String randBioString = "EYES.HAIR.SKIN.HT.WT.AGE.";
        aPC.getBioSet().randomize(randBioString, aPC);
        final List<String> globalHairStyleList = SystemCollections.getUnmodifiableHairStyleList();
        aPC.setPCAttribute(PCAttribute.HAIRSTYLE, globalHairStyleList.get(RandomUtil.getRandomInt(globalHairStyleList.size())));
        final List<String> speechList = SystemCollections.getUnmodifiableSpeechList();
        aPC.setPCAttribute(PCAttribute.SPEECHTENDENCY, speechList.get(RandomUtil.getRandomInt(speechList.size())));
        final List<String> globalPhobiaList = SystemCollections.getUnmodifiablePhobiaList();
        aPC.setPCAttribute(PCAttribute.PHOBIAS, globalPhobiaList.get(RandomUtil.getRandomInt(globalPhobiaList.size())));
        final List<String> globalInterestsList = SystemCollections.getUnmodifiableInterestsList();
        aPC.setPCAttribute(PCAttribute.INTERESTS, globalInterestsList.get(RandomUtil.getRandomInt(globalInterestsList.size())));
        final List<String> globalPhraseList = SystemCollections.getUnmodifiablePhraseList();
        aPC.setPCAttribute(PCAttribute.CATCHPHRASE, globalPhraseList.get(RandomUtil.getRandomInt(globalPhraseList.size())));
        final List<String> globalTraitList = SystemCollections.getUnmodifiableTraitList();
        // TODO: it is possible for trait1 == trait2
        aPC.setPCAttribute(PCAttribute.PERSONALITY1, globalTraitList.get(RandomUtil.getRandomInt(globalTraitList.size())));
        aPC.setPCAttribute(PCAttribute.PERSONALITY2, globalTraitList.get(RandomUtil.getRandomInt(globalTraitList.size())));
        final List<String> globalCityList = SystemCollections.getUnmodifiableCityList();
        aPC.setPCAttribute(PCAttribute.RESIDENCE, globalCityList.get(RandomUtil.getRandomInt(globalCityList.size())));
        final List<String> globalLocationList = SystemCollections.getUnmodifiableLocationList();
        aPC.setPCAttribute(PCAttribute.LOCATION, globalLocationList.get(RandomUtil.getRandomInt(globalLocationList.size())));
        final List<String> globalBirthplaceList = SystemCollections.getUnmodifiableBirthplaceList();
        aPC.setPCAttribute(PCAttribute.BIRTHPLACE, globalBirthplaceList.get(RandomUtil.getRandomInt(globalBirthplaceList.size())));
    //TODO: Link in with the doomsday book name generator
    //			final Names nameGen = Names.getInstance();
    //			nameGen.init(aNameChoice, aPC);
    //			aPC.setName(nameGen.getRandomName());
    } catch (Exception e) {
        Logging.errorPrint("Problem generation NPC", e);
    } finally {
        SettingsHandler.setShowHPDialogAtLevelUp(tempShowHP);
        UIPropertyContext.setSingleChoiceAction(tempChoicePref);
        ChooserFactory.popChooserClassname();
    }
}
Also used : Ability(pcgen.core.Ability) Gender(pcgen.cdom.enumeration.Gender) PCClass(pcgen.core.PCClass) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) PCAlignment(pcgen.core.PCAlignment) WeightedCollection(pcgen.base.util.WeightedCollection) Race(pcgen.core.Race)

Example 5 with Gender

use of pcgen.cdom.enumeration.Gender 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;
}
Also used : StatFacade(pcgen.facade.core.StatFacade) GenderFacade(pcgen.facade.core.GenderFacade) TemplateFacet(pcgen.cdom.facet.model.TemplateFacet) Handed(pcgen.cdom.enumeration.Handed) Gender(pcgen.cdom.enumeration.Gender) HandedFacade(pcgen.facade.core.HandedFacade) XPFacet(pcgen.cdom.facet.fact.XPFacet) GameMode(pcgen.core.GameMode) PCStat(pcgen.core.PCStat) File(java.io.File) LanguageFacet(pcgen.cdom.facet.model.LanguageFacet) AutoEquipmentFacet(pcgen.cdom.facet.AutoEquipmentFacet)

Aggregations

Gender (pcgen.cdom.enumeration.Gender)6 File (java.io.File)1 ArrayList (java.util.ArrayList)1 WeightedCollection (pcgen.base.util.WeightedCollection)1 Handed (pcgen.cdom.enumeration.Handed)1 AutoEquipmentFacet (pcgen.cdom.facet.AutoEquipmentFacet)1 XPFacet (pcgen.cdom.facet.fact.XPFacet)1 LanguageFacet (pcgen.cdom.facet.model.LanguageFacet)1 TemplateFacet (pcgen.cdom.facet.model.TemplateFacet)1 Ability (pcgen.core.Ability)1 GameMode (pcgen.core.GameMode)1 PCAlignment (pcgen.core.PCAlignment)1 PCClass (pcgen.core.PCClass)1 PCStat (pcgen.core.PCStat)1 Race (pcgen.core.Race)1 CharacterSpell (pcgen.core.character.CharacterSpell)1 Spell (pcgen.core.spell.Spell)1 GenderFacade (pcgen.facade.core.GenderFacade)1 HandedFacade (pcgen.facade.core.HandedFacade)1 StatFacade (pcgen.facade.core.StatFacade)1