Skip to content

Instantly share code, notes, and snippets.

function formatGame(game) {
return {
id: game.id,
name: game.name,
openCriticScore: (game.topCriticScore > 0) ? Math.round(game.topCriticScore) : null,
reviewCount: game.numReviews,
percentRecommended: (game.percentRecommended > 0) ? Math.round(game.percentRecommended) : null,
openCriticUrl: buildUrl('game', game.id, game.name),
award: game.tier ? game.tier : ''
};
{
"mastheadScreenshot": {
"fullRes": "//c.opencritic.com/images/games/7407/aibDuCdJiBsP5V7kEx.jpg",
"thumbnail": "//c.opencritic.com/images/games/7407/aibDuCdJiBsP5V7kEx_th.jpg"
},
"bannerScreenshot": {
"fullRes": "//c.opencritic.com/images/games/7407/banner.jpg"
},
"Rating": {
"value": "T",
function formatScore (score, ScoreFormat, showDecimals) {
let ret = '';
if (ScoreFormat.isNumeric) {
// Convert the 0 - 100 score to the 0 - X score of the score format.
ret = '' + (score / ScoreFormat.base);
// If we're showing deicmals
// AND there's a decimal place in this Score format
// AND the remainder is 0