Sandcastle-Builder icon indicating copy to clipboard operation
Sandcastle-Builder copied to clipboard

Numbers as badge names causes problems

Open pickten opened this issue 9 years ago • 6 comments

Briefly, I had a badge named 1921. This caused the badge to be earned on first mNP after load on occasion, and the previous one to always be earned on the first mNP after load. I changed the name to a non-number and both work fine, now. While I understand why it makes sense that this would happen, it would be good to fix this bug.

pickten avatar Aug 19 '15 02:08 pickten

I made a badge named 1234567 and that was fine.

Then I added (in this order, but all in one go): aaaa 123456 bbbb 12345 cccc 1234 dddd

None of those were auto-earned either.

Then I added a 1921 and it wasn't auto-earned. So it doesn't seem to be just the name that's causing the problem.

[edit] I was very wrong

eternaldensity avatar Aug 19 '15 05:08 eternaldensity

Now I've got a problem where after saving and refreshing, the first five Badges load as if there weren't earned. Uh...

eternaldensity avatar Aug 19 '15 05:08 eternaldensity

I tried Coma-ing and that still made the first few Badges reset on save+refresh. Then I loaded an export from before the Coma and now it's all messed up.

Um... yeah this is weird.

eternaldensity avatar Aug 19 '15 05:08 eternaldensity

1921 definitely causes problems that 1234 doesn't.

[edit] no I was wrong, all numbers do cause problems if you refresh. [edit] no, just loading messes it up too. It's definitely getting something out of order somewhere.

eternaldensity avatar Aug 19 '15 06:08 eternaldensity

    Molpy.BadgesToString = function() {
        var s = 'S'; //Semicolon
        var c = 'C'; //Comma
        var str = '';
        for( var which in Molpy.Badges) {
            var badge = Molpy.Badges[which];
            console.debug(which);
            if(badge.group == 'badges') str += badge.earned;
        }
        return str;
    }

I printed the value of 'which' throughout the loop for( var which in Molpy.Badges)

If I add in a numericly named badge to the end, it is listed first instead of last.

I don't think there's anything I can do about that. It's just the way javascript sorts array indices.

eternaldensity avatar Aug 19 '15 06:08 eternaldensity

Solution: name the badge "1921" or #1921 or something else not quite numeric.

eternaldensity avatar Aug 19 '15 06:08 eternaldensity