Example #1
0
  /**
   * Method used to give the player group the reward for the quest that was completed
   *
   * @param quest an object of the class Quest
   */
  public void receiveReward(Quest quest) {

    // test if the reward has money
    if (quest.getMoneyRewarded() != -1) {
      RPGSystem.getRPGSystem().getPlayerGroup().setMoneyValue(quest.getMoneyRewarded());
    }

    // test if has one or more itens to receive
    if (quest.getRewardItem() != null) {
      // will pass throught all itens and say to give them to the player
      for (int i = 0; i < quest.getRewardedItem().length; i++) {
        // say to put the item in the player inventory
        RPGSystem.getRPGSystem()
            .getPlayerGroup()
            .addItem(quest.getRewardItem()[i], quest.getRewardedItem()[i]);
      }
    }

    // test if has one or more features to increase
    if (quest.getFeatureName() != null) {
      // will pass throught all the features and increase all the groups features
      for (int i = 0; i < quest.getFeatureName().length; i++) {
        // needs to increase for the entire group
        RPGSystem.getRPGSystem()
            .getPlayerGroup()
            .increaseGroupFeature(
                quest.getFeatureName()[i], quest.getFeatureType()[i], quest.getFeatureValue()[i]);
      }
    }
  }