org.starhope.appius.user.events
Class EventOutcomeRecord

java.lang.Object
  extended by org.starhope.appius.util.SimpleDataRecord<EventOutcomeRecord>
      extended by org.starhope.appius.user.events.EventOutcomeRecord
All Implemented Interfaces:
com.whirlycott.cache.Cacheable, Serializable, Comparable<EventOutcomeRecord>, CTime, DataRecord, HasSubversionRevision

public class EventOutcomeRecord
extends SimpleDataRecord<EventOutcomeRecord>

Event Outcome Record

Event outcomes are the rules that determine what results come from ending an event.

Each event type is associated with a single outcome. That outcome can reward the player for an event, or do nothing.

For events such as minigames and in-world games, outcomes will general give the player some kind of reward.

The Reward Scalar

The reward scalar scales the reward. It is used for selection of items, as well as currency rewards.

The reward scalar can be chosen randomly from within a given range of values. (A minimum and maximum value can be set.)

The reward scalar can also be taken from points earned playing a game or minigame, multiplied by a scaling factor. For example, in a game in which the score could range from 0 to 1000, but a reward item is to be chosen in the range from 0 to 9, the scaling factor would be .001 with limits of 0 and 9. This would ensure that the score of 1000 × .001 = 10 would be limited instead to 9.

Rewarding the player with currency

Issuing a reward of currency is the simplest option. For this, the unit of currency (for example, Tootsville™ Peanuts) must be chosen, and the reward scalar is translated directly into currency.

For example, for a game with a score ranging from 0 to 1000, for which you wish to reward from 0 to 50 currency units, a scaling factor of .05 would give the correct results. (50 ÷ 1000 = .05; 1000 × .05 = 50).

Rewarding the player with items

Players can be rewarded with items based on the outcome of a game or minigame. The reward item can be a specific item, an item from a collection, or any item in the game's entire item database.

In the case of an item collection, the reward scalar is first determined. Then, the scalar is taken modulo the size of the collection. The item in the collection, in sequence, with the index of the reward scalar is the chosen item. Note that the index and scalar both begin counting with 0.

In other words, for a set of ten items, the items are numbered 0 through 9. The scalar is limited to the range of 0 to 9 (thus, 18 becomes 8). The first item is item 0; the next is item 1; and so forth.

Likewise, for “all items,” the actual item rewarded is taken from the item scalar. This is generally worthless, unless the scalar is random.

Furthermore, however, the item rewarded can be restricted based upon its rarity. Both a minimum and maximum rarity rating can be specified. (These ratings are inclusive.) This allows, for example, rewarding a random item from a collection, but not the rarest item in that collection. It can also be combined with random scalars against all items.

Note that applying a random scalar within a range does not imply even distribution of random values. There will be an uneven distribution based upon various factors, so the total set of all items rewarded “randomly” will favour certain items mathematically. However, this effect should generally be negligible.

Remedial Third-Grade Math

