|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.util.SimpleDataRecord<EventRecord>
org.starhope.appius.user.events.EventRecord
public class EventRecord
Events are any thing that happens in the world that can influence a player's currency or inventory.
XXX:contains SQL
ALTER TABLE eventTypes CHANGE COLUMN outcome outcome INT NOT NULL DEFAULT 3; ALTER TABLE eventTypes ADD CONSTRAINT FOREIGN KEY (outcome) REFERENCES eventOutcomes (ID); ALTER TABLE eventTypes CHANGE COLUMN filename filename VARCHAR(64) NOT NULL DEFAULT ''; ALTER TABLE eventTypes CHANGE COLUMN description description TEXT NOT NULL;
Field Summary | |
---|---|
private long |
completionTimestamp
WRITEME: Document this brpocock@star-hope.org |
private long |
creationTimestamp
WRITEME: Document this brpocock@star-hope.org |
private int |
creatorID
WRITEME: Document this brpocock@star-hope.org |
private BigDecimal |
currencyAmountEarned
WRITEME: Document this brpocock@star-hope.org |
private Currency |
currencyEarned
WRITEME: Document this brpocock@star-hope.org |
private int |
earnedItemID
WRITEME |
private int |
eventTypeID
WRITEME: Document this brpocock@star-hope.org |
private int |
id
WRITEME: Document this brpocock@star-hope.org |
private Collection<MedalType> |
medals
WRITEME |
private BigDecimal |
points
WRITEME: Document this brpocock@star-hope.org |
private boolean |
sendHighScore
Whether to send high scores when printing this event |
private static long |
serialVersionUID
WRITEME: Document this ewinkelman |
Fields inherited from class org.starhope.appius.util.SimpleDataRecord |
---|
myLoader, timeLastChanged, timeLastSaved |
Constructor Summary | |
---|---|
EventRecord()
WRITEME: Document this constructor brpocock@star-hope.org |
|
EventRecord(EventRecordLoader loader)
WRITEME: Document this constructor brpocock@star-hope.org |
Method Summary | |
---|---|
void |
addMedalEarned(int medalTypeID)
WRITEME: Document this method brpocock@star-hope.org |
void |
addMedalEarned(String medal)
WRITEME: Document this method brpocock@star-hope.org |
void |
cancel()
Cancel an event in progress. |
private BigDecimal |
determineRewardScalar(EventOutcomeRecord outcome)
|
private void |
doOutcome()
perform actions specified by the outcome for this event type |
void |
end(BigDecimal score)
End an event (such as a game or minigame) with a singular score |
void |
end(GenericItemReference itemPurchased)
purchase something. |
void |
end(InventoryItem item,
AbstractUser u)
End a “gift” event whereby an user has given an item to another user |
void |
end(LinkedHashMap<Integer,Integer> sortedScores)
End this event for this player. |
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. |
long |
getCompletionTimestamp()
|
long |
getCreationTimestamp()
|
private AbstractUser |
getCreator()
WRITEME: Document this method brpocock@star-hope.org |
int |
getCreatorID()
|
BigDecimal |
getCurrencyAmountEarned()
|
Currency |
getCurrencyEarned()
|
EventType |
getEventType()
|
int |
getEventTypeID()
|
int |
getID()
|
int |
getItemEarned()
|
Collection<MedalType> |
getMedalsEarned()
WRITEME WRITEME: Document this method brpocock@star-hope.org |
BigDecimal |
getPoints()
|
String |
getSubversionRevision()
Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence. |
boolean |
isSendHighScore()
|
private void |
pushHighScoresIntoJSON(PreparedStatement getHighScores,
org.json.JSONObject wrapper)
WRITEME: document this method (brpocock@star-hope.org, Dec 1, 2009) |
protected void |
putEventHighScoresIntoJSON(org.json.JSONObject wrapper)
Get high score information from the database and return it as a JSON object |
private void |
rewardWithCurrency(EventOutcomeRecord outcome,
BigDecimal scalar)
Award any currency earned |
private void |
rewardWithItem(EventOutcomeRecord outcome,
BigDecimal scalar)
Award any item earned |
private GenericItemReference |
rewardWithItemFromCollection(EventOutcomeRecord outcome,
BigDecimal scalar)
WRITEME: Document this method brpocock@star-hope.org |
private void |
rewardWithMedal(EventOutcomeRecord outcome,
BigDecimal scalar)
Is a medal to be awarded at this point? Note that this will overrule any medal earned during the event, presently, as medals are in the events table. |
void |
setCompletionTimestamp(long newTimestamp)
|
void |
setCompletionTimestamp(Timestamp timestamp)
|
void |
setCreationTimestamp(long newTimestamp)
WRITEME: Document this method brpocock@star-hope.org |
void |
setCreationTimestamp(Timestamp timestamp)
|
void |
setCreator(AbstractUser user)
WRITEME: Document this method brpocock@star-hope.org |
void |
setCreatorID(int newCreatorID)
WRITEME: Document this method brpocock@star-hope.org |
void |
setCurrencyEarned(String currencyType,
BigDecimal amount)
WRITEME: Document this method brpocock@star-hope.org |
void |
setEventTypeID(int newEventTypeID)
WRITEME: Document this method brpocock@star-hope.org |
void |
setID(int newID)
set the event's unique ID (normally done only once at creation) |
void |
setItemEarned(int itemID)
WRITEME: Document this method brpocock@star-hope.org |
private void |
setPoints(BigDecimal score)
WRITEME: Document this method brpocock@star-hope.org |
void |
setPoints(long newPoints)
|
void |
setSendHighScore(boolean whether)
|
org.json.JSONObject |
toJSON()
WRITEME: Document this method brpocock@star-hope.org |
String |
toString()
|
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 |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private long completionTimestamp
private long creationTimestamp
private int creatorID
private BigDecimal currencyAmountEarned
private Currency currencyEarned
private int earnedItemID
private int eventTypeID
private int id
private final Collection<MedalType> medals
private BigDecimal points
private boolean sendHighScore
FIXME: Move this into EventType
now that it's been
refactored away from SQLPeerEnum
Constructor Detail |
---|
public EventRecord()
public EventRecord(EventRecordLoader loader)
loader
- WRITEMEMethod Detail |
---|
public void addMedalEarned(int medalTypeID)
medalTypeID
- WRITEMEpublic void addMedalEarned(String medal) throws NotFoundException
medal
- WRITEME
NotFoundException
- invalid medal namepublic void cancel()
private BigDecimal determineRewardScalar(EventOutcomeRecord outcome)
outcome
- the outcome being executed
private void doOutcome()
public void end(BigDecimal score)
score
- score earned by this playerpublic void end(GenericItemReference itemPurchased) throws NonSufficientFundsException
itemPurchased
- what was purchased
NonSufficientFundsException
- couldn't afford itpublic void end(InventoryItem item, AbstractUser u) throws GameLogicException
item
- the item being given as a giftu
- the user giving the item as a gift
GameLogicException
- if the transaction cannot be completedpublic void end(LinkedHashMap<Integer,Integer> sortedScores)
sortedScores
- scores earned by all players of a multiplayer
event.public int getCacheableID() throws NotFoundException
DataRecord
DataRecord.getCacheableID()
or a string identifier (
DataRecord.getCacheableIdent()
or both.
NotFoundException
- if the item doesn't have a distinct
numeric IDDataRecord.getCacheableID()
public String getCacheableIdent()
DataRecord
DataRecord.getCacheableID()
or a string identifier (
DataRecord.getCacheableIdent()
or both.
DataRecord.getCacheableIdent()
public long getCompletionTimestamp()
public long getCreationTimestamp()
private AbstractUser getCreator()
public int getCreatorID()
public BigDecimal getCurrencyAmountEarned()
public Currency getCurrencyEarned()
public EventType getEventType()
public int getEventTypeID()
public int getID()
public int getItemEarned()
public Collection<MedalType> getMedalsEarned()
public BigDecimal getPoints()
public String getSubversionRevision()
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: "; }
HasSubversionRevision.getSubversionRevision()
public boolean isSendHighScore()
private void pushHighScoresIntoJSON(PreparedStatement getHighScores, org.json.JSONObject wrapper) throws SQLException, org.json.JSONException
getHighScores
- WRITEMEwrapper
- WRITEME
SQLException
- WRITEME
org.json.JSONException
- WRITEMEprotected void putEventHighScoresIntoJSON(org.json.JSONObject wrapper)
wrapper
- the JSON container to absorb the high score listprivate void rewardWithCurrency(EventOutcomeRecord outcome, BigDecimal scalar)
outcome
- the outcome being executedscalar
- the reward scalarprivate void rewardWithItem(EventOutcomeRecord outcome, BigDecimal scalar)
outcome
- the event outcome being appliedscalar
- the scalar used to determine the outcomeprivate GenericItemReference rewardWithItemFromCollection(EventOutcomeRecord outcome, BigDecimal scalar)
outcome
- WRITEMEscalar
- WRITEME
private void rewardWithMedal(EventOutcomeRecord outcome, BigDecimal scalar)
outcome
- the outcome being executedscalar
- the reward scalarpublic void setCompletionTimestamp(long newTimestamp)
newTimestamp
- the completionTimestamp to setpublic void setCompletionTimestamp(Timestamp timestamp)
timestamp
- the new completion timestamppublic void setCreationTimestamp(long newTimestamp)
newTimestamp
- WRITEMEpublic void setCreationTimestamp(Timestamp timestamp)
timestamp
- the new creation timestamppublic void setCreator(AbstractUser user)
user
- the creator of the eventpublic void setCreatorID(int newCreatorID)
newCreatorID
- WRITEMEpublic void setCurrencyEarned(String currencyType, BigDecimal amount)
currencyType
- WRITEMEamount
- WRITEMEpublic void setEventTypeID(int newEventTypeID)
newEventTypeID
- WRITEMEpublic void setID(int newID)
newID
- the new IDpublic void setItemEarned(int itemID)
itemID
- WRITEMEprivate void setPoints(BigDecimal score)
score
- WRITEMEpublic void setPoints(long newPoints)
newPoints
- the points to setpublic void setSendHighScore(boolean whether)
whether
- whether to send high scores when printing this
eventpublic org.json.JSONObject toJSON() throws org.json.JSONException
org.json.JSONException
- if the contents can't be encoded in JSON
for some reasonpublic String toString()
toString
in class SimpleDataRecord<EventRecord>
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |