com.planet_ink.coffee_mud.Common.interfaces
Interface CoffeeShop

All Superinterfaces:
java.lang.Cloneable, CMCommon, CMObject, java.lang.Comparable<CMObject>
All Known Implementing Classes:
AuctionCoffeeShop, DefaultCoffeeShop

public interface CoffeeShop
extends CMCommon

A CoffeeShop is an object for storing the inventory of a shopkeeper, banker, auctionhouse, merchant, or other object that implements the ShopKeeper interface for the purpose of selling goods and services. ShopKeepers maintain two types of inventory, the base inventory, and the stock inventory. The stock or store inventory is the list of items the shopkeeper currently has for sale, the amounts, base prices, etc. The base inventory is used only for shopkeepers who only buy things like they originally had in stock, and so the base inventory is always populated with a single copy of the original store inventory, to be used as a base of comparison for situations where the stock is empty, but someone is wanting to sell.

See Also:
ShopKeeper, ShopKeeper.isSold(int), ShopKeeper.DEAL_INVENTORYONLY

Nested Class Summary
static class CoffeeShop.ShelfProduct
          Class for representing a shelf product, holding an item prototype, the number in stock, and the price.
 
Method Summary
 Environmental addStoreInventory(Environmental thisThang)
          Adds a new item to the store inventory.
 Environmental addStoreInventory(Environmental thisThang, int number, int price)
          Adds a new item to the store inventory so the shopkeeper can sell it.
 CoffeeShop build(ShopKeeper SK)
          Initializes this shop object with its host ShopKeeper
 void buildShopFromXML(java.lang.String text)
          Repopulates this shop inventory from a given xml document, restoring store inventory, base inventory, prices, and availability.
 long contentHash()
          Returns a hash of all the items currently in the shop, for help in determining when things change.
 void delAllStoreInventory(Environmental thisThang)
          Removes all items like the given item from the base and store inventory.
 void deleteShelfProduct(CoffeeShop.ShelfProduct P)
          Remove the specific give shelf product from the official stores.
 void destroyStoreInventory()
          Destroys all the items in this shop.
 boolean doIHaveThisInStock(java.lang.String name, MOB mob)
          Returns whether an item with the given name is presently in this stores stock inventory, and available for sale.
 void emptyAllShelves()
          Clears both the base and stock/store inventories.
 int enumerableStockSize()
          Returns the number of items in the stores base inventory.
 java.util.Iterator<Environmental> getEnumerableInventory()
          Returns a iterator of all the Environmental objects this shop has in its base inventory.
 Environmental getStock(java.lang.String name, MOB mob)
          Searches this shops stock of items for sale for one matching the given name.
 java.util.Iterator<Environmental> getStoreInventory()
          Returns a iterator of all the Environmental objects this shop has for sale.
 java.util.Iterator<Environmental> getStoreInventory(java.lang.String srchStr)
          Returns a iterator of all the Environmental objects this shop has for sale which match the given search string.
 java.util.Iterator<CoffeeShop.ShelfProduct> getStoreShelves()
          Returns a iterator of all the ShelfProduct objects this shop has for sale.
 boolean inEnumerableInventory(Environmental thisThang)
          Returns whether an item sufficiently like the given item originally existed in this shops inventory when it was created.
 boolean isSold(int code)
          Returns whether the whatIsSold code applies to the shopkeeper hosting this shop.
 boolean lowerStock(java.lang.String name)
          Searches this shops stock of items for sale for one matching the given name.
 java.lang.String makeXML()
          Generates an XML document of all available shop inventory, prices, and availability.
 int numberInStock(Environmental likeThis)
          Returns the number of items like the one given that the shopkeeper presently has in stock and available for sale.
 java.util.List<Environmental> removeSellableProduct(java.lang.String named, MOB mob)
          Searches this shops stock of items for sale for one matching the given name.
 Environmental removeStock(java.lang.String name, MOB mob)
          Searches this shops stock of items for sale for one matching the given name.
 void resubmitInventory(java.util.List<Environmental> shopItems)
          A method for quickly making wholesale changes to a shopkeepers inventory.
 ShopKeeper shopKeeper()
          Returns the shopKeeper that is hosting this shop
 int stockPrice(Environmental likeThis)
          Returns the base stock price (not the final price by any means) that the shop will use as a foundation for determining the given items price.
 int totalStockSize()
          Returns the number of items this shop currently has for sale.
 int totalStockSizeIncludingDuplicates()
          The number of items in the store inventory, taking number in stock into account.
 int totalStockWeight()
          Total weight, in pounds, of all items in the store inventory, taking number in stock into account.
 CoffeeShop weakCopyOf()
          Returns a thin copy with independent lists, but the same items as the original host.
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, ID, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

