Buggy code:
} if ( captainSpecial . equals ( "AddOneWeaponAllKazonMinusOne" ) ) { if ( isKazon ( ) ) { cost -= 1 ; } } if ( "WeaponUpgradesCostOneLess" . equals ( fleetCaptainSpecial ) ) { cost -= 1 ; } } else if ( isTech ( ) ) { if ( ( "VulcanAndFedTechUpgradesMinus2" . equals ( captainSpecial ) ) && ( ( "Federation" . equals ( upgradeFaction ) ) || ( "Vulcan" . equals ( upgradeFaction ) ) ) ) { cost -= 2 ; } if ( "TechUpgradesCostOneLess" . equals ( fleetCaptainSpecial ) ) { cost -= 1 ; } } if ( upgradeSpecial . equals ( "costincreasedifnotbreen" ) ) { if ( ! ( ship . isBreen ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PenaltyOnShipOtherThanDefiant" ) ) { if ( ! ( ship . isDefiant ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFivePointsNonJemHadarShips" ) ) { if ( ! ( ship . isJemhadar ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFiveIfNotRemanWarbird" ) ) { if ( ! ( ship . isRemanWarbird ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PenaltyOnShipOtherThanKeldonClass" ) ) { if ( ! ( ship . isKeldon ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFiveOnNonSpecies8472" ) ) { if ( ! ( ship . isSpecies8472 ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFiveForNonKazon" ) ) { if ( ! ( ship . isKazon ( ) ) ) { cost += 5 ; } } else if ( ( upgradeSpecial . equals ( "CostPlusFiveExceptBajoranInterceptor" ) ) || ( upgradeSpecial . equals ( "PhaserStrike" ) ) ) { if ( ! ( ship . isBajoranInterceptor ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFiveIfNotBorgShip" ) ) { if ( ! ( ship . isBorg ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFiveIfNotRaven" ) ) { if ( ! ( ship . isRaven ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFiveIfNotMirrorUniverse" ) ) { if ( ! ( ship . isMirrorUniverse ( ) ) ) { cost += 5 ; } } else if ( upgradeSpecial . equals ( "PlusFourIfNotPredatorClass" ) ) { if ( ! ( ship . isPredatorClass ( ) ) ) { cost += 4 ; } } else if ( "PlusFiveIfNotGalaxyIntrepidSovereign" . equalsIgnoreCase ( upgradeSpecial ) ) { if ( ( ( ! ( ship . isGalaxy ( ) ) ) && ( ! ( ship . isIntrepid ( ) ) ) ) && ( ! ( ship . isSovereign ( ) ) ) ) { cost += 5 ; } } else if ( ( ( captainSpecial . equals ( "AllUpgradesMinusOneOnIndepedentShip" ) ) && ( "Independent" . equals ( shipFaction ) ) ) && ( ( ! ( this . isCaptain ( ) ) ) && ( ! ( this . isAdmiral ( ) ) ) ) ) { cost -= 1 ; } else if ( ( "PlusFiveIfNotRegentsFlagship" . equals ( upgradeSpecial ) ) && ( ! ( ship . isRegentsFlagship ( ) ) ) ) { cost += 5 ; } else if ( ( "PlusFivePointsNonHirogen" . equals ( upgradeSpecial ) ) && ( ! ( ship . getShipClass ( ) . contains ( "Hirogen" ) ) ) ) { cost += 5 ; } else if ( upgradeSpecial . startsWith ( "Plus5NotShipClass_" ) ) { String reqClass = upgradeSpecial . substring ( 18 ) ; <START_BUG> if ( ship . getShipClass ( ) . replace ( "<seq2seq4repair_space>" , "_" ) . equals ( reqClass ) ) { <END_BUG> cost += 5 ; } } if ( ( captainSpecial . equals ( "OneDominionUpgradeCostsMinusTwo" ) ) && ( ! shipIsSideboard ) ) { if ( isDominion ( ) ) { EquippedUpgrade most = equippedShip . mostExpensiveUpgradeOfFaction ( "Dominion" ) ; if ( ( ( most != null ) && ( ( this ) == ( most . getUpgrade ( ) ) ) ) && ( most == equippedUpgrade ) ) { cost -= 2 ; } } } else if ( ( captainSpecial . equals ( "AddTwoCrewSlotsDominionCostBonus" ) ) && ( ! shipIsSideboard ) ) { if ( isDominion ( ) ) { ArrayList < EquippedUpgrade > all = equippedShip . allUpgradesOfFactionAndType ( "Dominion" , "Crew" ) ; int index = - 1 ; for ( int i = 0 ; i < ( all . size ( ) ) ; ++ i ) { EquippedUpgrade eu = all . get ( i ) ; Upgrade upgradeToTest = eu . getUpgrade ( ) ; if ( ( ( this ) == upgradeToTest ) && ( eu == equippedUpgrade ) ) { index = i ; break ; } } if ( ( index != ( - 1 ) ) && ( index < 2 ) ) { cost -= 1 ; } } } else if ( ( ( captainSpecial . equals ( "AddsHiddenTechSlot" ) ) && ( this . isTech ( ) ) ) && ( ! shipIsSideboard ) ) { ArrayList < EquippedUpgrade > allTechUpgrades = equippedShip . allUpgradesOfFactionAndType ( null , "Tech" ) ; EquippedUpgrade most = null ; for ( EquippedUpgrade eu : allTechUpgrades ) { Upgrade targetTechUpgrade = eu . getUpgrade ( ) ; if ( targetTechUpgrade != null ) { String targetSpecial = targetTechUpgrade . getSpecial ( ) ; if ( ( targetSpecial == null ) || ( ! ( Upgrade . sIneligibleTechUpgrades . contains ( targetSpecial ) ) ) ) { most = eu ; break ; }

Fix:
if ( ! ( ship . getShipClass ( ) . replace ( "<seq2seq4repair_space>" , "_" ) . equals ( reqClass ) ) ) {