コード例 #1
0
 @Override
 public void use(IPlayer player) throws ItemNotInBackpackException, ContextRequireException {
   player.getBackpack().removeItem(this);
   this.getAttributes()
       .forEach(
           (itemAttribute) -> {
             player.getStatistic(itemAttribute.getAttribute()).add(itemAttribute.getChangeValue());
           });
 }
コード例 #2
0
 @Override
 public void use(IPlayer player, IUsageContext usageContext)
     throws ItemNotInBackpackException, ContextRequireException {
   super.use(player);
   if (usageContext == null) {
     throw new ContextRequireException(this);
   }
   usageContext.registerOnFinishListener(
       () ->
           getAttributes()
               .forEach(
                   itemAttribute ->
                       player
                           .getStatistic(itemAttribute.getAttribute())
                           .add(itemAttribute.getOpositeOfChangeValue())));
 }