To figure out the scaling factor to give a scalar in the range from 0 to x, with a points-score in the range from 0 to y. simply take x÷y. (That's the maximum scalar desired divided by the maximum possible score.)

Author:
brpocock@star-hope.org
See Also:
Serialized Form

Field Summary
private  MedalType giveMedal
          WRITEME: Document this brpocock@star-hope.org
private  int id
          event outcome ID
private  RarityRating maxRarity
          WRITEME: Document this brpocock@star-hope.org
private  BigDecimal maxReward
          WRITEME: Document this brpocock@star-hope.org
private  RarityRating minRarity
          WRITEME: Document this brpocock@star-hope.org
private  BigDecimal minReward
          WRITEME: Document this brpocock@star-hope.org
private  boolean permitDuplicateReward
          WRITEME: Document this brpocock@star-hope.org
private  boolean retryDuplicateReward
          WRITEME: Document this brpocock@star-hope.org
private  boolean rewardByPoints
          WRITEME: Document this brpocock@star-hope.org
private  int rewardCollectionID
          WRITEME: Document this brpocock@star-hope.org
private  Currency rewardCurrency
          WRITEME: Document this brpocock@star-hope.org
private  int rewardItemID
          WRITEME: Document this brpocock@star-hope.org
private  RewardItemType rewardItemType
          the type of method of selection of an item reward
private  BigDecimal rewardMax
          WRITEME: Document this brpocock@star-hope.org
private  BigDecimal rewardMin
          WRITEME: Document this brpocock@star-hope.org
private  boolean rewardRandom
          WRITEME: Document this brpocock@star-hope.org
private  BigDecimal rewardRatio
          WRITEME: Document this brpocock@star-hope.org
private static long serialVersionUID
          WRITEME: Document this brpocock@star-hope.org
 
Fields inherited from class org.starhope.appius.util.SimpleDataRecord
myLoader, timeLastChanged, timeLastSaved
 
Constructor Summary
EventOutcomeRecord()
          WRITEME: Document this constructor brpocock@star-hope.org
EventOutcomeRecord(RecordLoader<EventOutcomeRecord> loader)
          WRITEME: Document this constructor brpocock@star-hope.org
 
Method Summary
 int getCacheableID()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 String getCacheableIdent()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 MedalType getGiveMedal()
           
 int getID()
           
 RarityRating getMaxRarity()
           
 BigDecimal getMaxReward()
           
 RarityRating getMinRarity()
           
 BigDecimal getMinReward()
           
 int getRewardCollectionID()
           
 Currency getRewardCurrency()
           
 int getRewardItemID()
           
 RewardItemType getRewardItemType()
           
 BigDecimal getRewardMax()
           
 BigDecimal getRewardMin()
           
 BigDecimal getRewardRatio()
           
 String getSubversionRevision()
           Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.
 boolean isPermitDuplicateReward()
           
 boolean isRetryDuplicateReward()
           
 boolean isRewardByPoints()
           
 boolean isRewardRandom()
           
 void setGiveMedal(MedalType medalToGive)
           
 void setID(int newID)
           
 void setMaxRarity(RarityRating newMaxRarity)
           
 void setMaxReward(BigDecimal newMaxReward)
           
 void setMinRarity(RarityRating newMinRarity)
           
 void setMinReward(BigDecimal newMinReward)
           
 void setPermitDuplicateReward(boolean whetherToPermitDuplicateRewards)
           
 void setRetryDuplicateReward(boolean whetherToRetryOnDuplicateRewards)
           
 void setRewardByPoints(boolean whetherToRewardByPoints)
           
 void setRewardCollectionID(int newRewardCollectionID)
           
 void setRewardCurrency(Currency currency)
           
 void setRewardItemID(int newRewardItemID)
           
 void setRewardItemType(RewardItemType newType)
          WRITEME: Document this method brpocock@star-hope.org
 void setRewardMax(BigDecimal bigDecimal)
           
 void setRewardMin(BigDecimal bigDecimal)
           
 void setRewardRandom(boolean equals)
           
 void setRewardRatio(BigDecimal newRewardRatio)
           
 
Methods inherited from class org.starhope.appius.util.SimpleDataRecord
changed, checkStale, compareTo, equals, finalize, getRecordLoader, getTimeLastChanged, getTimeLastSaved, hashCode, isBeingLoaded, markAsLoaded, markAsSaved, markForReload, onRemove, onRetrieve, onStore, save, setRecordLoader, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
WRITEME: Document this brpocock@star-hope.org

See Also:
Constant Field Values

giveMedal

private MedalType giveMedal
WRITEME: Document this brpocock@star-hope.org


id

private int id
event outcome ID


maxRarity

private RarityRating maxRarity
WRITEME: Document this brpocock@star-hope.org


maxReward

private BigDecimal maxReward
WRITEME: Document this brpocock@star-hope.org


minRarity

private RarityRating minRarity
WRITEME: Document this brpocock@star-hope.org


minReward

private BigDecimal minReward
WRITEME: Document this brpocock@star-hope.org


permitDuplicateReward

private boolean permitDuplicateReward
WRITEME: Document this brpocock@star-hope.org


retryDuplicateReward

private boolean retryDuplicateReward
WRITEME: Document this brpocock@star-hope.org


rewardByPoints

private boolean rewardByPoints
WRITEME: Document this brpocock@star-hope.org


rewardCollectionID

private int rewardCollectionID
WRITEME: Document this brpocock@star-hope.org


rewardCurrency

private Currency rewardCurrency
WRITEME: Document this brpocock@star-hope.org


rewardItemID

private int rewardItemID
WRITEME: Document this brpocock@star-hope.org


rewardRatio

private BigDecimal rewardRatio
WRITEME: Document this brpocock@star-hope.org


rewardRandom

private boolean rewardRandom
WRITEME: Document this brpocock@star-hope.org


rewardMin

private BigDecimal rewardMin
WRITEME: Document this brpocock@star-hope.org


rewardMax

private BigDecimal rewardMax
WRITEME: Document this brpocock@star-hope.org


rewardItemType

private RewardItemType rewardItemType
the type of method of selection of an item reward

Constructor Detail

EventOutcomeRecord

public EventOutcomeRecord()
WRITEME: Document this constructor brpocock@star-hope.org


EventOutcomeRecord

public EventOutcomeRecord(RecordLoader<EventOutcomeRecord> loader)
WRITEME: Document this constructor brpocock@star-hope.org

Parameters:
loader - WRITEME
Method Detail

getCacheableID

public int getCacheableID()
                   throws NotFoundException
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Returns:
an unique ID number
Throws:
NotFoundException - if the item doesn't have a distinct numeric ID
See Also:
DataRecord.getCacheableID()

getCacheableIdent

public String getCacheableIdent()
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Returns:
an unique identifier string
See Also:
DataRecord.getCacheableIdent()

getGiveMedal

public MedalType getGiveMedal()
Returns:
the giveMedal

getID

public int getID()
Returns:
the id

getMaxRarity

public RarityRating getMaxRarity()
Returns:
the maxRarity

getMaxReward

public BigDecimal getMaxReward()
Returns:
the maxReward

getMinRarity

public RarityRating getMinRarity()
Returns:
the minRarity

getMinReward

public BigDecimal getMinReward()
Returns:
the minReward

getRewardCollectionID

public int getRewardCollectionID()
Returns:
the rewardCollectionID

getRewardCurrency

public Currency getRewardCurrency()
Returns:
the rewardCurrency

getRewardItemID

public int getRewardItemID()
Returns:
the rewardItemID

getRewardItemType

public RewardItemType getRewardItemType()
Returns:
the method by which an item might be awarded

getRewardMax

public BigDecimal getRewardMax()
Returns:
maximum reward amount (in currency units)

getRewardMin

public BigDecimal getRewardMin()
Returns:
minimum reward amount (in currency units)

getRewardRatio

public BigDecimal getRewardRatio()
Returns:
the rewardRatio

getSubversionRevision

public String getSubversionRevision()
Description copied from interface: HasSubversionRevision

Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.

As an example,the Subversion revision string for this file is "$Rev: 1968 $"

 
 @Override
 public String getSubversionRevision () {
        return "$Rev: ";
 }
 

Returns:
The Subversion revision level for this class's source code file.
See Also:
HasSubversionRevision.getSubversionRevision()

isPermitDuplicateReward

public boolean isPermitDuplicateReward()
Returns:
the permitDuplicateReward

isRetryDuplicateReward

public boolean isRetryDuplicateReward()
Returns:
the retryDuplicateReward

isRewardByPoints

public boolean isRewardByPoints()
Returns:
the rewardByPoints

isRewardRandom

public boolean isRewardRandom()
Returns:
true, if reward scalars are decided randomly

setGiveMedal

public void setGiveMedal(MedalType medalToGive)
Parameters:
medalToGive - the giveMedal to set

setID

public void setID(int newID)
Parameters:
newID - the id to set

setMaxRarity

public void setMaxRarity(RarityRating newMaxRarity)
Parameters:
newMaxRarity - the maxRarity to set

setMaxReward

public void setMaxReward(BigDecimal newMaxReward)
Parameters:
newMaxReward - the maxReward to set

setMinRarity

public void setMinRarity(RarityRating newMinRarity)
Parameters:
newMinRarity - the minRarity to set

setMinReward

public void setMinReward(BigDecimal newMinReward)
Parameters:
newMinReward - the minReward to set

setPermitDuplicateReward

public void setPermitDuplicateReward(boolean whetherToPermitDuplicateRewards)
Parameters:
whetherToPermitDuplicateRewards - the permitDuplicateReward to set

setRetryDuplicateReward

public void setRetryDuplicateReward(boolean whetherToRetryOnDuplicateRewards)
Parameters:
whetherToRetryOnDuplicateRewards - the retryDuplicateReward to set

setRewardByPoints

public void setRewardByPoints(boolean whetherToRewardByPoints)
Parameters:
whetherToRewardByPoints - the rewardByPoints to set

setRewardCollectionID

public void setRewardCollectionID(int newRewardCollectionID)
Parameters:
newRewardCollectionID - the rewardCollectionID to set

setRewardCurrency

public void setRewardCurrency(Currency currency)
Parameters:
currency - the rewardCurrency to set

setRewardItemID

public void setRewardItemID(int newRewardItemID)
Parameters:
newRewardItemID - the rewardItemID to set

setRewardItemType

public void setRewardItemType(RewardItemType newType)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
newType - WRITEME

setRewardMax

public void setRewardMax(BigDecimal bigDecimal)
Parameters:
bigDecimal - the maximum reward scalar

setRewardMin

public void setRewardMin(BigDecimal bigDecimal)
Parameters:
bigDecimal - the minimum amount for the reward scalar

setRewardRandom

public void setRewardRandom(boolean equals)
Parameters:
equals - whether the reward scalar is determined randomly

setRewardRatio

public void setRewardRatio(BigDecimal newRewardRatio)
Parameters:
newRewardRatio - the rewardRatio to set