From 9551b8b5dee8155ffcfc90a7d09cd944edcfbd53 Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Sat, 15 Apr 2017 18:11:50 +0100 Subject: [PATCH] Add shopping list for refit --- ChangeLog.md | 1 + src/app/components/CostSection.jsx | 26 +++++++++++++++++++++++++- src/app/i18n/en.js | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index de526ded..894da6cb 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,6 @@ #2.3.3 * Remove unused blueprint when hitting reset + * Add 'purchase module' external link to EDDB for refit items #2.3.2 * Use scan range for DSS rather than scan time diff --git a/src/app/components/CostSection.jsx b/src/app/components/CostSection.jsx index 302dd5c8..cbc74b39 100644 --- a/src/app/components/CostSection.jsx +++ b/src/app/components/CostSection.jsx @@ -6,6 +6,7 @@ import Ship from '../shipyard/Ship'; import { Insurance } from '../shipyard/Constants'; import { slotName, slotComparator } from '../utils/SlotFunctions'; import TranslatedComponent from './TranslatedComponent'; +import { ShoppingIcon } from '../components/SvgIcons'; /** * Cost Section @@ -31,6 +32,7 @@ export default class CostSection extends TranslatedComponent { this._buildRetrofitShip = this._buildRetrofitShip.bind(this); this._onBaseRetrofitChange = this._onBaseRetrofitChange.bind(this); this._defaultRetrofitName = this._defaultRetrofitName.bind(this); + this._eddbShoppingList = this._eddbShoppingList.bind(this); let data = Ships[props.ship.id]; // Retrieve the basic ship properties, slots and defaults let retrofitName = this._defaultRetrofitName(props.ship.id, props.buildName); @@ -325,12 +327,29 @@ export default class CostSection extends TranslatedComponent { ; } + /** + * Open up a window for EDDB with a shopping list of our retrofit components + */ + _eddbShoppingList() { + const { retrofitCosts } = this.state; + const { ship } = this.props; + +console.log(`retrofitCosts is ${JSON.stringify(retrofitCosts, null, 2)}`); + // Provide unique list of non-PP module EDDB IDs to buy + const modIds = retrofitCosts.filter(item => item.retroItem.incCost && item.buyId && !item.buyPp).map(item => item.buyId).filter((v, i, a) => a.indexOf(v) === i); +console.log(`modIds is ${JSON.stringify(modIds)}`); + + // Open up the relevant URL + window.open('https://eddb.io/station?m=' + modIds.join(',')); + } + /** * Render the retofit tab * @return {React.Component} Tab contents */ _retrofitTab() { let { retrofitTotal, retrofitCosts, moduleDiscount, retrofitName } = this.state; + const { termtip, tooltip } = this.context; let { translate, formats, units } = this.context.language; let int = formats.int; let rows = [], options = []; @@ -370,7 +389,8 @@ export default class CostSection extends TranslatedComponent { {rows} - {translate('cost')} + + {translate('cost')} 0 ? 'warning' : 'secondary-disabled')} style={{ borderBottom:'none' }}> {int(retrofitTotal)}{units.CR} @@ -403,6 +423,8 @@ export default class CostSection extends TranslatedComponent { if (ship.bulkheads.m.index != retrofitShip.bulkheads.m.index) { item = { buyClassRating: ship.bulkheads.m.class + ship.bulkheads.m.rating, + buyId: ship.bulkheads.m.eddbID, + buyPp: ship.bulkheads.m.pp, buyName: ship.bulkheads.m.name, sellClassRating: retrofitShip.bulkheads.m.class + retrofitShip.bulkheads.m.rating, sellName: retrofitShip.bulkheads.m.name, @@ -424,6 +446,8 @@ export default class CostSection extends TranslatedComponent { if (modId != retroModId) { item = { netCost: 0, retroItem: retroSlotGroup[i] }; if (slotGroup[i].m) { + item.buyId = slotGroup[i].m.eddbID, + item.buyPp = slotGroup[i].m.pp, item.buyName = slotGroup[i].m.name || slotGroup[i].m.grp; item.buyClassRating = slotGroup[i].m.class + slotGroup[i].m.rating; item.netCost = slotGroup[i].discountedCost; diff --git a/src/app/i18n/en.js b/src/app/i18n/en.js index b154cae4..5ef042f3 100644 --- a/src/app/i18n/en.js +++ b/src/app/i18n/en.js @@ -38,6 +38,7 @@ export const terms = { PHRASE_SELECT_SPECIAL: 'Click to select an experimental effect', PHRASE_NO_SPECIAL: 'No experimental effect', PHRASE_SHOPPING_LIST: 'Stations that sell this build', + PHRASE_REFIT_SHOPPING_LIST: 'Stations that sell required modules', PHRASE_TOTAL_EFFECTIVE_SHIELD: 'Total amount of damage that can be taken from each damage type, if using all shield cells', PHRASE_TIME_TO_LOSE_SHIELDS: 'Shields will hold for', PHRASE_TIME_TO_RECOVER_SHIELDS: 'Shields will recover in',