Class Market
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
games.stendhal.server.entity.PassiveEntity
games.stendhal.server.entity.trade.Market
- All Implemented Interfaces:
Killer
,Cloneable
,Iterable<String>
,Serializable
A Market handles sales offers of players. Players can place offers or accept
offers to buy a desired item. Offers last only for a certain amount of time
before they expire and can be prolonged. Expired Offers get removed
permanently from the market after another period of time. When an offer has
been accepted, the offering Player can come and fetch his earnings for that
sale.
- Author:
- madmetzger, kiheru
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
the name of the slot where the earnings are storedstatic String
the name of the slot where the expired offers are storedstatic String
the RPClass name for the marketstatic String
the name of the slot where the offers are storedFields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptOffer(Offer offer, Player acceptingPlayer)
Completes a trade of an offer by transferring item to accepting player and taking the money from himboolean
int
countOffersOfPlayer(Player offerer)
counts the number of offers, a player has placedcreateOffer(Player offerer, Item item, Integer money, Integer number)
creates a new offer at the marketstatic Market
Factory method for the marketvoid
expireOffer(Offer o)
expires an offer and removes it from the available offersfetchEarnings(Player earner)
The earnings for complete trades are paid to the player.static void
Generate the RPClass for the MarketgetEarningsOlderThan(int seconds)
Get a list of earnings whose timestamp is older than specified.getExpiredOffersOlderThan(int seconds)
Get a list of expired offers whose timestamp is older than specified.getOffersOlderThan(int seconds)
Get a list of offers whose timestamp is older than specified.boolean
hasEarningsFor(Player player)
prolongOffer(Offer offer)
prolongs an offer in the market to make it available againvoid
removeEarnings(Iterable<Earning> earningsToRemove)
Remove a set of earnings.void
removeExpiredOffer(Offer offerToRemove)
removes an expired offer permanently from the marketvoid
removeOffer(Offer o, Player p)
removes an offer from the market and returns the item to the userMethods inherited from class games.stendhal.server.entity.Entity
describe, getAdjacentNodes, getArea, getArea, getCursor, getDescription, getDescriptionName, getEntitySlot, getHeight, getName, getOrigin, getResistance, getResistance, getTitle, getWidth, getX, getY, getZone, hasDescription, isInSight, isObstacle, nextTo, nextTo, notifyWorldAboutChanges, onAdded, onMoved, onRemoved, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance, stopped, update
Methods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, toString, unhide, unstore, writeObject, writeObject, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
MARKET_RPCLASS_NAME
the RPClass name for the market- See Also:
- Constant Field Values
-
EARNINGS_SLOT_NAME
the name of the slot where the earnings are stored- See Also:
- Constant Field Values
-
OFFERS_SLOT_NAME
the name of the slot where the offers are stored- See Also:
- Constant Field Values
-
EXPIRED_OFFERS_SLOT_NAME
the name of the slot where the expired offers are stored- See Also:
- Constant Field Values
-
-
Constructor Details
-
Market
Creates a new Market from an RPObject- Parameters:
object
-
-
-
Method Details
-
generateRPClass
public static void generateRPClass()Generate the RPClass for the Market -
createShop
Factory method for the market- Returns:
- a new Market
-
createOffer
creates a new offer at the market- Parameters:
offerer
- offering playeritem
- item to sellmoney
- price for the itemnumber
- number of items to sell- Returns:
- the new created offer
-
acceptOffer
Completes a trade of an offer by transferring item to accepting player and taking the money from him- Parameters:
offer
-acceptingPlayer
-- Returns:
true
if the trade was done,false
on failure
-
fetchEarnings
The earnings for complete trades are paid to the player.- Parameters:
earner
- the player fetching his earnings- Returns:
- the fetched earnings
-
removeEarnings
Remove a set of earnings.- Parameters:
earningsToRemove
- The earnings to be removed
-
countOffersOfPlayer
counts the number of offers, a player has placed- Parameters:
offerer
-- Returns:
- the number of offers
-
removeOffer
removes an offer from the market and returns the item to the user- Parameters:
o
- the offer to removep
- the removing player
-
expireOffer
expires an offer and removes it from the available offers- Parameters:
o
- the offer to expire
-
getExpiredOffers
- Returns:
- all currently expired offers in the market
-
removeExpiredOffer
removes an expired offer permanently from the market- Parameters:
offerToRemove
-
-
prolongOffer
prolongs an offer in the market to make it available again- Parameters:
offer
- the offer to prolong- Returns:
- the prolonged offer
-
getOffersOlderThan
Get a list of offers whose timestamp is older than specified.- Parameters:
seconds
- age of offers in seconds- Returns:
- list of offers that are older than the specified time
-
getExpiredOffersOlderThan
Get a list of expired offers whose timestamp is older than specified.- Parameters:
seconds
- age of offers in seconds- Returns:
- list of expired offers that are older than the specified time
-
getEarningsOlderThan
Get a list of earnings whose timestamp is older than specified.- Parameters:
seconds
- age of offers in seconds- Returns:
- list of earnings that are older than the specified time
-
contains
- Parameters:
o
-- Returns:
- true iff the Offer o is in this market's offers
-
hasEarningsFor
- Parameters:
player
-- Returns:
- true iff there are earnings for this player in the market
-