(fit, options, callback)
| 23 | |
| 24 | |
| 25 | def exportMultiBuy(fit, options, callback): |
| 26 | itemAmounts = {} |
| 27 | |
| 28 | for module in fit.modules: |
| 29 | if module.item: |
| 30 | # Mutated items are of no use for multibuy |
| 31 | if module.isMutated: |
| 32 | continue |
| 33 | _addItem(itemAmounts, module.item) |
| 34 | if module.charge and options[PortMultiBuyOptions.LOADED_CHARGES]: |
| 35 | _addItem(itemAmounts, module.charge, module.numCharges) |
| 36 | |
| 37 | for drone in fit.drones: |
| 38 | _addItem(itemAmounts, drone.item, drone.amount) |
| 39 | |
| 40 | for fighter in fit.fighters: |
| 41 | _addItem(itemAmounts, fighter.item, fighter.amount) |
| 42 | |
| 43 | if options[PortMultiBuyOptions.CARGO]: |
| 44 | for cargo in fit.cargo: |
| 45 | _addItem(itemAmounts, cargo.item, cargo.amount) |
| 46 | |
| 47 | if options[PortMultiBuyOptions.IMPLANTS]: |
| 48 | for implant in fit.implants: |
| 49 | _addItem(itemAmounts, implant.item) |
| 50 | |
| 51 | if options[PortMultiBuyOptions.BOOSTERS]: |
| 52 | for booster in fit.boosters: |
| 53 | _addItem(itemAmounts, booster.item) |
| 54 | |
| 55 | if options[PortMultiBuyOptions.OPTIMIZE_PRICES]: |
| 56 | |
| 57 | def formatCheaperExportCb(replacementsCheaper): |
| 58 | updatedAmounts = {} |
| 59 | for item, itemAmount in itemAmounts.items(): |
| 60 | _addItem(updatedAmounts, replacementsCheaper.get(item, item), itemAmount) |
| 61 | string = _prepareString(fit.ship.item, updatedAmounts) |
| 62 | callback(string) |
| 63 | |
| 64 | priceSvc = sPrc.getInstance() |
| 65 | priceSvc.findCheaperReplacements(itemAmounts, formatCheaperExportCb) |
| 66 | else: |
| 67 | string = _prepareString(fit.ship.item, itemAmounts) |
| 68 | if callback: |
| 69 | callback(string) |
| 70 | else: |
| 71 | return string |
| 72 | |
| 73 | |
| 74 | def _addItem(container, item, quantity=1): |
no test coverage detected