コード例 #1
0
 public void incrementBonus(final AptitudeBonusView bonus) {
   if (!bonus.canBeIncreased()) {
     return;
   }
   this.m_inventory.addLevel(bonus.getId(), (short) 1);
   this.m_inventory.removePointsFor(bonus.getId(), (short) 1);
   this.m_modifications.adjustOrPutValue(bonus.getId(), (short) 1, (short) 1);
   bonus.fireLevelChanged();
   final AptitudeBonusCategoryView category =
       this.m_categoriesById.get(
           AptitudeCategoryModelManager.INSTANCE.getBonusCategoryId(bonus.getId()));
   category.fireAvailablePointsChanged();
 }
コード例 #2
0
 public void decrementBonus(final AptitudeBonusView bonus) {
   if (!bonus.canBeDecreased()) {
     return;
   }
   final int categoryId = AptitudeCategoryModelManager.INSTANCE.getBonusCategoryId(bonus.getId());
   this.m_inventory.addLevel(bonus.getId(), (short) (-1));
   this.m_inventory.incPointFor(categoryId);
   final short previousValue = this.m_modifications.get(bonus.getId());
   if (previousValue == 1) {
     this.m_modifications.remove(bonus.getId());
   } else {
     this.m_modifications.put(bonus.getId(), (short) (previousValue - 1));
   }
   bonus.fireLevelChanged();
   final AptitudeBonusCategoryView category = this.m_categoriesById.get(categoryId);
   category.fireAvailablePointsChanged();
 }
コード例 #3
0
 public void reset(final AptitudeBonusInventory inventory) {
   this.m_categories.clear();
   this.m_categoriesById.clear();
   (this.m_inventory = inventory.getInactiveCopy()).addListener(this);
   this.m_modifications.clear();
   AptitudeCategoryModelManager.INSTANCE.forEachCategory(
       new TObjectProcedure<AptitudeCategoryModel>() {
         @Override
         public boolean execute(final AptitudeCategoryModel object) {
           final AptitudeBonusCategoryView category =
               new AptitudeBonusCategoryView(object, AptitudesView.this.m_inventory);
           AptitudesView.this.m_categories.add(category);
           AptitudesView.this.m_categoriesById.put(category.getId(), category);
           return true;
         }
       });
   Collections.sort(this.m_categories, this.m_categoryViewComparator);
   this.m_currentCategory = this.m_categories.get(0);
 }