Ejemplo n.º 1
0
 @Test
 public void testGetFromRace() {
   Race r = new Race();
   r.put(IntegerKey.CREATURE_HANDS, 5);
   rfacet.set(id, r);
   assertEquals(5, facet.getHands(id));
   rfacet.remove(id);
   assertEquals(0, facet.getHands(id));
 }
Ejemplo n.º 2
0
  /**
   * Returns the index of the active AgeSet on the Player Character.
   *
   * <p>In general, use of this method outside of AgeSetFacet is discouraged. If this method is
   * being used, a serious analysis should be taking place to determine if the AgeSet itself (in
   * other words, the get method of AgeSetFacet) can be used instead.
   *
   * @param id The CharID identifying the Player Character for which the index of the active AgeSet
   *     should be returned.
   * @return The index of the active AgeSet on the Player Character.
   */
  public int getAgeSetIndex(CharID id) {
    BioSet bioSet = bioSetFacet.get(id);
    String region = regionFacet.getRegion(id);
    Race race = raceFacet.get(id);
    String raceName = race == null ? "" : race.getKeyName().trim();
    List<String> values = bioSet.getValueInMaps(region, raceName, "BASEAGE");
    if (values == null) {
      return 0;
    }

    int pcAge = ageFacet.getAge(id);
    int ageSet = -1;

    for (String s : values) {
      int setBaseAge = Integer.parseInt(s);

      if (pcAge < setBaseAge) {
        break;
      }

      ++ageSet;
    }

    //
    // Check to see if character is younger than earliest age group
    //
    if (ageSet < 0) {
      ageSet = 0;
    }

    return ageSet;
  }
Ejemplo n.º 3
0
  /**
   * Returns a non-null Collection of the Racial Sub Types for the Player Character represented by
   * the given CharID.
   *
   * <p>This method is value-semantic in that ownership of the returned Collection is transferred to
   * the class calling this method. Modification of the returned Collection will not modify this
   * RacialSubTypesFacet and modification of this RacialSubTypesFacet will not modify the returned
   * Collection. Modifications to the returned Collection will also not modify any future or
   * previous objects returned by this (or other) methods on RacialSubTypesFacet.
   *
   * @param id The CharID representing the Player Character for which the Racial Sub Types should be
   *     returned
   * @return A non-null Collection of the Racial Sub Types for the Player Character represented by
   *     the given CharID
   */
  public Collection<RaceSubType> getRacialSubTypes(CharID id) {
    List<RaceSubType> racialSubTypes = new ArrayList<>();
    Race race = raceFacet.get(id);
    if (race != null) {
      for (RaceSubType st : race.getSafeListFor(ListKey.RACESUBTYPE)) {
        racialSubTypes.add(st);
      }
    }
    Collection<PCTemplate> templates = templateFacet.getSet(id);
    if (!templates.isEmpty()) {
      List<RaceSubType> added = new ArrayList<>();
      List<RaceSubType> removed = new ArrayList<>();
      for (PCTemplate aTemplate : templates) {
        added.addAll(aTemplate.getSafeListFor(ListKey.RACESUBTYPE));
        removed.addAll(aTemplate.getSafeListFor(ListKey.REMOVED_RACESUBTYPE));
      }
      for (RaceSubType st : added) {
        racialSubTypes.add(st);
      }
      for (RaceSubType st : removed) {
        racialSubTypes.remove(st);
      }
    }

    return Collections.unmodifiableList(racialSubTypes);
  }
Ejemplo n.º 4
0
 /**
  * Initializes the connections for AgeSetFacet to other facets.
  *
  * <p>This method is automatically called by the Spring framework during initialization of the
  * AgeSetFacet.
  */
 public void init() {
   raceFacet.addDataFacetChangeListener(this);
   regionFacet.addDataFacetChangeListener(this);
   ageFacet.addDataFacetChangeListener(this);
   bioSetFacet.addDataFacetChangeListener(this);
   OutputDB.register("ageset", this);
 }
Ejemplo n.º 5
0
 @Test
 public void testGetFromTemplateSecondOverrides() {
   Race r = new Race();
   r.put(IntegerKey.CREATURE_HANDS, 5);
   rfacet.set(id, r);
   assertEquals(5, facet.getHands(id));
   PCTemplate t = new PCTemplate();
   t.setName("PCT");
   t.put(IntegerKey.CREATURE_HANDS, 3);
   tfacet.add(id, t, this);
   assertEquals(3, facet.getHands(id));
   PCTemplate t5 = new PCTemplate();
   t5.setName("Other");
   t5.put(IntegerKey.CREATURE_HANDS, 4);
   tfacet.add(id, t5, this);
   assertEquals(4, facet.getHands(id));
   tfacet.remove(id, t, this);
   assertEquals(4, facet.getHands(id));
   tfacet.add(id, t, this);
   assertEquals(3, facet.getHands(id));
   tfacet.remove(id, t, this);
   assertEquals(4, facet.getHands(id));
   tfacet.remove(id, t5, this);
   assertEquals(5, facet.getHands(id));
 }
Ejemplo n.º 6
0
 @Test
 public void testAvoidPollution() {
   Race r = new Race();
   r.put(IntegerKey.CREATURE_HANDS, 5);
   rfacet.set(id, r);
   assertEquals(0, facet.getHands(altid));
 }
Ejemplo n.º 7
0
 @Test
 public void testGetFromTemplate() {
   rfacet.set(id, new Race());
   PCTemplate t = new PCTemplate();
   t.put(IntegerKey.CREATURE_HANDS, 5);
   tfacet.add(id, t, this);
   assertEquals(5, facet.getHands(id));
   tfacet.remove(id, t, this);
   assertEquals(2, facet.getHands(id));
 }
Ejemplo n.º 8
0
 /**
  * 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";
 }
Ejemplo n.º 9
0
 /**
  * Initializes the connections for AgeSetFacet to other facets.
  *
  * <p>This method is automatically called by the Spring framework during initialization of the
  * AgeSetFacet.
  */
 public void init() {
   raceFacet.addDataFacetChangeListener(this);
   regionFacet.addDataFacetChangeListener(this);
   ageFacet.addDataFacetChangeListener(this);
   bioSetFacet.addDataFacetChangeListener(this);
 }
Ejemplo n.º 10
0
 @Test
 public void testWithNothingInRaceDefault2() {
   rfacet.set(id, new Race());
   assertEquals(2, facet.getHands(id));
 }