inEnumerableInventory

boolean inEnumerableInventory(Environmental thisThang)
Returns whether an item sufficiently like the given item originally existed in this shops inventory when it was created. Applies only to shops where their whatIsSold method returns ONLY_INVENTORY

Parameters:
thisThang - the thing to compare against the base inventory
Returns:
whether the item, or one just like it, is in the base inventory
See Also:
ShopKeeper.isSold(int), ShopKeeper.DEAL_INVENTORYONLY

addStoreInventory

Environmental addStoreInventory(Environmental thisThang)
Adds a new item to the store inventory. Use this method when an item is sold to the store, as pricing and other information will have to be derived.

Parameters:
thisThang - the thing to sell
Returns:
the core store inventory item added
See Also:
addStoreInventory(Environmental, int, int)

enumerableStockSize

int enumerableStockSize()
Returns the number of items in the stores base inventory. Only really useful for historical reasons, or if the shop sells inventory only.

Returns:
the number of items in the base inventory
See Also:
ShopKeeper.isSold(int), ShopKeeper.DEAL_INVENTORYONLY

totalStockSize

int totalStockSize()
Returns the number of items this shop currently has for sale. Does not take number of duplicates into account. For that call totalStockSizeIncludingDuplicates

Returns:
the number of items for sale.
See Also:
totalStockSizeIncludingDuplicates()

destroyStoreInventory

void destroyStoreInventory()
Destroys all the items in this shop.


deleteShelfProduct

void deleteShelfProduct(CoffeeShop.ShelfProduct P)
Remove the specific give shelf product from the official stores.

Parameters:
P - the shelf product to remove permanently

getStoreInventory

java.util.Iterator<Environmental> getStoreInventory()
Returns a iterator of all the Environmental objects this shop has for sale. Will only return one of each item, even if multiple are available.

Returns:
a iterator of objects for sale.

getStoreShelves

java.util.Iterator<CoffeeShop.ShelfProduct> getStoreShelves()
Returns a iterator of all the ShelfProduct objects this shop has for sale.

Returns:
a iterator of all the shelves at the shop.

getStoreInventory

java.util.Iterator<Environmental> getStoreInventory(java.lang.String srchStr)
Returns a iterator of all the Environmental objects this shop has for sale which match the given search string. Will only return one of each item, even if multiple are available.

Parameters:
srchStr - the item to hunt for.
Returns:
a iterator of objects for sale.

getEnumerableInventory

java.util.Iterator<Environmental> getEnumerableInventory()
Returns a iterator of all the Environmental objects this shop has in its base inventory. Only useful for historical reasons, or if the shop sells inventory only.

Returns:
a iterator of objects in base inventory
See Also:
ShopKeeper.isSold(int), ShopKeeper.DEAL_INVENTORYONLY

emptyAllShelves

void emptyAllShelves()
Clears both the base and stock/store inventories.


addStoreInventory

Environmental addStoreInventory(Environmental thisThang,
                                int number,
                                int price)
Adds a new item to the store inventory so the shopkeeper can sell it. All items added go cumulatively into the store inventory, and one copy is kept in the base inventory for historical reasons. The method is called when multiple items need to be added, or if the price is available. This method is usually used to build an original shop inventory.

Parameters:
thisThang - the item/mob/ability to sell
number - the number of items to sell
price - the price of the item (in base currency) or -1 to have it determined
Returns:
the actual object stored in the inventory

totalStockWeight

int totalStockWeight()
Total weight, in pounds, of all items in the store inventory, taking number in stock into account.

Returns:
the total weight in pounds

totalStockSizeIncludingDuplicates

int totalStockSizeIncludingDuplicates()
The number of items in the store inventory, taking number in stock into account. Call this method to see how crowded the shop really is, as opposed to totalStockSize.

Returns:
the total number of all items in stock
See Also:
totalStockSize()

delAllStoreInventory

void delAllStoreInventory(Environmental thisThang)
Removes all items like the given item from the base and store inventory.

