Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi porttitor est quis tellus aliquam, et cursus nisi lobortis. Nulla felis magna, scelerisque sit amet lobortis eget, fermentum blandit lacus. Ut id orci condimentum, pretium nunc sit amet, congue lorem. Vivamus est dolor, imperdiet ac lectus vel, feugiat ultrices dui. In tincidunt ante eu leo vehicula vehicula.
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
/** | |
* Calculates all trade functionality. | |
* Copyright Virtuosi Media, Inc. | |
*/ | |
jg.calculate.trade = { | |
resources: false, | |
components: false, | |
/** |
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
/** | |
* Renders the trade center screen. | |
* Copyright Virtuosi Media, Inc. | |
*/ | |
jg.templates.commercial.tradeCenter = function(){ | |
return { | |
updateManager: function(){ | |
}, |
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
/** | |
* Cancels an order for a good from a holding. | |
* @param {int} holdingId The holding id. | |
* @param {string} good The good id. | |
*/ | |
cancelTradeOrder: function(holdingId, good){ | |
var holding = jg.data.holdings[holdingId]; | |
var order = holding.data.economic.trade.orders[good]; | |
if (order.orderType === 'order'){ |
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
/** | |
* Unlocks a purchase bid, canceling it and rerendering the table and the resource panel. | |
* @param {HTMLObject} target The unlock button. | |
*/ | |
cancelBid: function(target){ | |
var good = target.get('data-good'); | |
var holding = jg.data.state.holding; | |
var template = jg.templates.commercial.tradeCenter(); | |
jg.calculate.trade.cancelTradeOrder(holding, good); |
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
/** | |
* Places an order for a good from a holding. | |
* @param {int} holdingId The holding id. | |
* @param {string} good The good id. | |
* @param {string} goodCategory The good category: resource, component. | |
* @param {float} price The price of the order. | |
* @param {int} quantity The quantity of goods ordered. | |
* @param {string} orderType The type of purchase: trade or order. | |
* @return {boolean} TRUE if the order was placed, FALSE if there were insufficient resources. | |
*/ |
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
/** | |
* Locks in a purchase bid, but checks for errors first then rerenders the table and the resource panel. | |
* @param {HTMLObject} target The lock button. | |
*/ | |
placeBid: function(target){ | |
var good = target.get('data-good'); | |
var goodCategory = target.get('data-goodCategory'); | |
var priceInput = _.$('purchasePrice-' + good); | |
var quantityInput = _.$('purchaseQuantity-' + good); | |
var price = parseFloat(priceInput.value); |
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; | |
}, |
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
/** | |
* Retrieves a base price for a given good based on the base prices of all resources used to craft it. | |
* @param {string} good The good id. | |
* @return {numeric} The base price of the good. | |
*/ | |
getGoodBasePrice: function(good){ | |
if (!this.resources){ | |
this.resources = _.container(_.language.getDataSet('resources')); | |
} |
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 average sales price for a good from all entities that are selling it. | |
* @param {int} holdingId The holding id. | |
* @param {string} good The good id. | |
* @return {numeric} The average sales price for the good. | |
*/ | |
getAverageGoodSalesPrice: function(holdingId, good){ | |
var numSellers = 1; | |
var totalPrice = this.getGoodBasePrice(good); |
NewerOlder