Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/artifacts/artifactory/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
37 changes: 34 additions & 3 deletions content/artifacts/hunt-artifacts/plugin.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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');
Expand All @@ -47,6 +75,7 @@ class Plugin {
let moves = captureArtifacts(
planet.locationId,
this.maxEnergyPercent,
this.minPlanetLevel
);
message.innerText = `Capturing ${moves} planets.`;
} else {
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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)]
})
Expand Down