Skip to content

Instantly share code, notes, and snippets.

@x1024
Last active December 19, 2015 03:49
Show Gist options
  • Save x1024/5892691 to your computer and use it in GitHub Desktop.
Save x1024/5892691 to your computer and use it in GitHub Desktop.
var data = {
'bone-spear': 1,
'bolas': 4,
'bullets': 30,
'rifle': 1,
'cured-meat': 38,
'steel-sword': 1,
'torch': 5,
'laser-rifle': 1,
'energy-cell': 7,
'grenade': 3
}
function arm()
{
for (var item in data) {
var qty = data[item];
console.log(item, qty);
var $item = $('#outfit_row_' + item);
while (true) {
var bagFull = parseInt($('#bagspace').text().substring(5), 10) == 0
var available = parseInt($item.find('.row_val:eq(2)').text(), 10);
var taken = parseInt($item.find('.row_val:eq(0) span').text(), 10);
if (available <= 0 || taken >= qty || bagFull) {
break;
}
$item.find('.upBtn').click();
}
}
}
arm(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment