Skip to content

Commit

Permalink
Show an indication when Loot Ranger has not included every NPC in the…
Browse files Browse the repository at this point in the history
…ir scheduled attack. (#825)
  • Loading branch information
DeKleineKobini authored Dec 9, 2024
1 parent c05ffa8 commit 282d90a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion extension/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
{ "message": "Update our external library for icons: Font Awesome.", "contributor": "DeKleineKobini" },
{ "message": "Update our external library for charts: ChartJS.", "contributor": "DeKleineKobini" },
{ "message": "Update our external library for mobile drag and drop: DragDropTouch.", "contributor": "DeKleineKobini" },
{ "message": "Use API v2 for the Profile Box in preparation for Torn's incoming changes to the personal stats API", "contributor": "Kwack" }
{ "message": "Use API v2 for the Profile Box in preparation for Torn's incoming changes to the personal stats API", "contributor": "Kwack" },
{ "message": "Show an indication when Loot Ranger has not included every NPC in their scheduled attack.", "contributor": "DeKleineKobini" }
],
"removed": [
{ "message": "Removed bazaar prices from the popup, as they are set to be removed from the API.", "contributor": "DeKleineKobini" },
Expand Down
12 changes: 7 additions & 5 deletions extension/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -1619,12 +1619,13 @@ async function updateNPCs() {
}

async function fetchLootRangers() {
const data = await fetchData("lzpt", { section: "loot" });
const planned = data.time.clear;
const reason = data.time.reason;
const {
time: { clear: planned, reason, attack: ongoing },
...data
} = await fetchData("lzpt", { section: "loot" });

npcs = {
next_update: now + TO_MILLIS.MINUTES * (planned === 0 && !reason ? 1 : 15),
next_update: now + TO_MILLIS.MINUTES * (ongoing || (planned === 0 && !reason) ? 1 : 15),
service: "Loot Rangers",
targets: {},
};
Expand All @@ -1642,7 +1643,8 @@ async function updateNPCs() {
5: hospital + TO_MILLIS.MINUTES * 450,
},
name: npc.name || (NPCS[id] ?? "Unknown"),
order: data.order.findIndex((o) => o === id),
scheduled: npc.next ?? true,
order: data.order.findIndex((o) => o === id) + (npc.next ? 0 : 10),
};

npcs.targets[id].current = getCurrentLevel(npcs.targets[id]);
Expand Down
4 changes: 4 additions & 0 deletions extension/scripts/features/npc-loot-times/ttNPCLootTimes.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@
.npc-information .status.hospital {
color: red;
}

.tt-npc-divider {
text-align: center;
}
14 changes: 13 additions & 1 deletion extension/scripts/features/npc-loot-times/ttNPCLootTimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
);
}

let hasNotScheduled = false;
for (const [id, npc] of Object.entries(npcs.targets).sort(([, a], [, b]) => a.order - b.order)) {
const status = npc.current === 0 ? "Hospital" : `Level ${npc.current}`;
const next = npc.current !== 5 ? npc.current + 1 : false;
Expand All @@ -74,7 +75,7 @@
timer = document.newElement({
type: "span",
class: "timer",
text: formatTime(left, settings),
text: formatTime(left, timerSettings),
dataset: {
seconds: (left / TO_MILLIS.SECONDS).dropDecimals(),
timeSettings: timerSettings,
Expand All @@ -84,6 +85,17 @@
countdownTimers.push(timer);
} else timer = document.newElement({ type: "span", class: "timer", text: "max level" });

if (!hasNotScheduled && npc.scheduled === false) {
hasNotScheduled = true;
content.appendChild(
document.newElement({
type: "div",
class: "tt-npc-divider",
text: "-- not scheduled --",
})
);
}

content.appendChild(
document.newElement({
type: "div",
Expand Down

0 comments on commit 282d90a

Please sign in to comment.