Files
Magic-Garden-Bot/debug_state.js
2025-12-09 23:21:09 +00:00

34 lines
1.2 KiB
JavaScript

const fs = require('fs');
const root = JSON.parse(fs.readFileSync('fullstate.json'));
function safeKeys(obj) { return obj ? Object.keys(obj) : []; }
console.log('Root keys:', safeKeys(root));
console.log('fullState keys:', safeKeys(root.fullState));
const fsData = root.fullState && root.fullState.data;
// Log deep structure to find 'world'
function findKey(obj, key, path = '') {
if (!obj || typeof obj !== 'object') return;
if (Object.keys(obj).includes(key)) {
console.log(`Found ${key} at ${path}/${key}`);
console.log(`Keys of ${key}:`, safeKeys(obj[key]));
if (key === 'world') {
console.log('World Dump:', JSON.stringify(obj[key], null, 2).substring(0, 500));
}
}
Object.keys(obj).forEach(k => {
if (typeof obj[k] === 'object' && obj[k] !== null && k !== 'world') { // Don't recurse into found world
// limit depth
if (path.split('/').length < 4) {
findKey(obj[k], key, path + '/' + k);
}
}
});
}
console.log('Searching for "world"...');
findKey(root, 'world');
console.log('Searching for "tileObjects"...');
findKey(root, 'tileObjects');