* Gets the quantity of the currently selected item * on the base. * @return Quantity of selected item on the base. */
| 575 | * @return Quantity of selected item on the base. |
| 576 | */ |
| 577 | int SellState::getQuantity() |
| 578 | { |
| 579 | int qty = 0; |
| 580 | // Soldiers/crafts are individual |
| 581 | switch(getType(_sel)) |
| 582 | { |
| 583 | case SELL_SOLDIER: |
| 584 | case SELL_CRAFT: |
| 585 | return 1; |
| 586 | case SELL_SCIENTIST: |
| 587 | return _base->getAvailableScientists(); |
| 588 | case SELL_ENGINEER: |
| 589 | return _base->getAvailableEngineers(); |
| 590 | case SELL_ITEM: |
| 591 | qty = _base->getItems()->getItem(_items[getItemIndex(_sel)]); |
| 592 | if (Options::storageLimitsEnforced && _origin == OPT_BATTLESCAPE) |
| 593 | { |
| 594 | for (std::vector<Transfer*>::iterator j = _base->getTransfers()->begin(); j != _base->getTransfers()->end(); ++j) |
| 595 | { |
| 596 | if ((*j)->getItems() == _items[getItemIndex(_sel)]) |
| 597 | { |
| 598 | qty += (*j)->getQuantity(); |
| 599 | } |
| 600 | } |
| 601 | for (std::vector<Craft*>::iterator j = _base->getCrafts()->begin(); j != _base->getCrafts()->end(); ++j) |
| 602 | { |
| 603 | qty += (*j)->getItems()->getItem(_items[getItemIndex(_sel)]); |
| 604 | } |
| 605 | } |
| 606 | return qty; |
| 607 | } |
| 608 | |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * Increases the quantity of the selected item to sell by one. |
no test coverage detected