예제 #1
0
  private static SortedSet<AbstractPlayerPower> loadDatabase() throws Exception {
    if (_pp == null) {
      _pp = new TreeSet<AbstractPlayerPower>();

      FileData fd = DataLoaderService.loadFile("data/military_bonuses.txt");
      Set<String> keys = fd.getKeys();
      for (String key : keys) {
        List<String> data = fd.getList(key);
        int level = Integer.valueOf(data.get(0));
        String name = data.get(1);
        String className = data.get(2);
        List<String> params = data.subList(3, data.size());

        Class<? extends AbstractPlayerPower> clazz =
            (Class<? extends AbstractPlayerPower>)
                Class.forName("com.battlespace.domain.player." + className);
        Constructor<? extends AbstractPlayerPower> constructor = clazz.getConstructor(List.class);
        AbstractPlayerPower cp = constructor.newInstance(params);
        cp.level = level;
        cp.name = name;
        _pp.add(cp);
      }
    }
    return _pp;
  }
예제 #2
0
 public static void upgrade(Booster booster, int militarySkill) throws Exception {
   SortedSet<AbstractPlayerPower> pp = loadDatabase();
   for (AbstractPlayerPower app : pp) {
     if (app.level > militarySkill) break;
     app.upgrade(booster);
   }
 }