示例#1
0
 @Test
 public void testWithNothingInRaceDefaultsTo2() {
   rfacet.set(id, new Race());
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
   assertEquals(2, facet.racialSizeInt(id));
   rfacet.remove(id);
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
   assertEquals(2, facet.racialSizeInt(id));
 }
示例#2
0
 @Test
 public void testGetWithBonus() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
   bonusInfo.put(altid, 2.0);
   // No pollution
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
   bonusInfo.put(id, 2.0);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(0));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals(4, facet.sizeInt(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
   bonusInfo.clear();
   facet.update(id);
   assertEquals(0, facet.sizeInt(id));
 }
示例#3
0
 @Test
 public void testGetFromRace() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
 }
示例#4
0
 @Test
 public void testAvoidPollution() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals(2, facet.sizeInt(altid));
   assertEquals(2, facet.racialSizeInt(altid));
 }
示例#5
0
 @Test
 public void testGetFromTemplateHigherOverridesDefault() {
   rfacet.set(id, new Race());
   PCTemplate t1 = new PCTemplate();
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
   tfacet.remove(id, t1, this);
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
 }
示例#6
0
 @Test
 public void testGetFromTemplateLowerOverridesRace() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   rfacet.set(id, r);
   PCTemplate t1 = new PCTemplate();
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
   tfacet.remove(id, t1, this);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
 }
示例#7
0
 @Test
 public void testGetAbbWithBonus() {
   assertEquals("M", facet.getSizeAbb(id));
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   bonusInfo.put(altid, 2.0);
   // No pollution
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   bonusInfo.put(id, 2.0);
   facet.update(id);
   assertEquals("L", facet.getSizeAbb(id));
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(0));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals("H", facet.getSizeAbb(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   bonusInfo.put(id, -2.0);
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   facet.update(id);
   assertEquals("T", facet.getSizeAbb(id));
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(4));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals("T", facet.getSizeAbb(id));
   bonusInfo.clear();
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
 }
示例#8
0
  /**
   * 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;
  }
示例#9
0
  /**
   * Returns the Face of the Player Character represented by the given CharID. The Face is a
   * Point2D, where the X value of the Point represents the front/rear facing size and the Y value
   * of the Point represents the left/right side facing size.
   *
   * @param id The CharID representing the Player Character for which the Face will be returned
   * @return The Face of the Player Character represented by the given CharID
   */
  public Point2D.Double getFace(CharID id) {
    final Race aRace = raceFacet.get(id);
    // Default to 5' by 5'
    Point2D.Double face = new Point2D.Double(5, 0);
    if (aRace != null) {
      Point2D.Double rf = getFace(aRace);
      if (rf != null) {
        face = rf;
      }
    }

    // Scan templates for any overrides
    for (PCTemplate template : templateFacet.getSet(id)) {
      Point2D.Double tf = getFace(template);
      if (tf != null) {
        face = tf;
      }
    }
    return face;
  }
示例#10
0
 @Test
 public void testGetAbbWithLevelProgression() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   fakeLevels = 6;
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 2);
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   r.removeListFor(ListKey.HITDICE_ADVANCEMENT);
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 2);
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 5);
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 6);
   facet.update(id);
   assertEquals("L", facet.getSizeAbb(id));
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(0));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals("H", facet.getSizeAbb(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   r.removeListFor(ListKey.HITDICE_ADVANCEMENT);
   facet.update(id);
   assertEquals("T", facet.getSizeAbb(id));
 }
示例#11
0
 @Test
 public void testGetFromTemplateSecondOverrides() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t1, this);
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(4));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals(4, facet.sizeInt(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
   tfacet.remove(id, t1, this);
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
 }
示例#12
0
 /**
  * Initializes the connections for StartingLanguageFacet to other facets.
  *
  * <p>This method is automatically called by the Spring framework during initialization of the
  * StartingLanguageFacet.
  */
 public void init() {
   raceFacet.addDataFacetChangeListener(this);
   templateFacet.addDataFacetChangeListener(this);
   conditionalTemplateFacet.addDataFacetChangeListener(this);
   classFacet.addDataFacetChangeListener(this);
 }