From 00523fc03d743004aad25d0e5d2d6bb7fe30b693 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Tue, 23 Apr 2013 20:21:48 -0500 Subject: [PATCH 1/5] Completely overhauled passcode redemption. * Show table by default, offer plaintext option for reward copy-pasting * Use recommendations from https://plus.google.com/115907431535033114848/posts/PVV9j4fTR2m for item plaintext listing * Break passcode redemption responses and errors into window.REDEEM_* variables * If an item isn't known, don't simply let it slip into the Aurbis. Log it separately. * Don't show AP or XM if the passcode didn't give any. --- code/redeeming.js | 159 +++++++++++++++++++++++---------------------- code/utils_misc.js | 5 +- 2 files changed, 86 insertions(+), 78 deletions(-) diff --git a/code/redeeming.js b/code/redeeming.js index 08fee9ce..e4017d73 100644 --- a/code/redeeming.js +++ b/code/redeeming.js @@ -1,79 +1,90 @@ // REDEEMING ///////////////////////////////////////////////////////// +window.REDEEM_RES_LONG = {'RES_SHIELD' : 'Portal Shield', + 'EMITTER_A' : 'Resonator', + 'EMP_BURSTER' : 'XMP Burster', + 'POWER_CUBE' : 'Power Cube'}; + +window.REDEEM_RES_SHORT = {'RES_SHIELD' : 'S', + 'EMITTER_A' : 'R', + 'EMP_BURSTER' : 'X', + 'POWER_CUBE' : 'C'}; + +window.REDEEM_ERRORS = {'ALREADY_REDEEMED' : 'The passcode has already been redeemed.', + 'ALREADY_REDEEMED_BY_PLAYER' : 'You have already redeemed this passcode.', + 'INVALID_PASSCODE' : 'This passcode is invalid.'}; + +window.REDEEM_STATUSES = {429 : 'You have been rate-limited by the server. Wait a bit and try again.'}; + window.handleRedeemResponse = function(data, textStatus, jqXHR) { - if(data.error) { - var error = ''; - if(data.error === 'ALREADY_REDEEMED') { - error = 'The passcode has already been redeemed.'; - } else if(data.error === 'ALREADY_REDEEMED_BY_PLAYER') { - error = 'You have already redeemed this passcode.'; - } else if(data.error === 'INVALID_PASSCODE') { - error = 'This passcode is invalid.'; - } else { - error = 'There was a problem redeeming the passcode. Try again?'; - } + if (data.error) { + // Errors are now in window.REDEEM_ERRORS. + var error = window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?'; + + // Show an alert and add a console log alert('' + data.error + '\n' + error); + console.log(this.passcode + ' => [ERROR] ' + data.error); } else if(data.result) { - var tblResult = $(''); - tblResult.append($('')); - - if(data.result.apAward) - tblResult.append($('')); - if(data.result.xmAward) - tblResult.append($('')); - - var resonators = {}; - var bursts = {}; - var shields = {}; - var cubes = {}; - - for(var i in data.result.inventoryAward) { - var acquired = data.result.inventoryAward[i][2]; - if(acquired.modResource) { - if(acquired.modResource.resourceType === 'RES_SHIELD') { - var rarity = acquired.modResource.rarity.split('_').map(function (i) {return i[0]}).join(''); - if(!shields[rarity]) shields[rarity] = 0; - shields[rarity] += 1; - } - } else if(acquired.resourceWithLevels) { - if(acquired.resourceWithLevels.resourceType === 'EMITTER_A') { - var level = acquired.resourceWithLevels.level - if(!resonators[level]) resonators[level] = 0; - resonators[level] += 1; - } else if(acquired.resourceWithLevels.resourceType === 'EMP_BURSTER') { - var level = acquired.resourceWithLevels.level - if(!bursts[level]) bursts[level] = 0; - bursts[level] += 1; - } else if(acquired.resourceWithLevels.resourceType === 'POWER_CUBE') { - var level = acquired.resourceWithLevels.level - if(!cubes[level]) cubes[level] = 0; - cubes[level] += 1; - } + // Successful redemption + var payload = {}; + var table_result = [''], plain_result = []; + var table = '', plain = ''; + + // Get AP, XM, and other static quantities + var scores = [[parseInt(data.result.apAward), 'AP'], [parseInt(data.result.xmAward), 'XM']]; + for (var i in scores) { + if (scores[i][0] > 0) { + table_result.push(''); + plain_result.push(scores[i][0] + ' ' + scores[i][1]); } } - - $.each(resonators, function(lvl, count) { - var text = 'Resonator'; - if(count >= 2) text += ' ('+count+')'; - tblResult.append($('')); - }); - $.each(bursts, function(lvl, count) { - var text = 'Xmp Burster'; - if(count >= 2) text += ' ('+count+')'; - tblResult.append($('')); - }); - $.each(cubes, function(lvl, count) { - var text = 'Power Cube'; - if(count >= 2) text += ' ('+count+')'; - tblResult.append($('')); - }); - $.each(shields, function(lvl, count) { - var text = 'Portal Shield'; - if(count >= 2) text += ' ('+count+')'; - tblResult.append($('')); - }); - alert(tblResult, true); + + // Track frequencies and levels of items + for (var i in data.result.inventoryAward) { + var acquired = data.result.inventoryAward[i][2], primary, secondary, type; + if (acquired.modResource) { + primary = acquired.modResource.resourceType; + secondary = acquired.modResource.rarity; + type = 'mod'; + } else if (acquired.resourceWithLevels) { + primary = acquired.resourceWithLevels.resourceType; + secondary = parseInt(acquired.resourceWithLevels.level); + type = 'leveled'; + } + + payload[primary] = payload[primary] || {}; + payload[primary][secondary] = payload[primary][secondary] || {}; + payload[primary][secondary].type = payload[primary][secondary].type || type; + payload[primary][secondary].count = payload[primary][secondary].count || 0; + payload[primary][secondary].count += 1; + } + + // Build the table and plaintext arrays + var keys = Object.keys(payload).sort(); + for (var k in keys) { + var primary = payload[keys[k]], long_name = window.REDEEM_RES_LONG[keys[k]] || keys[k], short_name = window.REDEEM_RES_SHORT[keys[k]] || '?'; + var table_array = [], plain_array = []; + for (var secondary in primary) { + var acquired = primary[secondary]; + var span_prefix = acquired.type === 'leveled' ? '' : ''; + var span_infix = acquired.type === 'leveled' ? secondary : secondary.split('_').map(function (i) {return i[0];}).join(''); + var span_suffix = '' + table_array.push(''); + plain_array.push(primary[secondary].count + '@' + (acquired.type === 'leveled' ? short_name : '') + span_prefix + span_infix + span_suffix); + } + table_result.push(table_array.join('')); + plain_result.push(plain_array.join('/')); + } + + // Add more HTML tags + plain = '' + plain_result.join('/') + ''; + table_result.push(''); plain_result.push(scores[i][0] + ' ' + scores[i][1]); } } // Track frequencies and levels of items - for (var i in data.result.inventoryAward) { + for(var i in data.result.inventoryAward) { var acquired = data.result.inventoryAward[i][2], primary, secondary, type; - if (acquired.modResource) { + if(acquired.modResource) { primary = acquired.modResource.resourceType; secondary = acquired.modResource.rarity; type = 'mod'; - } else if (acquired.resourceWithLevels) { + } else if(acquired.resourceWithLevels) { primary = acquired.resourceWithLevels.resourceType; secondary = parseInt(acquired.resourceWithLevels.level); type = 'leveled'; @@ -62,10 +62,10 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { // Build the table and plaintext arrays var keys = Object.keys(payload).sort(); - for (var k in keys) { + for(var k in keys) { var primary = payload[keys[k]], long_name = window.REDEEM_RES_LONG[keys[k]] || keys[k], short_name = window.REDEEM_RES_SHORT[keys[k]] || '?'; var table_array = [], plain_array = []; - for (var secondary in primary) { + for(var secondary in primary) { var acquired = primary[secondary]; var span_prefix = acquired.type === 'leveled' ? '' : ''; var span_infix = acquired.type === 'leveled' ? secondary : secondary.split('_').map(function (i) {return i[0];}).join(''); @@ -96,7 +96,7 @@ window.setupRedeem = function() { window.postAjax('redeemReward', data, window.handleRedeemResponse, function(response) { var extra = '' - if (response.status) { + if(response.status) { extra = (window.REDEEM_STATUSES[response.status] || 'The server indicated an error.') + ' (HTTP ' + response.status + ')'; } else { extra = 'No status code was returned.'; From 2d662f9e79d11d4909b684f770504e98badb0ced Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Thu, 25 Apr 2013 01:09:22 -0500 Subject: [PATCH 3/5] = IITC Passcode Redemption overhaul, part 2 * Display random words of encouragement for successfully redeemed passcodes * Refactor redeeming into smaller functions, using more jQuery logic * Add redeem "handlers" - combinations of "decoders" and "formatters" for each taxonomy of item * Add heuristic item guessing. If IITC can't figure out directly what an item is, try to guess what taxonomy of item it would be closest to. (For instance, if an item is truly unknown, but has a "rarity" attribute, it's going to be close to a modResource. Likewise, if an unknown item has a "level" attribute, it's going to be close to a resourceWithLevels. ** Tailor formatting and decoding based upon that guess. Worst case: the item is truly a mystery. Don't discard it: display it in a default format. ** Let the user know if we tried to heuristically guess an item. This won't happen unless something changes on the Ingress backend. --- code/redeeming.js | 274 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 202 insertions(+), 72 deletions(-) diff --git a/code/redeeming.js b/code/redeeming.js index 5a6cc4b9..4b9e6a2b 100644 --- a/code/redeeming.js +++ b/code/redeeming.js @@ -1,101 +1,231 @@ // REDEEMING ///////////////////////////////////////////////////////// -window.REDEEM_RES_LONG = {'RES_SHIELD' : 'Portal Shield', - 'EMITTER_A' : 'Resonator', - 'EMP_BURSTER' : 'XMP Burster', - 'POWER_CUBE' : 'Power Cube'}; +/* Resource type names mapped to actual names and abbreviations. + * Add more here if necessary. + */ +window.REDEEM_RESOURCES = { + RES_SHIELD: {long: 'Portal Shield', short: 'SH'}, + EMITTER_A: {long: 'Resonator', short: 'R'}, + EMP_BURSTER: {long: 'XMP Burster', short: 'X'}, + POWER_CUBE: {long: 'Power Cube', short: 'C'} +}; -window.REDEEM_RES_SHORT = {'RES_SHIELD' : 'S', - 'EMITTER_A' : 'R', - 'EMP_BURSTER' : 'X', - 'POWER_CUBE' : 'C'}; +/* Redemption errors. Very self-explanatory. + */ +window.REDEEM_ERRORS = { + ALREADY_REDEEMED: 'The passcode has already been redeemed.', + ALREADY_REDEEMED_BY_PLAYER : 'You have already redeemed this passcode.', + INVALID_PASSCODE: 'This passcode is invalid.' +}; -window.REDEEM_ERRORS = {'ALREADY_REDEEMED' : 'The passcode has already been redeemed.', - 'ALREADY_REDEEMED_BY_PLAYER' : 'You have already redeemed this passcode.', - 'INVALID_PASSCODE' : 'This passcode is invalid.'}; +/* These are HTTP status codes returned by the redemption API. + * TODO: Move to another file? Use more generally across IITC? + */ +window.REDEEM_STATUSES = { + 429: 'You have been rate-limited by the server. Wait a bit and try again.', + 500: 'Internal server error' +}; -window.REDEEM_STATUSES = {429 : 'You have been rate-limited by the server. Wait a bit and try again.'}; +/* Encouragement for people who got it in. + * Just for fun. + */ +window.REDEEM_ENCOURAGEMENT = [ + "Passcode accepted!", + "Access granted.", + "Asset transfer in progress.", + "Well done, Agent.", + "Make the " + {'RESISTANCE' : 'Resistance', 'ALIENS' : 'Enlightened'}[PLAYER.team] + " proud!" +]; + +/* Redemption "handlers" handle decoding and formatting for rewards. + * + * Redemption "decoders" are used for returning the primary attribute (key) from + * different types of items. Pretty self-explanatory. + * + * Redemption "formatters" are used for formatting specific types of password rewards. + * Right now, Ingress has resourceWithLevels (leveled resources) and modResource (mods). + * Resources with levels have levels, and mods have rarity. Format them appropriately. + */ +window.REDEEM_HANDLERS = { + 'resourceWithLevels' : { + decode: function(type, resource) {return resource.level;}, + format: function(acquired, level) { + var prefix = ''; + var suffix = ''; + return { + table: '', + html: acquired.count + '@' + acquired.name.short + prefix + level + suffix, + plain: acquired.count + '@' + acquired.name.short + level + }; + } + }, + 'modResource' : { + decode: function(type, resource) {return resource.rarity;}, + format: function(acquired, rarity) { + var prefix = ''; + var suffix = ''; + var abbreviation = rarity.split('_').map(function (i) {return i[0];}).join(''); + return { + table: '', + html: acquired.count + '@' + prefix + abbreviation + suffix, + plain: acquired.count + '@' + abbreviation + }; + } + }, + 'default' : { + decode: function(type, resource) {return 'UNKNOWN';}, + format: function(acquired, group) { + return { + table: '', + html: acquired.count + '@' + acquired.name.short, + plain: acquired.count + '@' + acquired.name.short + }; + } + } +}; + +/* Redemption "hints" hint at what an unknown resource might be from its object properties. + */ +window.REDEEM_HINTS = { + level: 'resourceWithLevels', + rarity: 'modResource' +}; window.handleRedeemResponse = function(data, textStatus, jqXHR) { + var passcode = this.passcode, to_alert, to_log; + if(data.error) { - // Errors are now in window.REDEEM_ERRORS. - var error = window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?'; - - // Show an alert and add a console log - alert('' + data.error + '\n' + error); - console.log(this.passcode + ' => [ERROR] ' + data.error); + to_alert = '' + data.error + '
' + (window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?'); + to_log = '[ERROR] ' + data.error; } else if(data.result) { - // Successful redemption - var payload = {}; - var table_result = [''], plain_result = []; - var table = '', plain = ''; - - // Get AP, XM, and other static quantities - var scores = [[parseInt(data.result.apAward), 'AP'], [parseInt(data.result.xmAward), 'XM']]; - for(var i in scores) { - if(scores[i][0] > 0) { - table_result.push(''); - plain_result.push(scores[i][0] + ' ' + scores[i][1]); - } - } + var payload = {}; + var encouragement = window.REDEEM_ENCOURAGEMENT[Math.floor(Math.random() * window.REDEEM_ENCOURAGEMENT.length)]; + var inferred = []; + var results = { + 'table' : [''], + 'html' : [], + 'plain' : [] + }; // Track frequencies and levels of items - for(var i in data.result.inventoryAward) { - var acquired = data.result.inventoryAward[i][2], primary, secondary, type; - if(acquired.modResource) { - primary = acquired.modResource.resourceType; - secondary = acquired.modResource.rarity; - type = 'mod'; - } else if(acquired.resourceWithLevels) { - primary = acquired.resourceWithLevels.resourceType; - secondary = parseInt(acquired.resourceWithLevels.level); - type = 'leveled'; - } + $.each(data.result.inventoryAward, function (award_idx, award) { + var acquired = award[2], handler, type, key, name; - payload[primary] = payload[primary] || {}; - payload[primary][secondary] = payload[primary][secondary] || {}; - payload[primary][secondary].type = payload[primary][secondary].type || type; - payload[primary][secondary].count = payload[primary][secondary].count || 0; - payload[primary][secondary].count += 1; + // The "what the heck is this item" heuristic + $.each(acquired, function (taxonomy, resource) { + if('resourceType' in resource) { + if(taxonomy in window.REDEEM_HANDLERS) { + // Cool. We know how to directly handle this item. + handler = { + functions: window.REDEEM_HANDLERS[taxonomy], + taxonomy: taxonomy, + processed_as: taxonomy + }; + } else { + // Let's see if we can get a hint for how we should handle this. + $.each(resource, function (resource_key, resource_value) { + if(resource_key in window.REDEEM_HINTS) { + // We're not sure what this item is, but we can process it like another item + handler = { + functions: (window.REDEEM_HANDLERS[window.REDEEM_HINTS[resource_key]] || window.REDEEM_HANDLERS['default']), + taxonomy: taxonomy, + processed_as: window.REDEEM_HINTS[resource_key] + }; + return false; + } + return true; + }); + + // Fall back to the default handler if necessary + handler = handler || { + functions: window.REDEEM_HANDLERS['default'], + taxonomy: taxonomy, + processed_as: 'default' + }; + } + + // Collect the data that we know + type = resource.resourceType; + key = handler.functions.decode(type, resource); + name = window.REDEEM_RESOURCES[type] || {long: type + '*', short: type[0] + '*'}; + + // Decide if we inferred this resource + if(!(type in window.REDEEM_RESOURCES) || handler.taxonomy !== handler.processed_as) { + inferred.push({type: type, key: key, handler: handler}); + } + return false; + } + return true; + }); + + // Update frequencies + payload[type] = payload[type] || {}; + payload[type][key] = payload[type][key] || {}; + payload[type][key].handler = payload[type][key].handler || handler; + payload[type][key].type = payload[type][key].type || type; + payload[type][key].name = payload[type][key].name || name; + payload[type][key].count = payload[type][key].count || 0; + payload[type][key].count += 1; + }); + + // Get AP, XM, and other static quantities + $.each([{label: 'AP', award: parseInt(data.result.apAward)}, {label: 'XM', award: parseInt(data.result.xmAward)}], function(idx, val) { + if(val.award > 0) { + var formatted = val.award + ' ' + val.label; + results.table.push(''); + results.html.push(formatted); + results.plain.push(formatted); + } + return true; + }); + + // Build the formatted results alphabetically + $.each(Object.keys(payload).sort(), function(type_idx, type) { + $.each(Object.keys(payload[type]).sort(), function(key_idx, key) { + var acquired = payload[type][key]; + $.each(acquired.handler.functions.format(acquired, key), function(format, string) { + results[format].push(string); + return true; + }); + return true; + }); + return true; + }); + + if (inferred.length > 0) { + results.table.push(''); + results.table.push(''); + $.each(inferred, function (idx, val) { + var type = val.type + ':' + val.key, taxonomy = val.handler.taxonomy + ' =~ ' + val.handler.processed_as; + results.table.push(''); + results.table.push(''); + console.log(passcode + ' => [INFERRED] ' + type + ' :: ' + taxonomy); + }); } - // Build the table and plaintext arrays - var keys = Object.keys(payload).sort(); - for(var k in keys) { - var primary = payload[keys[k]], long_name = window.REDEEM_RES_LONG[keys[k]] || keys[k], short_name = window.REDEEM_RES_SHORT[keys[k]] || '?'; - var table_array = [], plain_array = []; - for(var secondary in primary) { - var acquired = primary[secondary]; - var span_prefix = acquired.type === 'leveled' ? '' : ''; - var span_infix = acquired.type === 'leveled' ? secondary : secondary.split('_').map(function (i) {return i[0];}).join(''); - var span_suffix = '' - table_array.push(''); - plain_array.push(primary[secondary].count + '@' + (acquired.type === 'leveled' ? short_name : '') + span_prefix + span_infix + span_suffix); - } - table_result.push(table_array.join('')); - plain_result.push(plain_array.join('/')); - } - - // Add more HTML tags - plain = '' + plain_result.join('/') + ''; - table_result.push(''], @@ -172,7 +172,7 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { // Get AP, XM, and other static quantities $.each([{label: 'AP', award: parseInt(data.result.apAward)}, {label: 'XM', award: parseInt(data.result.xmAward)}], function(idx, val) { if(val.award > 0) { - var formatted = val.award + ' ' + val.label; + var formatted = digits(val.award) + ' ' + val.label; results.table.push(''); results.html.push(formatted); results.plain.push(formatted); @@ -197,7 +197,7 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { results.table.push(''); results.table.push(''); $.each(inferred, function (idx, val) { - var type = val.type + ':' + val.key, taxonomy = val.handler.taxonomy + ' =~ ' + val.handler.processed_as; + var type = val.type + ':' + val.key, taxonomy = val.handler.taxonomy + (val.handler.taxonomy === val.handler.processed_as ? '' : ' =~ ' + val.handler.processed_as); results.table.push(''); results.table.push(''); console.log(passcode + ' => [INFERRED] ' + type + ' :: ' + taxonomy); diff --git a/json_examples/redeeming.js b/json_examples/redeeming.js index 89af2b3d..4982b052 100644 --- a/json_examples/redeeming.js +++ b/json_examples/redeeming.js @@ -7,332 +7,1924 @@ //////////////////////////////////////////////////////////////////////// { - "gameBasket": { - "apGains": [{ - "apGainAmount": "200", - "apTrigger": "REDEEMED_AP" - }], - "deletedEntityGuids": [], - "gameEntities": [], - "inventory": [ - ["00000000000000000000000000000000.5", - 1358631239636, { - "inInventory": { - "acquisitionTimestampMs": "1358631239302", - "playerId": "00000000000000000000000000000000.c" - }, - "modResource": { - "displayName": "Portal Shield", - "rarity": "VERY_RARE", - "resourceType": "RES_SHIELD", - "stats": { - "MITIGATION": "10" - } - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239330", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "inInventory": { - "acquisitionTimestampMs": "1358631239313", - "playerId": "00000000000000000000000000000000.c" - }, - "modResource": { - "displayName": "Portal Shield", - "rarity": "VERY_RARE", - "resourceType": "RES_SHIELD", - "stats": { - "MITIGATION": "10" - } - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 7 - }, - "requiredLevel": 7 - }, - "empWeapon": { - "ammo": 1, - "level": 7 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239348", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 7, - "resourceType": "EMP_BURSTER" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239319", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239342", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239336", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - [ "00000000000000000000000000000000.5", - 1365809491413, { - "accessLevel" : { - "failure" : { - "isAllowed" : false, - "requiredLevel" : 4 - }, - "requiredLevel" : 4 - }, - "inInventory" : { - "acquisitionTimestampMs" : "1365809491260", - "playerId" : "00000000000000000000000000000000.c" - }, - "powerCube" : { - "energy" : 4000 - }, - "resourceWithLevels" : { - "level" : 4, - "resourceType" : "POWER_CUBE" - } - }] - ], - "playerEntity": ["00000000000000000000000000000000.c", - 1358631239530, { - "controllingTeam": { - "team": "RESISTANCE" - }, - "playerPersonal": { - "allowFactionChoice": false, - "allowNicknameEdit": false, - "ap": "326513", - "clientLevel": 26, - "energy": 3205, - "energyState": "XM_OK", - "mediaHighWaterMarks": { - "General": 8, - "RESISTANCE": 9 - }, - "notificationSettings" : { - "maySendPromoEmail" : false, - "shouldSendEmail" : true - } - } - }] - }, - "result": { - "apAward": "200", - "inventoryAward": [ - ["00000000000000000000000000000000.5", - 1358631239636, { - "inInventory": { - "acquisitionTimestampMs": "1358631239302", - "playerId": "00000000000000000000000000000000.c" - }, - "modResource": { - "displayName": "Portal Shield", - "rarity": "VERY_RARE", - "resourceType": "RES_SHIELD", - "stats": { - "MITIGATION": "10" - } - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239330", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "inInventory": { - "acquisitionTimestampMs": "1358631239313", - "playerId": "00000000000000000000000000000000.c" - }, - "modResource": { - "displayName": "Portal Shield", - "rarity": "VERY_RARE", - "resourceType": "RES_SHIELD", - "stats": { - "MITIGATION": "10" - } - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 7 - }, - "requiredLevel": 7 - }, - "empWeapon": { - "ammo": 1, - "level": 7 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239348", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 7, - "resourceType": "EMP_BURSTER" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239319", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239342", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - ["00000000000000000000000000000000.5", - 1358631239636, { - "accessLevel": { - "failure": { - "isAllowed": false, - "requiredLevel": 1 - }, - "requiredLevel": 1 - }, - "inInventory": { - "acquisitionTimestampMs": "1358631239336", - "playerId": "00000000000000000000000000000000.c" - }, - "resourceWithLevels": { - "level": 1, - "resourceType": "EMITTER_A" - } - }], - [ "00000000000000000000000000000000.5", - 1365809491413, { - "accessLevel" : { - "failure" : { - "isAllowed" : false, - "requiredLevel" : 4 - }, - "requiredLevel" : 4 - }, - "inInventory" : { - "acquisitionTimestampMs" : "1365809491260", - "playerId" : "00000000000000000000000000000000.c" - }, - "powerCube" : { - "energy" : 4000 - }, - "resourceWithLevels" : { - "level" : 4, - "resourceType" : "POWER_CUBE" - } - }] - ], - "xmAward": "300" - } -} + "gameBasket": { + "playerEntity": [ + "00000000000000000000000000000000.c", + 1365600000000, + { + "playerPersonal": { + "notificationSettings": { + "shouldSendEmail": true, + "maySendPromoEmail": true + }, + "energyState": "XM_OK", + "energy": 10000, + "clientLevel": 36, + "ap": "12000000", + "mediaHighWaterMarks": { + "RESISTANCE": 9, + "General": 63 + }, + "allowNicknameEdit": false, + "allowFactionChoice": false + }, + "controllingTeam": { + "team": "RESISTANCE" + } + } + ], + "gameEntities": [], + "deletedEntityGuids": [], + "inventory": [ + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "RES_SHIELD", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Shield", + "rarity": "COMMON" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 4 + }, + "requiredLevel": 4 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 4 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 6 + }, + "requiredLevel": 6 + }, + "resourceWithLevels": { + "resourceType": "POWER_CUBE", + "level": 6 + }, + "powerCube": { + "energy": 6000 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 4 + }, + "requiredLevel": 4 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 4 + } + } + ] + ], + "apGains": [ + { + "apTrigger": "REDEEMED_AP", + "apGainAmount": "200" + } + ] + }, + "result": { + "apAward": "1200000", + "xmAward": "10000", + "inventoryAward": [ + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 1 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMITTER_A", + "level": 2 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 3 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 4 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 5 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 1 + }, + "requiredLevel": 1 + }, + "resourceWithLevels": { + "resourceType": "EMP_BURSTER", + "level": 6 + }, + "empWeapon": { + "ammo": 1, + "level": 1 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 6 + }, + "requiredLevel": 6 + }, + "resourceWithLevels": { + "resourceType": "POWER_CUBE", + "level": 7 + }, + "powerCube": { + "energy": 6000 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 6 + }, + "requiredLevel": 6 + }, + "resourceWithLevels": { + "resourceType": "POWER_CUBE", + "level": 8 + }, + "powerCube": { + "energy": 6000 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "RES_SHIELD", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Shield", + "rarity": "COMMON" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "RES_SHIELD", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Shield", + "rarity": "COMMON" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "RES_SHIELD", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Shield", + "rarity": "RARE" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "RES_SHIELD", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Shield", + "rarity": "RARE" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "RES_SHIELD", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Shield", + "rarity": "VERY_RARE" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "RES_SHIELD", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Shield", + "rarity": "VERY_RARE" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 6 + }, + "requiredLevel": 6 + }, + "doesNotExist": { + "resourceType": "MEDIA", + "level": 8 + }, + "powerCube": { + "energy": 6000 + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "modResource": { + "resourceType": "PORTAL_TURRET", + "stats": { + "MITIGATION": "6" + }, + "displayName": "Portal Turret", + "rarity": "VERY_RARE" + } + } + ], + [ + "00000000000000000000000000000000.5", + 1365600000000, + { + "inInventory": { + "playerId": "00000000000000000000000000000000.c", + "acquisitionTimestampMs": "1365600000000" + }, + "accessLevel": { + "failure": { + "isAllowed": false, + "requiredLevel": 6 + }, + "requiredLevel": 6 + }, + "doesNotExist": { + "resourceType": "SUPER_SECRET" + } + } + ] + ] + } +} \ No newline at end of file From 909c760061504a3b576bdc122ccdc78b86adbd90 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Sat, 27 Apr 2013 22:37:21 -0500 Subject: [PATCH 5/5] * New passcode redemption plaintext format using Unicode chars * Don't use digit format for plaintext redemption * Remove unneecessary 'return true' statements * Passcode guessing doesn't dirty up the results window as much * Add asterisks to names for all types of guess --- code/redeeming.js | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/code/redeeming.js b/code/redeeming.js index eb2020c2..1c4931de 100644 --- a/code/redeeming.js +++ b/code/redeeming.js @@ -55,7 +55,7 @@ window.REDEEM_HANDLERS = { var suffix = ''; return { table: '', - html: acquired.count + '@' + acquired.name.short + prefix + level + suffix, + html: acquired.count + '×' + acquired.name.short + prefix + level + suffix, plain: acquired.count + '@' + acquired.name.short + level }; } @@ -68,7 +68,7 @@ window.REDEEM_HANDLERS = { var abbreviation = rarity.split('_').map(function (i) {return i[0];}).join(''); return { table: '', - html: acquired.count + '@' + prefix + abbreviation + suffix, + html: acquired.count + '×' + prefix + abbreviation + suffix, plain: acquired.count + '@' + abbreviation }; } @@ -78,7 +78,7 @@ window.REDEEM_HANDLERS = { format: function(acquired, group) { return { table: '', - html: acquired.count + '@' + acquired.name.short, + html: acquired.count + '×' + acquired.name.short, plain: acquired.count + '@' + acquired.name.short }; } @@ -134,7 +134,6 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { }; return false; } - return true; }); // Fall back to the default handler if necessary @@ -148,15 +147,16 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { // Collect the data that we know type = resource.resourceType; key = handler.functions.decode(type, resource); - name = window.REDEEM_RESOURCES[type] || {long: type + '*', short: type[0] + '*'}; + name = window.REDEEM_RESOURCES[type] || {long: type, short: type[0]}; // Decide if we inferred this resource if(!(type in window.REDEEM_RESOURCES) || handler.taxonomy !== handler.processed_as) { + name.long += '*'; + name.short += '*'; inferred.push({type: type, key: key, handler: handler}); } return false; } - return true; }); // Update frequencies @@ -169,15 +169,13 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { payload[type][key].count += 1; }); - // Get AP, XM, and other static quantities + // Get AP and XM. $.each([{label: 'AP', award: parseInt(data.result.apAward)}, {label: 'XM', award: parseInt(data.result.xmAward)}], function(idx, val) { if(val.award > 0) { - var formatted = digits(val.award) + ' ' + val.label; - results.table.push(''); - results.html.push(formatted); - results.plain.push(formatted); + results.table.push(''); + results.html.push(val.award + ' ' + val.label); + results.plain.push(val.award + ' ' + val.label); } - return true; }); // Build the formatted results alphabetically @@ -186,32 +184,28 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { var acquired = payload[type][key]; $.each(acquired.handler.functions.format(acquired, key), function(format, string) { results[format].push(string); - return true; }); - return true; }); - return true; }); + // Let the user know if we had to guess if (inferred.length > 0) { - results.table.push(''); - results.table.push(''); + results.table.push(''); $.each(inferred, function (idx, val) { - var type = val.type + ':' + val.key, taxonomy = val.handler.taxonomy + (val.handler.taxonomy === val.handler.processed_as ? '' : ' =~ ' + val.handler.processed_as); - results.table.push(''); - results.table.push(''); - console.log(passcode + ' => [INFERRED] ' + type + ' :: ' + taxonomy); + console.log(passcode + + ' => [INFERRED] ' + val.type + ':' + val.key + ' :: ' + + val.handler.taxonomy + ' =~ ' + val.handler.processed_as); }); } // Add table footers - results.table.push('
Passcode accepted!
+' + data.result.apAward + 'AP
+' + data.result.xmAward + 'XM
Passcode accepted!+' + scores[i][0] + ' ' + scores[i][1] + '
L' +lvl+ '' + text + '
L' +lvl+ '' + text + '
L' +lvl+ '' + text + '
'+lvl+''+text+'
' + span_prefix + (acquired.type === 'leveled' ? 'L' : '') + span_infix + span_suffix + '' + long_name + ' [' + primary[secondary].count + ']>>[plaintext]'); + table = '' + table_result.map(function(a) {return '' + a + '';}).join("\n") + '
'; + + // Display formatted versions in a table, plaintext, and the console log + alert(table, true); + console.log(this.passcode + ' => ' + $(plain).text()); } } @@ -81,16 +92,12 @@ window.setupRedeem = function() { $("#redeem").keypress(function(e) { if((e.keyCode ? e.keyCode : e.which) != 13) return; var data = {passcode: $(this).val()}; + window.postAjax('redeemReward', data, window.handleRedeemResponse, function(response) { - var extra = ''; - if(response && response.status) { - if(response.status === 429) { - extra = 'You have been rate-limited by the server. Wait a bit and try again.'; - } else { - extra = 'The server indicated an error.'; - } - extra += '\nResponse: HTTP ' + response.status + '.'; + var extra = '' + if (response.status) { + extra = (window.REDEEM_STATUSES[response.status] || 'The server indicated an error.') + ' (HTTP ' + response.status + ')'; } else { extra = 'No status code was returned.'; } diff --git a/code/utils_misc.js b/code/utils_misc.js index 84562c92..6058a864 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -78,13 +78,14 @@ window.digits = function(d) { // able arguments: http://api.jquery.com/jQuery.ajax/ // error: see above. Additionally it is logged if the request failed. window.postAjax = function(action, data, success, error) { - data = JSON.stringify($.extend({method: 'dashboard.'+action}, data)); + var post_data = JSON.stringify($.extend({method: 'dashboard.'+action}, data)); var remove = function(data, textStatus, jqXHR) { window.requests.remove(jqXHR); }; var errCnt = function(jqXHR) { window.failedRequestCount++; window.requests.remove(jqXHR); }; var result = $.ajax({ url: '/rpc/dashboard.'+action, type: 'POST', - data: data, + data: post_data, + context: data, dataType: 'json', success: [remove, success], error: error ? [errCnt, error] : errCnt, From a80617e6e71e5b6b2531f374dbc50dc688776b41 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Wed, 24 Apr 2013 01:11:38 -0500 Subject: [PATCH 2/5] * Coding style tweaks --- code/redeeming.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/redeeming.js b/code/redeeming.js index e4017d73..5a6cc4b9 100644 --- a/code/redeeming.js +++ b/code/redeeming.js @@ -18,7 +18,7 @@ window.REDEEM_ERRORS = {'ALREADY_REDEEMED' : 'The passcode has already been rede window.REDEEM_STATUSES = {429 : 'You have been rate-limited by the server. Wait a bit and try again.'}; window.handleRedeemResponse = function(data, textStatus, jqXHR) { - if (data.error) { + if(data.error) { // Errors are now in window.REDEEM_ERRORS. var error = window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?'; @@ -33,21 +33,21 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { // Get AP, XM, and other static quantities var scores = [[parseInt(data.result.apAward), 'AP'], [parseInt(data.result.xmAward), 'XM']]; - for (var i in scores) { - if (scores[i][0] > 0) { + for(var i in scores) { + if(scores[i][0] > 0) { table_result.push('
+' + scores[i][0] + ' ' + scores[i][1] + '' + prefix + 'L' + level + suffix + '' + acquired.name.long + ' [' + acquired.count + ']' + prefix + abbreviation + suffix + '' + acquired.name.long + ' [' + acquired.count + ']+' + acquired.name.long + ' [' + acquired.count + ']Passcode accepted!+' + scores[i][0] + ' ' + scores[i][1] + '' + encouragement + '+' + formatted + '**IITC had to guess!**Submit a log including:!' + type + '!' + taxonomy + '' + span_prefix + (acquired.type === 'leveled' ? 'L' : '') + span_infix + span_suffix + '' + long_name + ' [' + primary[secondary].count + ']>>[plaintext]'); - table = '' + table_result.map(function(a) {return '' + a + '';}).join("\n") + '
'; + // Add table footers + results.table.push('
>>' + encouragement + '
' + results.html.join('/') + '') + + '\', true);" style="font-family: monospace;">[plaintext]
'); // Display formatted versions in a table, plaintext, and the console log - alert(table, true); - console.log(this.passcode + ' => ' + $(plain).text()); + to_alert = '' + results.table.map(function(a) {return '' + a + '';}).join("\n") + '
'; + to_log = results.plain.join('/'); } + + alert(to_alert, true); + console.log(passcode + ' => ' + to_log); } window.setupRedeem = function() { $("#redeem").keypress(function(e) { - if((e.keyCode ? e.keyCode : e.which) != 13) return; + if((e.keyCode ? e.keyCode : e.which) !== 13) return; var data = {passcode: $(this).val()}; window.postAjax('redeemReward', data, window.handleRedeemResponse, function(response) { - var extra = '' + var extra = ''; if(response.status) { extra = (window.REDEEM_STATUSES[response.status] || 'The server indicated an error.') + ' (HTTP ' + response.status + ')'; } else { From 297cac1a182ceeaaa5a8b7e83856bdebf4a98884 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Thu, 25 Apr 2013 04:33:36 -0500 Subject: [PATCH 4/5] * Proper digit formatting for passcode redemptions * Add redeeming example used in pull request comments to json_examples/redeeming.js --- code/redeeming.js | 6 +- json_examples/redeeming.js | 2250 ++++++++++++++++++++++++++++++------ 2 files changed, 1924 insertions(+), 332 deletions(-) diff --git a/code/redeeming.js b/code/redeeming.js index 4b9e6a2b..eb2020c2 100644 --- a/code/redeeming.js +++ b/code/redeeming.js @@ -99,8 +99,8 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { to_alert = '' + data.error + '
' + (window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?'); to_log = '[ERROR] ' + data.error; } else if(data.result) { - var payload = {}; var encouragement = window.REDEEM_ENCOURAGEMENT[Math.floor(Math.random() * window.REDEEM_ENCOURAGEMENT.length)]; + var payload = {}; var inferred = []; var results = { 'table' : ['
' + encouragement + '+' + formatted + '**IITC had to guess!**Submit a log including:!' + type + '!' + taxonomy + '' + prefix + 'L' + level + suffix + '' + acquired.name.long + ' [' + acquired.count + ']' + prefix + abbreviation + suffix + '' + acquired.name.long + ' [' + acquired.count + ']+' + acquired.name.long + ' [' + acquired.count + ']+' + formatted + '+' + digits(val.award) + ' ' + val.label + '**IITC had to guess!**Submit a log including:*Guessed (check console)!' + type + '!' + taxonomy + '>>>' + encouragement + '
' + results.html.join('/') + '') + '\', true);" style="font-family: monospace;">[plaintext]
'); // Display formatted versions in a table, plaintext, and the console log to_alert = '' + results.table.map(function(a) {return '' + a + '';}).join("\n") + '
'; - to_log = results.plain.join('/'); + to_log = '[SUCCESS] ' + results.plain.join('/'); } alert(to_alert, true);