Trying to get my head around this. As part of trying to expand maximize to handle Crown of Thrones (and later Buddy Bjorn) I'm trying to make an array list of all familiars which will improve on the best previous headgear in the Crown of Thrones. I'll then iterate over it in MaximiserSpeculation in the Hat section.
However, I'm currently getting a weird null pointer exception at the marked line ****. Given that I've already checked that familiar isn't null, why am I getting a null pointer exception trying to do this.enthronedFamiliars.add( familiar ) ?
Probably obvious, but I can't see it !
However, I'm currently getting a weird null pointer exception at the marked line ****. Given that I've already checked that familiar isn't null, why am I getting a null pointer exception trying to do this.enthronedFamiliars.add( familiar ) ?
Probably obvious, but I can't see it !
Code:
In public class Evaluator:
private ArrayList<FamiliarData> enthronedFamiliars;
In Evaluator.enumerateEquipment:
if ( item.getItemId() == ItemPool.HATSEAT )
{
Boolean useHat = false;
double bestScore = 0;
FamiliarData bestFamiliar = FamiliarData.NO_FAMILIAR;
// Check each familiar in hat to see if they are worthwhile
List familiarList = KoLCharacter.getFamiliarList();
String[] familiars = new String[ familiarList.size() ];
for ( int f = 0; f < familiarList.size(); ++f )
{
FamiliarData familiar = (FamiliarData) familiarList.get( f );
KoLmafia.updateDisplay( "Familiar: " + familiar.getName() );
if ( familiar != null && familiar != FamiliarData.NO_FAMILIAR && familiar.enthroneable() &&
!familiar.equals( KoLCharacter.getFamiliar() ) && !this.enthronedFamiliars.contains( familiar ) )
{
spec.setEnthroned( familiar );
double score = spec.getScore();
if ( score > this.maxUseful( slot ) )
{
this.enthronedFamiliars.add( familiar ); **** null pointer exception ****
if ( score > bestScore )
{
useHat = true;
bestScore = score;
bestFamiliar = familiar;
}
}
}
}
if ( useHat == false )
{
continue;
}
spec.setEnthroned( bestFamiliar );
spec.getScore();
spec.failed = false;