feat: updated collector
This commit is contained in:
@@ -30,8 +30,8 @@ export const ModelOverlay = {
|
||||
}
|
||||
|
||||
const MB = window.MagicBot;
|
||||
if (!MB || !MB.state || !MB.state.inventory) {
|
||||
container.innerHTML = '<div style="color:red">No State Data</div>';
|
||||
if (!MB || !MB.state || !MB.state.garden || !MB.state.garden.tileObjects) {
|
||||
container.innerHTML = '<div style="color:red">No Garden Data</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,55 +40,68 @@ export const ModelOverlay = {
|
||||
|
||||
// Header Info
|
||||
const header = createElement('div', 'padding: 5px; background: rgba(0,0,0,0.2); margin-bottom: 5px; border-radius: 4px;');
|
||||
const rainProb = MB.weatherTracker ? (MB.weatherTracker.probabilities.rain * 100).toFixed(0) : '?';
|
||||
const frostProb = MB.weatherTracker ? (MB.weatherTracker.probabilities.frost * 100).toFixed(0) : '?';
|
||||
const probs = MB.automation && MB.automation.weatherTracker ? MB.automation.weatherTracker.probabilities : null;
|
||||
|
||||
const rainProb = probs ? (probs.P_Next_Rain_Thunderstorm * 100).toFixed(0) : '?';
|
||||
const frostProb = probs ? (probs.P_Next_Frost * 100).toFixed(0) : '?';
|
||||
const nextEventHrs = probs ? probs.Time_Until_Next_Event_Hrs.toFixed(2) : '?';
|
||||
|
||||
const tracker = MB.automation ? MB.automation.weatherTracker : null;
|
||||
const currentEvent = tracker ? tracker.currentEvent : 'None';
|
||||
|
||||
header.innerHTML = `
|
||||
<div><b>Weather Probabilities:</b> Rain: ${rainProb}% | Frost: ${frostProb}%</div>
|
||||
<div><b>Weather:</b> ${currentEvent || 'Clear'}</div>
|
||||
<div><b>Next Event:</b> ${nextEventHrs} hrs (Rain: ${rainProb}%, Frost: ${frostProb}%)</div>
|
||||
<div><b>Smart Harvest:</b> ${MB.automation && MB.automation.smartHarvest ? '<span style="color:#bada55">ON</span>' : '<span style="color:#ff5252">OFF</span>'}</div>
|
||||
`;
|
||||
list.appendChild(header);
|
||||
|
||||
const plots = MB.state.inventory.items.filter(i => i.itemType === 'Plot');
|
||||
if (plots.length === 0) {
|
||||
container.innerHTML += '<div style="padding:10px">No Plots Found</div>';
|
||||
const garden = MB.state.garden;
|
||||
const tiles = garden ? garden.tileObjects : {};
|
||||
const activeCrops = [];
|
||||
|
||||
if (tiles) {
|
||||
Object.keys(tiles).forEach(key => {
|
||||
|
||||
const tile = tiles[key];
|
||||
if (tile.slots) {
|
||||
tile.slots.forEach((slot, idx) => {
|
||||
activeCrops.push({
|
||||
id: key,
|
||||
idx: idx,
|
||||
name: slot.species || tile.species || 'Unknown',
|
||||
endTime: slot.endTime,
|
||||
startTime: slot.startTime,
|
||||
mutations: slot.mutations || []
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (activeCrops.length === 0) {
|
||||
container.innerHTML += '<div style="padding:10px">No Active Crops Found</div>';
|
||||
container.appendChild(list);
|
||||
return;
|
||||
}
|
||||
|
||||
plots.forEach(plot => {
|
||||
if (!plot.properties) return;
|
||||
const crop = plot.properties.crop;
|
||||
if (!crop) return; // Empty plot
|
||||
|
||||
// Limit to first 50 to prevent lag if huge farm
|
||||
activeCrops.slice(0, 50).forEach(crop => {
|
||||
const row = createElement('div', 'background: rgba(255,255,255,0.05); padding: 5px; border-radius: 4px; display: flex; flex-direction: column; gap: 2px;');
|
||||
|
||||
// Basic Crop Info
|
||||
const name = crop.name;
|
||||
const stage = crop.stage;
|
||||
const totalStages = crop.stages;
|
||||
const isReady = stage >= totalStages;
|
||||
|
||||
// Value Calculation (Simple approximation if actual vals not available)
|
||||
const sellPrice = crop.sellPrice || 0;
|
||||
const currentVal = isReady ? sellPrice : 0;
|
||||
|
||||
// Decision Logic Inspection
|
||||
// We can't easily "spy" on the exact decision function result without modifying it to store state,
|
||||
// but we can replicate the visual indicators.
|
||||
const now = Date.now();
|
||||
const isReady = now >= crop.endTime;
|
||||
const timeLeft = Math.max(0, (crop.endTime - now) / 60000).toFixed(1); // Minutes
|
||||
|
||||
let statusColor = '#aaa';
|
||||
let statusText = 'Growing';
|
||||
let statusText = `${timeLeft} min`;
|
||||
|
||||
if (isReady) {
|
||||
// Check mutation potential
|
||||
const nextWeather = MB.weatherTracker ? MB.weatherTracker.nextEvent : 'Unknown';
|
||||
const hasMutation = crop.mutations && crop.mutations.length > 0;
|
||||
|
||||
if (hasMutation) {
|
||||
statusText = 'Ready (Mutated!)';
|
||||
statusColor = '#bada55'; // Green
|
||||
statusText = `Ready (${crop.mutations.join(', ')})`;
|
||||
statusColor = '#bada55';
|
||||
} else {
|
||||
// This is where we'd ideally show the "Wait vs Harvest" logic
|
||||
// For now, let's show the current value and a theoretical max if waiting
|
||||
statusText = 'Ready';
|
||||
statusColor = '#fff';
|
||||
}
|
||||
@@ -96,18 +109,9 @@ export const ModelOverlay = {
|
||||
|
||||
row.innerHTML = `
|
||||
<div style="font-weight:bold; display:flex; justify-content:space-between;">
|
||||
<span style="color:${Styles.colors.primary}">${name}</span>
|
||||
<span style="color:${Styles.colors.primary}">${crop.name} <span style="font-size:9px; color:#555">#${crop.id}</span></span>
|
||||
<span style="color:${statusColor}">${statusText}</span>
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; color:#888;">
|
||||
<span>Stage: ${stage}/${totalStages}</span>
|
||||
<span>Value: ${currentVal}</span>
|
||||
</div>
|
||||
<!--
|
||||
<div style="font-size:9px; color:#666;">
|
||||
EV: ??? | Boundary: ???
|
||||
</div>
|
||||
-->
|
||||
`;
|
||||
list.appendChild(row);
|
||||
});
|
||||
|
||||
@@ -83,4 +83,4 @@ export const PetsOverlay = {
|
||||
container.appendChild(list);
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user