private int nextUpgradeIndex() {
    if (upgrades == null) return -1 ;
    for (int i = 0 ; i < upgrades.length ; i++) {
      if (upgrades[i] != null && upgradeStates[i] != STATE_INTACT) return i ;
    }
    return -1 ;
  }