Module 6 · In Studio · challenge 2 of 2 in this lesson
challenges/work/leaderboard_badges.luau turns a coin amount into a whole, valid ordered score: rounded down, and 0 for a negative number, NaN or infinity
A test in Studio grades it and prints a pass code.
Open
Level 3, Professional
Challenge
Write the scoring and award rules as pure functions in the learner file. Start from the m14-ship tag in the game repo, and see the solution in challenges/solutions/leaderboards-badges.md. The capstone's capstone_leaderboard challenge builds on the same ideas.
- Start from
- The game at milestone m14 (download)
- Grade it
- In Studio, press Play, then run
game.ServerScriptService.RunGameTests:Invoke("leaderboards-badges", "leaderboards-badges-rules")in the server command bar. Copy the pass code from Output.
Done means
- challenges/work/leaderboard_badges.luau turns a coin amount into a whole, valid ordered score: rounded down, and 0 for a negative number, NaN or infinity
- It lists the badges a round earns in this order: FIRST_DRILL when the player survived, then DRONE_DOWN when the drone went down. A badge already owned is left out
- It never changes the owned table it is given (the test passes a frozen one)
- It turns entries, best first, into rows that read "1. Mira - 155" (rank, name, score), with rank 1 on the first row and no rows for no entries
- challenges/leaderboards-badges.luau prints TEST PASS for every check