Created
April 6, 2016 22:12
-
-
Save VirtuosiMedia/22e903ca3d127b4bf716a72cdf934d02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the order purchase price for a particular good from a holding. | |
* @param {int} holding The holding id. | |
* @param {string} good The good id. | |
* @return {mixed} The order purchase price if the order exists, false otherwise. | |
*/ | |
getGoodOrderPrice: function(holding, good){ | |
var orders = jg.data.holdings[holding].data.economic.trade.orders; | |
return (orders.hasKey(good)) ? orders[good].price : false; | |
}, | |
/** | |
* Gets the order quantity for a particular good from a holding. | |
* @param {int} holding The holding id. | |
* @param {string} good The good id. | |
* @return {mixed} The order quantity if the order exists, false otherwise. | |
*/ | |
getGoodOrderQuantity: function(holding, good){ | |
var orders = jg.data.holdings[holding].data.economic.trade.orders; | |
return (orders.hasKey(good)) ? orders[good].quantity : false; | |
}, | |
/** | |
* Gets the order type for a particular good from a holding. | |
* @param {int} holding The holding id. | |
* @param {string} good The good id. | |
* @return {mixed} The order type if the order exists, false otherwise. | |
*/ | |
getGoodOrderType: function(holding, good){ | |
var orders = jg.data.holdings[holding].data.economic.trade.orders; | |
return (orders.hasKey(good)) ? orders[good].orderType : false; | |
}, | |
/** | |
* Gets the order action for a particular good from a holding. | |
* @param {int} holding The holding id. | |
* @param {string} good The good id. | |
* @return {string} 'cancel' if the order exists, 'bid' otherwise. | |
*/ | |
getGoodOrderAction: function(holding, good){ | |
var orders = jg.data.holdings[holding].data.economic.trade.orders; | |
return (orders.hasKey(good)) ? 'cancel' : 'bid'; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment