Skip to content

How to Guide: Creating a Reward

charliebkw edited this page Sep 6, 2023 · 1 revision

Introduction

Rewards are items and stats that the player can receive for completing different Quests in the game. There are two types of Rewards you are able to use when creating your Quest these are ItemRewards and StatRewards depending on how you would like to reward the Player.

ItemRewards

An ItemReward is a Reward that when collected allows the Player to receive whatever Items you would like to their Inventory. First, create an ArrayList of Entities that you would like to add to the players inventory. Then create a new instance of an ItemReward with your desired ArrayList then you are able to add this to your new Quest instance.

Reward rewardItems = new ItemReward(itemEntities);
Quest quest = new Quest(name, rewardItems, expiryDuration, isMandatory);

StatRewards

StatRewards are Rewards that when collected make changes to the Player’s stats. Please note: player stats are currently not being using within the game. In the current implementation of StatRewards, on collect() the Player will receive the specified amount of health. In the implementation example below, when the Quest calls collect() on its reward it will provide the Player with an additional 20 health points.

Reward statReward = new StatReward(20);
Quest quest = new Quest(name, statReward, expiryDuration, isMandatory);

Making a Custom Reward

The current Reward class is an abstract class meaning anyone has the ability to create their own custom rewards based on your own desired functionality.

By default, the Reward class provides the isCollected() and setCollected() methods while the collect() method needs an implementation.

Overriding collect()

The collect() method should provide your desired functionality for when the Player completes the attached quest. This is up to you for how you believe completing the Quest should affect the game. However, for this Reward to work with the current Mission system implementation you must call setCollected() method so that the Quest is aware the Reward has been collected. You may use the following template:

public void collect() {
   this.setCollected();


   // your desired implementation…
}
 
Clone this wiki locally