From 1fd0084058a71547dd6ee7c86077675657d200f1 Mon Sep 17 00:00:00 2001 From: ericet Date: Fri, 2 Jul 2021 18:20:31 -0400 Subject: [PATCH 1/4] added min. planet level to capture --- content/artifacts/hunt-artifacts/plugin.js | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/content/artifacts/hunt-artifacts/plugin.js b/content/artifacts/hunt-artifacts/plugin.js index 9fe2f3d3..184aa036 100644 --- a/content/artifacts/hunt-artifacts/plugin.js +++ b/content/artifacts/hunt-artifacts/plugin.js @@ -1,6 +1,9 @@ +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'; @@ -31,6 +34,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'); @@ -45,6 +73,7 @@ class Plugin { let moves = captureArtifacts( planet.locationId, this.maxEnergyPercent, + this.minPlanetLevel ); message.innerText = `Capturing ${moves} planets.`; } else { @@ -64,7 +93,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); } @@ -74,6 +103,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); @@ -86,7 +117,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); @@ -97,7 +128,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)] }) From 505c2df80948ce5dec31a26d93a3d52b3a728d28 Mon Sep 17 00:00:00 2001 From: ericet Date: Sun, 4 Jul 2021 19:40:11 -0400 Subject: [PATCH 2/4] Filtering out the planets which have no actual artifacts to prospect --- content/artifacts/artifactory/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/artifacts/artifactory/plugin.js b/content/artifacts/artifactory/plugin.js index 4410718f..7520ddc7 100644 --- a/content/artifacts/artifactory/plugin.js +++ b/content/artifacts/artifactory/plugin.js @@ -245,7 +245,7 @@ function Unfound({ selected }) { let [lastLocationId, setLastLocationId] = useState(null); let planets = myPlanetsWithFindable() - .filter(planet => !planet.hasTriedFindingArtifact); + .filter(planet => !planet.hasTriedFindingArtifact && !planet.unconfirmedProspectPlanet && planet.prospectedBlockNumber === undefined ) ; let planetsChildren = planets.map(planet => { let planetEntry = { From 96cef496f9959d7a218fc8b2ff41ee5dc4e46143 Mon Sep 17 00:00:00 2001 From: ericet Date: Sun, 4 Jul 2021 21:49:51 -0400 Subject: [PATCH 3/4] Filtering out the planets which have no actual artifacts to prospect --- content/artifacts/artifactory/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/artifacts/artifactory/plugin.js b/content/artifacts/artifactory/plugin.js index 7520ddc7..a0fc3a1f 100644 --- a/content/artifacts/artifactory/plugin.js +++ b/content/artifacts/artifactory/plugin.js @@ -245,7 +245,7 @@ function Unfound({ selected }) { let [lastLocationId, setLastLocationId] = useState(null); let planets = myPlanetsWithFindable() - .filter(planet => !planet.hasTriedFindingArtifact && !planet.unconfirmedProspectPlanet && planet.prospectedBlockNumber === undefined ) ; + .filter(planet => !planet.hasTriedFindingArtifact && (planet.prospectedBlockNumber === undefined || planet.hasOwnProperty('unconfirmedFindArtifact'))); let planetsChildren = planets.map(planet => { let planetEntry = { From 8a194b9265cbf433ce764f0baf78230d5631d5c3 Mon Sep 17 00:00:00 2001 From: ericet Date: Mon, 5 Jul 2021 16:28:37 -0400 Subject: [PATCH 4/4] per snowtigersoft's suggestion to hide the prospect expired planets --- content/artifacts/artifactory/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/artifacts/artifactory/plugin.js b/content/artifacts/artifactory/plugin.js index a0fc3a1f..c3512b7e 100644 --- a/content/artifacts/artifactory/plugin.js +++ b/content/artifacts/artifactory/plugin.js @@ -245,7 +245,7 @@ function Unfound({ selected }) { let [lastLocationId, setLastLocationId] = useState(null); let planets = myPlanetsWithFindable() - .filter(planet => !planet.hasTriedFindingArtifact && (planet.prospectedBlockNumber === undefined || planet.hasOwnProperty('unconfirmedFindArtifact'))); + .filter(planet => !planet.hasTriedFindingArtifact && (planet.prospectedBlockNumber === undefined || !prospectExpired(currentBlockNumber, planet.prospectedBlockNumber))) let planetsChildren = planets.map(planet => { let planetEntry = {