Sealed Deck development / Draft ranking problem

I have modified the Sealed Deck tournament mode to allow choosing up to two stater packs instead of boosters if they are available for the selected sets. While coding this, I came across an old bug (it seems). Basically, the problem is that certain cards cause the draft ranking code to crash and burn with a null pointer exception. Yes, this has happened before, bu with the ordinary 6 booster packs, it was not quite as likely that the computer got any of the problem cards. But with the increased cardpool of 2 starter packs + 4 boosters, the problem cards are much, much more frequent. Furthermore, 'ranking' basic lands (not normally present in booster packs but included in starter packs) seems to cause the null pointer exception as well.
For basic lands, this was easy enough to fix. I simply added this test to ReadDraftRankings::getRanking():
But I haven't figured out why certain other cards cause this as well. Ironclaw Orcs, for example, is a relatively common card when drawn from the Unlimited (2ED), and causes the problem. More specifically, the bad thing happens here:
In an example run, the Eclipse debugger reports the following values for the variables:
this = ReadDraftRankings (id=39)
cardName = "Ironclaw Orcs" (id=40)
edition = "2ED" (id=46)
rank = null
safeName = "Ironclaw Orcs" (id=40)
Any thoughts why this results in a null pointer exception would be helpful. (The 'null' for rank is, as I understand, irrelevant here.)
For basic lands, this was easy enough to fix. I simply added this test to ReadDraftRankings::getRanking():
- Code: Select all
if (cardName.equals("Island") || cardName.equals("Forest") || cardName.equals("Swamp")
|| cardName.equals("Plains") || cardName.equals("Mountain")) {
return null;
}
But I haven't figured out why certain other cards cause this as well. Ironclaw Orcs, for example, is a relatively common card when drawn from the Unlimited (2ED), and causes the problem. More specifically, the bad thing happens here:
- Code: Select all
rank = (double) draftRankings.get(edition).get(safeName) / (double) setSizes.get(edition);
In an example run, the Eclipse debugger reports the following values for the variables:
this = ReadDraftRankings (id=39)
cardName = "Ironclaw Orcs" (id=40)
edition = "2ED" (id=46)
rank = null
safeName = "Ironclaw Orcs" (id=40)
Any thoughts why this results in a null pointer exception would be helpful. (The 'null' for rank is, as I understand, irrelevant here.)