PlaydateSquad / pdScoreboards

MIT License
2 stars 0 forks source link

Add dummy data funxtion #5

Open GammaGames opened 1 month ago

GammaGames commented 1 month ago

Scenic Route said on discord:

It's also useful to have the API wrapper return a stub when you're designing your UI. I use this:

scores = {
{ player = "ScenicRouteSoftware", rank = 1, value = 6000 },
{ player = "elephanteater", rank = 2, value = 5000 },
{ player = "fatnosegaming", rank = 3, value = 4000 },
{ player = "Poe", rank = 5, value = 2599 },
{ player = "kmchipman", rank = 4, value = 2800 },
{ player = "ledbetter", rank = 7, value = 2390 },
{ player = "pixelghost", rank = 6, value = 2400 },
{ player = "yessclara", rank = 8, value = 2200 },
{ player = "emre", rank = 9, value = 2199 },
{ player = "callmesteam", rank = 5293, value = 30 }
}

might be useful too include a function to check for default user strings, and include them in the dummy data

ebeneliason commented 1 month ago

That's a nice idea. A couple of suggested tweaks to the test data:

Relatedly, everyone using these scoreboards has to figure out how to properly order them for display since they don't come sorted. Perhaps a helper for this would be worth including. Something like this:

function getRankedScores(scores)
    local rankedScores = {}
    for i, score in ipairs(scores) do
        rankedScores[i] = score
    end
    table.sort(rankedScores, function(a, b) return a.rank < b.rank end)
    return rankedScores
end
GammaGames commented 1 month ago

:thinking: It might be useful to make the function something like pdScoreboards.getDummyData(ascending) where you pass a bool that defaults to sorting descending