@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)); }
@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)); }
@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)); }
@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)); }
@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)); }
@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)); }
@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)); }
@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)); }
@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)); }