Advertisement
twx0r67

Valo_mmr_last_5

Dec 28th, 2022 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | Gaming | 0 0
  1. ((
  2. /** @type {string} */ urlEncodedGetMmrHistoryResponseJson,
  3. ) => {
  4.  
  5.  
  6. const getMmrHistoryResponseJson = decodeURIComponent(urlEncodedGetMmrHistoryResponseJson);
  7. if (/^Error Connecting To Remote Server\b/i.test(getMmrHistoryResponseJson)) {
  8. return getMmrHistoryResponseJson;
  9. }
  10.  
  11. try {
  12. /** @type {{
  13. readonly data: ReadonlyArray<{
  14. readonly mmr_change_to_last_game: number;
  15. }>;
  16. }} */
  17.  
  18. const getMmrHistoryResponse = JSON.parse(getMmrHistoryResponseJson);
  19.  
  20. let text = "";
  21. let i=0;
  22. for (const {mmr_change_to_last_game: mmrChange} of getMmrHistoryResponse.data) {
  23.  
  24. if (i < 5){
  25. text += "[" + mmrChange + "] ";
  26. }
  27. i++;
  28. }
  29.  
  30. return `Pandii's last 5 Valo Elo changes :: ${text}`;
  31. } catch (e) {
  32. return `Failed to parse MMR history: ${e.message}: ${getMmrHistoryResponseJson}`.slice(0, 400);
  33. }
  34. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement