feat: updated collector
This commit is contained in:
@@ -5,8 +5,13 @@ console.log("%c Magic Garden Bot Starting... ", "background: #222; color: #bada5
|
||||
const MB = window.MagicBot;
|
||||
|
||||
// --- AUTOMATION STATE ---
|
||||
MB.settings = {
|
||||
debug: false
|
||||
};
|
||||
|
||||
MB.automation = {
|
||||
autoPlant: false,
|
||||
|
||||
autoHarvest: false,
|
||||
autoSell: false,
|
||||
autoSell: false,
|
||||
@@ -48,6 +53,11 @@ console.log("%c Magic Garden Bot Starting... ", "background: #222; color: #bada5
|
||||
|
||||
updateWeatherTracker();
|
||||
|
||||
// Update Weather Stats for UI
|
||||
if (MB.automation.weatherTracker) {
|
||||
MB.automation.weatherTracker.probabilities = getWorldEvents(MB.state);
|
||||
}
|
||||
|
||||
// 1. Auto Harvest
|
||||
if (MB.automation.autoHarvest && MB.state.garden && MB.state.garden.tileObjects) {
|
||||
const now = Date.now();
|
||||
@@ -55,6 +65,16 @@ console.log("%c Magic Garden Bot Starting... ", "background: #222; color: #bada5
|
||||
const tile = MB.state.garden.tileObjects[slotId];
|
||||
if (tile && tile.slots) {
|
||||
tile.slots.forEach((s, idx) => {
|
||||
// Debug Logging
|
||||
if (MB.settings && MB.settings.debug) {
|
||||
console.log(`[AutoHarvest] Checking Slot ${slotId} Index ${idx}:`, {
|
||||
species: s.species,
|
||||
ready: now >= s.endTime,
|
||||
timeLeft: (s.endTime - now) / 1000,
|
||||
mutations: s.mutations
|
||||
});
|
||||
}
|
||||
|
||||
if (now >= s.endTime) {
|
||||
const mutations = s.mutations || [];
|
||||
|
||||
@@ -65,7 +85,7 @@ console.log("%c Magic Garden Bot Starting... ", "background: #222; color: #bada5
|
||||
// Based on standard state structures, if checks fail, better safe than sorry.
|
||||
// Inspecting fullstate shows objectType property on the tile itself.
|
||||
if (tile.objectType && tile.objectType.toLowerCase().includes('egg')) {
|
||||
// console.log("Skipping Egg at slot", slotId);
|
||||
if (MB.settings && MB.settings.debug) console.log(`[AutoHarvest] Skipping Egg at slot ${slotId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,50 +100,54 @@ console.log("%c Magic Garden Bot Starting... ", "background: #222; color: #bada5
|
||||
if (isRainbow) {
|
||||
// Harvest immediately!
|
||||
// Fall through to harvest call.
|
||||
if (MB.settings && MB.settings.debug) console.log(`[AutoHarvest] Harvesting Rainbow at ${slotId}`);
|
||||
}
|
||||
// 2. Gold Strategy: Wait for Frozen (x200 EV)
|
||||
else if (isGold && !isFrozen) {
|
||||
if (MB.settings && MB.settings.debug) console.log(`[AutoHarvest] Skipping Gold (Waiting for Frozen) at ${slotId}`);
|
||||
return; // Skip
|
||||
}
|
||||
// 3. Long Crop Strategy (> 10 mins): Wait for Wet (x2 EV)
|
||||
return; // Skip
|
||||
}
|
||||
// Continues to Bellman Logic below...
|
||||
|
||||
// 4. Bellman Step (Section 3) Smart Harvest
|
||||
// Check if decision module is loaded
|
||||
if (MB.Decision) {
|
||||
const worldEvents = getWorldEvents(MB.state);
|
||||
const cropState = {
|
||||
species: s.species || tile.species,
|
||||
baseValue: s.baseValue || 1, // Need base value source?
|
||||
scale: s.scale || 1, // Can use targetScale or derive current scale?
|
||||
mutations: mutations
|
||||
};
|
||||
// 4. Bellman Step (Section 3) Smart Harvest
|
||||
// Check if decision module is loaded
|
||||
if (MB.Decision) {
|
||||
const worldEvents = getWorldEvents(MB.state);
|
||||
const cropState = {
|
||||
species: s.species || tile.species,
|
||||
baseValue: s.baseValue || 1, // Need base value source?
|
||||
scale: s.scale || 1, // Can use targetScale or derive current scale?
|
||||
mutations: mutations
|
||||
};
|
||||
|
||||
const events = {
|
||||
...worldEvents,
|
||||
Time_Remaining_Hrs: (s.endTime - Date.now()) / 3600000
|
||||
};
|
||||
const logic = MB.Decision.shouldHarvest(cropState, events);
|
||||
const events = {
|
||||
...worldEvents,
|
||||
Time_Remaining_Hrs: (s.endTime - Date.now()) / 3600000
|
||||
};
|
||||
const logic = MB.Decision.shouldHarvest(cropState, events);
|
||||
|
||||
// Log logic occasionally?
|
||||
// console.log(`[SmartHarvest] Slot ${slotId}: ${logic.action}`, logic);
|
||||
if (MB.settings && MB.settings.debug) {
|
||||
console.log(`[SmartHarvest] Slot ${slotId}: ${logic.action}`, logic);
|
||||
}
|
||||
|
||||
if (logic.action === 'WAIT') {
|
||||
return; // Skip harvest
|
||||
if (logic.action === 'WAIT') {
|
||||
return; // Skip harvest
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't spam: check if we just sent it?
|
||||
// For simplicity, relying on server or next state update.
|
||||
// A simple dedupe could be added if needed.
|
||||
MB.sendMsg({
|
||||
type: 'HarvestCrop',
|
||||
slot: parseInt(slotId),
|
||||
slotsIndex: idx,
|
||||
scopePath: ["Room", "Quinoa"]
|
||||
});
|
||||
// Don't spam: check if we just sent it?
|
||||
// For simplicity, relying on server or next state update.
|
||||
// A simple dedupe could be added if needed.
|
||||
MB.sendMsg({
|
||||
type: 'HarvestCrop',
|
||||
slot: parseInt(slotId),
|
||||
slotsIndex: idx,
|
||||
scopePath: ["Room", "Quinoa"]
|
||||
});
|
||||
if (MB.settings && MB.settings.debug) console.log(`[AutoHarvest] Sent HarvestCrop for ${slotId}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user