Parameters:
thisThang - the item like which to remove
See Also:
ShopKeeper.isSold(int)

doIHaveThisInStock

boolean doIHaveThisInStock(java.lang.String name,
                           MOB mob)
Returns whether an item with the given name is presently in this stores stock inventory, and available for sale.

Parameters:
name - the name of the item to search for
mob - the mob who is interested (stock can differ depending on customer)
Returns:
whether the item is available
See Also:
ShopKeeper.isSold(int)

stockPrice

int stockPrice(Environmental likeThis)
Returns the base stock price (not the final price by any means) that the shop will use as a foundation for determining the given items price. -1 would mean that the shopkeeper uses the valuation of the item as a basis, whereas another value is in base gold. Best to get likeThis item from the getStoreInventory()

Parameters:
likeThis - the item like which to compare
Returns:
the stock price of the item given.
See Also:
getStoreInventory()

numberInStock

int numberInStock(Environmental likeThis)
Returns the number of items like the one given that the shopkeeper presently has in stock and available for sale.

Parameters:
likeThis - the item like which to compare
Returns:
the number currently in stock.
See Also:
getStoreInventory()

getStock

Environmental getStock(java.lang.String name,
                       MOB mob)
Searches this shops stock of items for sale for one matching the given name.

Parameters:
name - the name of the item to search for
mob - the mob who is interested (stock can differ depending on customer)
Returns:
the available item, if found
See Also:
getStoreInventory()

removeStock

Environmental removeStock(java.lang.String name,
                          MOB mob)
Searches this shops stock of items for sale for one matching the given name. If one is found, it copies the item, removes one from the available stock, and returns the copy.

Parameters:
name - the name of the item to search for
mob - the mob who is interested (stock can differ depending on customer)
Returns:
the available item, if found
See Also:
getStoreInventory()

lowerStock

boolean lowerStock(java.lang.String name)
Searches this shops stock of items for sale for one matching the given name. If one is found, then one unit is removed from one of the available stock and true is returned.

Parameters:
name - the name of the item to lower the stock of
Returns:
true if it was lowered

removeSellableProduct

java.util.List<Environmental> removeSellableProduct(java.lang.String named,
                                                    MOB mob)
Searches this shops stock of items for sale for one matching the given name. If one is found, it copies the item, removes one from the available stock, and prepares it for sale by adding it to a list along with any necessary accessories, such as necessary keys, or if a container, any contents of the container.

Parameters:
named - the name of the item to search for
mob - the mob who is interested (stock can differ depending on customer)
Returns:
the available items, if found, as a list of Environmental objects
See Also:
getStoreInventory()

makeXML

java.lang.String makeXML()
Generates an XML document of all available shop inventory, prices, and availability.

Returns:
an XML document.
See Also:
getStoreInventory(), buildShopFromXML(String)

buildShopFromXML

void buildShopFromXML(java.lang.String text)
Repopulates this shop inventory from a given xml document, restoring store inventory, base inventory, prices, and availability.

Parameters:
text - the xml document to restore from
See Also:
makeXML()

resubmitInventory

void resubmitInventory(java.util.List<Environmental> shopItems)
A method for quickly making wholesale changes to a shopkeepers inventory. getStoreInventory should be called to get the list of items. The items can then be modified, and this method called to properly "resubmit" them to the shopkeeper.

Parameters:
shopItems - the items for inventory

build

CoffeeShop build(ShopKeeper SK)
Initializes this shop object with its host ShopKeeper

Parameters:
SK - the shopkeeper that hosts this object
Returns:
always this

shopKeeper

ShopKeeper shopKeeper()
Returns the shopKeeper that is hosting this shop

Returns:
the shopKeeper that is hosting this shop

weakCopyOf

CoffeeShop weakCopyOf()
Returns a thin copy with independent lists, but the same items as the original host.

Returns:
the thin copy

isSold

boolean isSold(int code)
Returns whether the whatIsSold code applies to the shopkeeper hosting this shop.

Parameters:
code - the whatIsSold code
Returns:
whether the whatIsSold code applies to the shopkeeper hosting this shop.
See Also:
ShopKeeper.DEAL_DESCS

contentHash

long contentHash()
Returns a hash of all the items currently in the shop, for help in determining when things change.

Returns:
the hash of the contents.