diff --git a/content/artifacts/artifactory/plugin.js b/content/artifacts/artifactory/plugin.js index 009756de..5bae1d39 100644 --- a/content/artifacts/artifactory/plugin.js +++ b/content/artifacts/artifactory/plugin.js @@ -246,7 +246,7 @@ function Unfound({ selected }) { let [lastLocationId, setLastLocationId] = useState(null); let planets = myPlanetsWithFindable() - .filter(planet => !planet.hasTriedFindingArtifact); + .filter(planet => !planet.hasTriedFindingArtifact && (planet.prospectedBlockNumber === undefined || !prospectExpired(currentBlockNumber, planet.prospectedBlockNumber))) let planetsChildren = planets.map(planet => { let planetEntry = { diff --git a/content/artifacts/hunt-artifacts/plugin.js b/content/artifacts/hunt-artifacts/plugin.js index 9ea5d8e3..61cae2ef 100644 --- a/content/artifacts/hunt-artifacts/plugin.js +++ b/content/artifacts/hunt-artifacts/plugin.js @@ -1,8 +1,11 @@ // Hunt Artifacts +const planetLevels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + class Plugin { constructor() { this.maxEnergyPercent = 50; + this.minPlanetLevel = 2; } render(container) { container.style.width = '200px'; @@ -33,6 +36,31 @@ class Plugin { } } + let levelLabel = document.createElement('label'); + levelLabel.innerText = 'Min. level to capture'; + levelLabel.style.display = 'block'; + + let level = document.createElement('select'); + level.style.background = 'rgb(8,8,8)'; + level.style.width = '100%'; + level.style.marginTop = '10px'; + level.style.marginBottom = '10px'; + planetLevels.forEach(lvl => { + let opt = document.createElement('option'); + opt.value = `${lvl}`; + opt.innerText = `Level ${lvl}`; + level.appendChild(opt); + }); + level.value = `${this.minPlanetLevel}`; + + level.onchange = (evt) => { + try { + this.minPlanetLevel = parseInt(evt.target.value, 10); + } catch (e) { + console.error('could not parse planet level', e); + } + } + let message = document.createElement('div'); let button = document.createElement('button'); @@ -47,6 +75,7 @@ class Plugin { let moves = captureArtifacts( planet.locationId, this.maxEnergyPercent, + this.minPlanetLevel ); message.innerText = `Capturing ${moves} planets.`; } else { @@ -66,7 +95,7 @@ class Plugin { // TODO: Make asteroid check configurable if (!isAsteroid(planet)) { setTimeout(() => { - moves += captureArtifacts(planet.locationId, this.maxEnergyPercent); + moves += captureArtifacts(planet.locationId, this.maxEnergyPercent, this.minPlanetLevel); message.innerText = `Capturing ${moves} planets.`; }, 0); } @@ -76,6 +105,8 @@ class Plugin { container.appendChild(stepperLabel); container.appendChild(stepper); container.appendChild(percent); + container.appendChild(levelLabel); + container.appendChild(level); container.appendChild(button); container.appendChild(globalButton); container.appendChild(message); @@ -88,7 +119,7 @@ function isAsteroid(planet) { return planet.planetResource === 1; } -function captureArtifacts(fromId, maxDistributeEnergyPercent) { +function captureArtifacts(fromId, maxDistributeEnergyPercent, minCaptureLevel) { const to = df.getPlanetWithId(fromId); const from = df.getPlanetWithId(fromId); @@ -99,7 +130,7 @@ function captureArtifacts(fromId, maxDistributeEnergyPercent) { } const candidates_ = df.getPlanetsInRange(fromId, maxDistributeEnergyPercent) - .filter(p => df.isPlanetMineable(p) && p.owner === "0x0000000000000000000000000000000000000000") + .filter(p => df.isPlanetMineable(p) && p.owner === "0x0000000000000000000000000000000000000000" && p.planetLevel >= minCaptureLevel) .map(to => { return [to, distance(from, to)] })