Parse items, AP, and XM response for passcodes, displaying information about the passcode's rewards.
This commit is contained in:
parent
457c3a9094
commit
211b039be6
@ -28,7 +28,7 @@ Features
|
|||||||
- may toggle portals/links/fields
|
- may toggle portals/links/fields
|
||||||
- hack range (yellow circle) and link range (large red circle) for portals. Click on the range link in the sidebar to zoom to link range.
|
- hack range (yellow circle) and link range (large red circle) for portals. Click on the range link in the sidebar to zoom to link range.
|
||||||
- double clicking a portal zooms in and focuses it
|
- double clicking a portal zooms in and focuses it
|
||||||
|
- display of XM and AP rewards for redeemed passcodes by [Dovahkiin](http://bit.ly/mjcode)
|
||||||
|
|
||||||
|
|
||||||
Missing
|
Missing
|
||||||
@ -37,7 +37,6 @@ Missing
|
|||||||
(and probably not going to implement it)
|
(and probably not going to implement it)
|
||||||
|
|
||||||
- logout link (but you wouldn’t want to *quit*, would you?), privacy link, etc.
|
- logout link (but you wouldn’t want to *quit*, would you?), privacy link, etc.
|
||||||
- redeem pretty display
|
|
||||||
|
|
||||||
|
|
||||||
Install
|
Install
|
||||||
|
@ -3,13 +3,45 @@
|
|||||||
// REDEEMING /////////////////////////////////////////////////////////
|
// REDEEMING /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||||
if(data.error) {
|
if (data.error) {
|
||||||
alert('Couldn’t redeem code. It may be used up, invalid or you have redeemed it already. (Code: '+data.error+')');
|
var error = '';
|
||||||
return;
|
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 = 'The passcode cannot be redeemed.';
|
||||||
|
}
|
||||||
|
alert("Error: " + data.error + "\n" + error);
|
||||||
|
} else if (data.result) {
|
||||||
|
var res_level = 0, res_count = 0;
|
||||||
|
var xmp_level = 0, xmp_count = 0;
|
||||||
|
var shield_rarity = '', shield_count = 0;
|
||||||
|
|
||||||
var text = 'Success! However, pretty display is not implemented.\nMaybe you can make sense of the following:\n';
|
// This assumes that each passcode gives only one type of resonator/XMP/shield.
|
||||||
alert(text + JSON.stringify(data));
|
// This may break at some point, depending on changes to passcode functionality.
|
||||||
|
for (var i in data.result.inventoryAward) {
|
||||||
|
var acquired = data.result.inventoryAward[i][2];
|
||||||
|
if (acquired.modResource) {
|
||||||
|
if (acquired.modResource.resourceType === 'RES_SHIELD') {
|
||||||
|
shield_rarity = acquired.modResource.rarity.split('_').map(function (i) {return i[0]}).join('');
|
||||||
|
shield_count++;
|
||||||
|
}
|
||||||
|
} else if (acquired.resourceWithLevels) {
|
||||||
|
if (acquired.resourceWithLevels.resourceType === 'EMITTER_A') {
|
||||||
|
res_level = acquired.resourceWithLevels.level;
|
||||||
|
res_count++;
|
||||||
|
} else if (acquired.resourceWithLevels.resourceType === 'EMP_BURSTER') {
|
||||||
|
xmp_level = acquired.resourceWithLevels.level;
|
||||||
|
xmp_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alert("Passcode redeemed!\n" + [data.result.apAward + 'AP', data.result.xmAward + 'XM', res_count + 'xL' + res_level + ' RES', xmp_count + 'xL' + xmp_level + ' XMP', shield_count + 'x' + shield_rarity + ' SHIELD'].join('/'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setupRedeem = function() {
|
window.setupRedeem = function() {
|
||||||
@ -17,6 +49,6 @@ window.setupRedeem = function() {
|
|||||||
if((e.keyCode ? e.keyCode : e.which) != 13) return;
|
if((e.keyCode ? e.keyCode : e.which) != 13) return;
|
||||||
var data = {passcode: $(this).val()};
|
var data = {passcode: $(this).val()};
|
||||||
window.postAjax('redeemReward', data, window.handleRedeemResponse,
|
window.postAjax('redeemReward', data, window.handleRedeemResponse,
|
||||||
function() { alert('HTTP request failed. Maybe try again?'); });
|
function() { alert('HTTP request failed. Try again?'); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
292
json_examples/redeeming.js
Normal file
292
json_examples/redeeming.js
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
// http://www.ingress.com/rpc/dashboard.redeemReward
|
||||||
|
|
||||||
|
{
|
||||||
|
"passcode": "<insert passcode here>"
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
],
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
],
|
||||||
|
"xmAward": "300"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user