@Test
  public void testGetSet() throws PersistenceLayerException {
    setUpPC();
    TransparentPlayerCharacter pc = new TransparentPlayerCharacter();
    initializeObjects();
    assertTrue(parse(getSubTokenName() + "|EXCLUSIVE[ALL]"));

    finishLoad();

    ChooseInformation<?> info = primaryProf.get(ObjectKey.CHOOSE_INFO);
    pc.classSet.add(cl1);
    Collection<?> set = info.getSet(pc);
    assertEquals(2, set.size());
    assertTrue(set.contains(s4));
    assertTrue(set.contains(s5));
    pc.skillSet.put(s1, 2);
    pc.skillSet.put(s2, 0);
    set = info.getSet(pc);
    assertEquals(2, set.size());
    assertTrue(set.contains(s4));
    assertTrue(set.contains(s5));
    pc.classSkillSet.add(s4);
    pc.crossClassSkillSet.add(s5);
    set = info.getSet(pc);
    assertTrue(set.isEmpty());
  }
Ejemplo n.º 2
0
  @Test
  public void testGetSetFiltered() throws PersistenceLayerException {
    setUpPC();
    TransparentPlayerCharacter pc = new TransparentPlayerCharacter();
    initializeObjects();
    assertTrue(parse(getSubTokenName() + "|CROSSCLASS[TYPE=Masterful]"));

    finishLoad();

    ChooseInformation<?> info = primaryProf.get(ObjectKey.CHOOSE_INFO);
    pc.classSet.add(cl1);
    Collection<?> set = info.getSet(pc);
    assertEquals(2, set.size());
    assertTrue(set.contains(s2));
    assertTrue(set.contains(s3));
    pc.skillCostMap.put(s2, cl1, SkillCost.CLASS);
    set = info.getSet(pc);
    assertFalse(set.isEmpty());
    assertEquals(1, set.size());
    assertTrue(set.contains(s3));
    pc.skillCostMap.put(s4, cl1, SkillCost.CROSS_CLASS);
    pc.skillCostMap.put(s5, cl1, SkillCost.CROSS_CLASS);
    set = info.getSet(pc);
    assertFalse(set.isEmpty());
    assertEquals(2, set.size());
    assertTrue(set.contains(s3));
    assertTrue(set.contains(s4));
  }
Ejemplo n.º 3
0
 @Override
 public String[] unparse(LoadContext context, CDOMObject cdo) {
   ChooseInformation<?> tc = context.getObjectContext().getObject(cdo, ObjectKey.CHOOSE_INFO);
   if (tc == null) {
     return null;
   }
   if (!tc.getName().equals(getTokenName())) {
     // Don't unparse anything that isn't owned by this SecondaryToken
     /*
      * TODO Either this really needs to be a check against the subtoken
      * (which thus needs to be stored in the ChooseInfo) or there needs
      * to be a loadtime check that no more than once CHOOSE subtoken
      * uses the same AssociationListKey... :P
      */
     return null;
   }
   if (!tc.getGroupingState().isValid()) {
     context.addWriteMessage(
         "Invalid combination of objects"
             + " was used in: "
             + getParentToken()
             + ":"
             + getTokenName());
     return null;
   }
   StringBuilder sb = new StringBuilder();
   sb.append(tc.getLSTformat());
   String title = tc.getTitle();
   if (!title.equals(getDefaultTitle())) {
     sb.append("|TITLE=");
     sb.append(title);
   }
   return new String[] {sb.toString()};
 }