Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:
- // Sophie "Shinko to kuma"
- //declaring variables
- var hours = 4;
- var scavengeInfo = JSON.parse($('html').find(
- 'script:contains("ScavengeScreen")').html().match(
- /\{.*\:\{.*\:.*\}\}/g)[0]);
- var duration_factor = scavengeInfo[1].duration_factor;
- var duration_exponent = scavengeInfo[1].duration_exponent;
- var duration_initial_seconds = scavengeInfo[1]
- .duration_initial_seconds;
- var lackadaisicalLooters = document.getElementsByClassName("title")[0]
- .innerHTML;
- var humbleHaulers = document.getElementsByClassName("title")[1]
- .innerHTML;
- var cleverCollectors = document.getElementsByClassName("title")[2]
- .innerHTML;
- var greatGatherers = document.getElementsByClassName("title")[3]
- .innerHTML;
- //finding values
- spears = $('.units-entry-all[data-unit=spear]').text().match(
- /\((\d+)\)/)[1];
- swords = $('.units-entry-all[data-unit=sword]').text().match(
- /\((\d+)\)/)[1];
- axes = $('.units-entry-all[data-unit=axe]').text().match(/\((\d+)\)/)[
- 1];
- lightC = 0;
- heavyC = 0;
- if ($('.units-entry-all[data-unit=archer]').text() != "") {
- archer = $('.units-entry-all[data-unit=archer]').text().match(
- /\((\d+)\)/)[1]
- } else archer = 0;
- if ($('.units-entry-all[data-unit=marcher]').text() != "") {
- marcher = $('.units-entry-all[data-unit=marcher]').text().match(
- /\((\d+)\)/)[1]
- } else marcher = 0;
- totalLoot = spears * 25 + swords * 15 + axes * 10 + lightC * 80 +
- heavyC * 50 + archer * 10 + marcher * 50;
- totalSpSwLoot = spears * 25 + swords * 15;
- possibleLoot = spears * 25 + swords * 15 + axes * 10 + lightC * 80 +
- heavyC * 50 + archer * 10 + marcher * 50;
- spearRatio = spears / (spears * 25 + swords * 15);
- swordRatio = swords / (spears * 25 + swords * 15);
- time = hours * 3600;
- haul = ((time / duration_factor - duration_initial_seconds) ** (1 / (
- duration_exponent)) / 100) ** (1 / 2);
- haul1 = haul / 0.1;
- haul2 = haul / 0.25;
- haul3 = haul / 0.5;
- haul4 = haul / 0.75;
- totalHaul = haul1 + haul2 + haul3 + haul4;
- var scavengeOptions = {};
- scavengeOptions[greatGatherers] = [{
- type: 'spear',
- count: (haul4 * (spears / possibleLoot))
- },
- {
- type: 'sword',
- count: (haul4 * (swords / possibleLoot))
- },
- {
- type: 'axe',
- count: (haul4 * (axes / possibleLoot))
- },
- {
- type: 'light',
- count: (haul4 * (lightC / possibleLoot))
- },
- {
- type: 'heavy',
- count: (haul4 * (heavyC / possibleLoot))
- },
- {
- type: 'archer',
- count: (haul4 * (archer / possibleLoot))
- },
- {
- type: 'marcher',
- count: (haul4 * (marcher / possibleLoot))
- },
- ];
- scavengeOptions[cleverCollectors] = [{
- type: 'spear',
- count: (haul3 * (spears / possibleLoot))
- },
- {
- type: 'sword',
- count: (haul3 * (swords / possibleLoot))
- },
- {
- type: 'axe',
- count: (haul3 * (axes / possibleLoot))
- },
- {
- type: 'light',
- count: (haul3 * (lightC / possibleLoot))
- },
- {
- type: 'heavy',
- count: (haul3 * (heavyC / possibleLoot))
- },
- {
- type: 'archer',
- count: (haul3 * (archer / possibleLoot))
- },
- {
- type: 'marcher',
- count: (haul3 * (marcher / possibleLoot))
- },
- ];
- scavengeOptions[humbleHaulers] = [{
- type: 'spear',
- count: (haul2 * (spears / possibleLoot))
- },
- {
- type: 'sword',
- count: (haul2 * (swords / possibleLoot))
- },
- {
- type: 'axe',
- count: (haul2 * (axes / possibleLoot))
- },
- {
- type: 'light',
- count: (haul2 * (lightC / possibleLoot))
- },
- {
- type: 'heavy',
- count: (haul2 * (heavyC / possibleLoot))
- },
- {
- type: 'archer',
- count: (haul2 * (archer / possibleLoot))
- },
- {
- type: 'marcher',
- count: (haul2 * (marcher / possibleLoot))
- },
- ];
- scavengeOptions[lackadaisicalLooters] = [{
- type: 'spear',
- count: (haul1 * (spears / possibleLoot))
- },
- {
- type: 'sword',
- count: (haul1 * (swords / possibleLoot))
- },
- {
- type: 'axe',
- count: (haul1 * (axes / possibleLoot))
- },
- {
- type: 'light',
- count: (haul1 * (lightC / possibleLoot))
- },
- {
- type: 'heavy',
- count: (haul1 * (heavyC / possibleLoot))
- },
- {
- type: 'archer',
- count: (haul1 * (archer / possibleLoot))
- },
- {
- type: 'marcher',
- count: (haul1 * (marcher / possibleLoot))
- },
- ];
- var unitsCapacity = {
- 'spear': 25,
- 'sword': 15,
- 'archer': 10,
- 'axe': 10,
- 'heavy': 50,
- 'light': 80,
- 'marcher': 50,
- 'knight': 100
- }
- run();
- function run() {
- let btn = null;
- for (const option in scavengeOptions) {
- btn = findNextButton(option);
- if (btn) {
- fillInTroops(option, getAvailableUnits(), btn);
- break;
- }
- }
- }
- function fillInTroops(option, availableUnits, button) {
- scavengeOptions[option].forEach(units => {
- const type = units.type;
- const count = units.count;
- let requiredCapacity = availableUnits[type] < count ?
- availableUnits[type] : count;
- $(`input.unitsInput[name='${type}']`).val(
- requiredCapacity).trigger("change");
- $(button).focus();
- });
- }
- function findNextButton(option) {
- let btn = $(`.scavenge-option:contains("${option}")`).find(
- 'a:contains("Start")');
- if (btn.length > 0 && !$(btn).hasClass('btn-disabled'))
- return btn;
- }
- function getAvailableUnits() {
- let availableUnits = {};
- $('.units-entry-all').each((i, e) => {
- const unitName = $(e).attr("data-unit");
- const count = $(e).text().replace(/[()]/, '');
- availableUnits[unitName] = parseInt(count);
- });
- return availableUnits;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement