@SuppressWarnings("unchecked") public void itemStateChanged(ItemEvent ie) { int[] current = new int[BombType.B_NUM]; int curPoints = 0; for (int type = 0; type < BombType.B_NUM; type++) { current[type] = b_choices[type].getSelectedIndex(); curPoints += current[type] * BombType.getBombCost(type); } int availBombPoints = maxPoints - curPoints; for (int type = 0; type < BombType.B_NUM; type++) { b_choices[type].removeItemListener(this); b_choices[type].removeAllItems(); int maxNumBombs = Math.round(availBombPoints / BombType.getBombCost(type)) + current[type]; if(typeMax != null) { if (maxNumBombs > 0 && maxNumBombs > typeMax[type]) maxNumBombs = typeMax[type]; } for (int x = 0; x <= maxNumBombs; x++) { b_choices[type].addItem(Integer.toString(x)); } b_choices[type].setSelectedIndex(current[type]); b_choices[type].addItemListener(this); } }
curBombPoints += bombChoices[i] * BombType.getBombCost(i); / BombType.getBombCost(type)) + bombChoices[type]; if (BombType.getBombCost(type) > maxSize) { maxNumBombs = 0;
/** * @return The number of points taken up by all mounted bombs or other external stores. */ default int getBombPoints() { int points = 0; for (Mounted bomb : getBombs()) { if (bomb.getUsableShotsLeft() > 0) { points += BombType.getBombCost(((BombType) bomb.getType()).getBombType()); } } return points; }
int slots = 1; if (mounted.getType() instanceof BombType) { slots = BombType.getBombCost(((BombType) mounted.getType()).getBombType()); } else if (mounted.getType() instanceof WeaponType) { int type = BombType.getBombTypeForWeapon(mounted.getType()); if (type >= 0) { slots = BombType.getBombCost(type); } else { slots = mounted.getType().getCriticals(this);