/** * SystemsTestScene.js * Test environment for all game systems * NO SPRITES REQUIRED - Console-based testing * Created: January 4, 2026 */ class SystemsTestScene extends Phaser.Scene { constructor() { super({ key: 'SystemsTestScene' }); } create() { console.log('๐Ÿงช === SYSTEMS TEST SCENE LOADING ==='); // Black background this.cameras.main.setBackgroundColor('#000000'); // Initialize mock player this.initializeMockPlayer(); // Initialize master systems this.initializeSystems(); // Create test UI this.createTestUI(); // Setup keyboard controls this.setupControls(); // Auto-run basic tests this.runBasicTests(); console.log('โœ… Systems Test Scene Ready!'); console.log('๐Ÿ“Œ Access systems: window.testSystems or game.scene.scenes[0].masterSystems'); } initializeMockPlayer() { // Create mock player object this.player = { energy: 50, maxEnergy: 100, money: 10000, farmLevel: 1, isMarried: false, spouse: null, farmhouseLevel: 0, // Mock inventory inventory: { items: new Map(), addItem: function (itemId, amount) { const current = this.items.get(itemId) || 0; this.items.set(itemId, current + amount); console.log(` ๐Ÿ“ฆ Added ${amount}x ${itemId} (total: ${current + amount})`); }, removeItem: function (itemId, amount) { const current = this.items.get(itemId) || 0; const newAmount = Math.max(0, current - amount); this.items.set(itemId, newAmount); console.log(` ๐Ÿ“ฆ Removed ${amount}x ${itemId} (total: ${newAmount})`); }, hasItem: function (itemId) { return this.items.has(itemId) && this.items.get(itemId) > 0; }, getItemCount: function (itemId) { return this.items.get(itemId) || 0; } }, // Mock methods hasCompletedQuest: function (questId) { return this.completedQuests.includes(questId); }, hasBuilding: function (buildingId) { return this.buildings.includes(buildingId); }, hasMaterials: function (materials) { for (const [item, amount] of Object.entries(materials)) { if (this.inventory.getItemCount(item) < amount) { return false; } } return true; }, removeMaterials: function (materials) { for (const [item, amount] of Object.entries(materials)) { this.inventory.removeItem(item, amount); } }, getRelationshipHearts: function (npcId) { return this.relationships[npcId] || 0; }, getRelationshipLevel: function (npcId) { return this.relationships[npcId] || 0; }, getSkillLevel: function (skill) { return this.skills[skill] || 0; }, hasMetNPC: function (npcId) { return this.metNPCs.includes(npcId); }, getPosition: function () { return { x: 512, y: 384 }; }, rebuildSprite: function (appearance) { console.log(' ๐Ÿ‘ค Player sprite rebuilt:', appearance); }, teleportToLocation: function (location) { console.log(` ๐Ÿšช Teleported to: ${location}`); }, // Data completedQuests: [], buildings: [], metNPCs: ['kai', 'ana', 'gronk'], relationships: { kai: 5, ana: 10, gronk: 3 }, skills: { farming: 2, combat: 1, alchemy: 0 }, debt: 0 }; // Expose to window for console access window.testPlayer = this.player; // Mock game object this.game.player = this.player; console.log(' โœ“ Mock player created'); } initializeSystems() { try { // Initialize Master Systems Manager this.masterSystems = new MasterGameSystemsManager(this); // Expose to window for console access window.testSystems = this.masterSystems; console.log(' โœ“ Master Systems Manager initialized'); console.log(' โœ“ All 9 systems loaded'); } catch (error) { console.error('โŒ Error initializing systems:', error); this.showError('System initialization failed: ' + error.message); } } createTestUI() { // Title this.add.text(512, 40, '๐Ÿงช SYSTEMS TEST SCENE', { fontSize: '36px', color: '#00ff00', fontFamily: 'monospace', fontStyle: 'bold' }).setOrigin(0.5); // Status panel const statusText = [ 'โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•', 'SYSTEMS STATUS:', 'โœ… Sleep System: Ready', 'โœ… Crafting Tables: Ready', 'โœ… Bakery Shop: Ready', 'โœ… Barber Shop: Ready', 'โœ… Lawyer Office: Ready', 'โœ… Zombie Miners: Ready', 'โœ… Town Growth: Ready', 'โœ… NPC Privacy: Ready', 'โœ… Master Coordinator: Ready', 'โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•' ].join('\n'); this.statusPanel = this.add.text(50, 100, statusText, { fontSize: '14px', color: '#00ff00', fontFamily: 'monospace', lineSpacing: 3 }); // Instructions const instructions = [ '', '๐ŸŽฎ KEYBOARD CONTROLS:', ' [1] - Test Sleep System', ' [2] - Test Crafting System', ' [3] - Test Bakery Shop', ' [4] - Test Town Growth', ' [5] - Test Save/Load', ' [R] - Run All Tests', ' [ESC] - Return to Main Menu', '', '๐Ÿ’ป CONSOLE ACCESS:', ' window.testSystems โ†’ All systems', ' window.testPlayer โ†’ Mock player', ' Quick: const s = window.testSystems;', '', '๐Ÿ“ EXAMPLE COMMANDS:', ' s.sleepSystem.sleep()', ' s.craftingSystem.canCraft("wooden_hoe")', ' s.townGrowthSystem.population', ' s.saveAllSystems()', '', 'Press [1-5] to run tests or open browser console!' ].join('\n'); this.add.text(50, 340, instructions, { fontSize: '13px', color: '#ffff00', fontFamily: 'monospace', lineSpacing: 2 }); // Test results panel this.testResultsY = 100; this.testResults = []; } setupControls() { // ESC to exit this.input.keyboard.on('keydown-ESC', () => { console.log('Returning to PreloadScene...'); this.scene.start('PreloadScene'); }); // Number keys for tests this.input.keyboard.on('keydown-ONE', () => this.testSleepSystem()); this.input.keyboard.on('keydown-TWO', () => this.testCraftingSystem()); this.input.keyboard.on('keydown-THREE', () => this.testBakerySystem()); this.input.keyboard.on('keydown-FOUR', () => this.testTownGrowth()); this.input.keyboard.on('keydown-FIVE', () => this.testSaveLoad()); this.input.keyboard.on('keydown-R', () => this.runAllTests()); } runBasicTests() { console.log('\n๐Ÿ”ฌ === RUNNING BASIC TESTS ===\n'); // Test 1: Systems exist console.log('TEST 1: Systems Initialization'); console.log(' Sleep System:', this.masterSystems.sleepSystem ? 'โœ…' : 'โŒ'); console.log(' Crafting System:', this.masterSystems.craftingSystem ? 'โœ…' : 'โŒ'); console.log(' Bakery System:', this.masterSystems.bakerySystem ? 'โœ…' : 'โŒ'); console.log(' Barber System:', this.masterSystems.barberSystem ? 'โœ…' : 'โŒ'); console.log(' Lawyer System:', this.masterSystems.lawyerSystem ? 'โœ…' : 'โŒ'); console.log(' Zombie Miners:', this.masterSystems.zombieMinerSystem ? 'โœ…' : 'โŒ'); console.log(' Town Growth:', this.masterSystems.townGrowthSystem ? 'โœ…' : 'โŒ'); console.log(' NPC Privacy:', this.masterSystems.npcPrivacySystem ? 'โœ…' : 'โŒ'); // Test 2: Mock player console.log('\nTEST 2: Mock Player'); console.log(' Energy:', this.player.energy + '/' + this.player.maxEnergy, 'โœ…'); console.log(' Money:', this.player.money + 'g', 'โœ…'); console.log(' Inventory:', this.player.inventory ? 'โœ…' : 'โŒ'); console.log('\nโœ… Basic tests complete!\n'); } testSleepSystem() { console.log('\n๐ŸŒ™ === TESTING SLEEP SYSTEM ===\n'); const sleep = this.masterSystems.sleepSystem; // Test 1: Can sleep check const canSleep = sleep.canSleepNow(); console.log('TEST 1: Can Sleep Now?', canSleep.canSleep ? 'โœ…' : 'โŒ', canSleep.message || ''); // Test 2: Current bed info const bedInfo = sleep.getCurrentBedInfo(); console.log('TEST 2: Current Bed:', bedInfo.name, 'โœ…'); console.log(' Energy Regen:', bedInfo.energyRegen + '%'); // Test 3: Try to sleep console.log('TEST 3: Attempting Sleep...'); const result = sleep.sleep(); console.log(' Result:', result.success ? 'โœ… SUCCESS' : 'โŒ FAILED', result.message || ''); console.log('\nโœ… Sleep System tests complete!\n'); } testCraftingSystem() { console.log('\n๐Ÿ”จ === TESTING CRAFTING SYSTEM ===\n'); const crafting = this.masterSystems.craftingSystem; // Test 1: Check recipe without ingredients console.log('TEST 1: Can craft wooden_hoe (no ingredients)?'); let check = crafting.canCraft('wooden_hoe'); console.log(' Result:', check.canCraft ? 'โœ…' : 'โŒ', check.reason || ''); if (check.missingIngredients) { console.log(' Missing:', JSON.stringify(check.missingIngredients)); } // Test 2: Add ingredients console.log('\nTEST 2: Adding ingredients...'); this.player.inventory.addItem('wood', 20); this.player.inventory.addItem('rope', 5); // Test 3: Check recipe with ingredients console.log('\nTEST 3: Can craft wooden_hoe (with ingredients)?'); check = crafting.canCraft('wooden_hoe'); console.log(' Result:', check.canCraft ? 'โœ… CAN CRAFT' : 'โŒ CANNOT CRAFT'); // Test 4: Try crafting if (check.canCraft) { console.log('\nTEST 4: Crafting wooden_hoe...'); const result = crafting.craft('wooden_hoe', 1); console.log(' Result:', result.success ? 'โœ… SUCCESS' : 'โŒ FAILED'); console.log(' Message:', result.message); } console.log('\nโœ… Crafting System tests complete!\n'); } testBakerySystem() { console.log('\n๐Ÿฅ– === TESTING BAKERY SYSTEM ===\n'); const bakery = this.masterSystems.bakerySystem; // Test 1: Shop status console.log('TEST 1: Bakery Status'); const shopData = bakery.getShopUIData(); console.log(' Unlocked:', shopData.isUnlocked ? 'โœ…' : 'โŒ'); console.log(' Open:', shopData.isOpen ? 'โœ…' : 'โŒ'); // Test 2: Try to buy item console.log('\nTEST 2: Buying fresh_bread...'); const result = bakery.buyItem('fresh_bread', 2); console.log(' Result:', result.success ? 'โœ… SUCCESS' : 'โŒ FAILED'); console.log(' Message:', result.message || 'Item purchased'); console.log('\nโœ… Bakery System tests complete!\n'); } testTownGrowth() { console.log('\n๐Ÿ˜๏ธ === TESTING TOWN GROWTH SYSTEM ===\n'); const town = this.masterSystems.townGrowthSystem; // Test 1: Current population console.log('TEST 1: Population Status'); console.log(' Current:', town.population + '/' + town.maxPopulation, 'โœ…'); console.log(' Status:', town.getTownStatus(), 'โœ…'); // Test 2: Check unlock requirements console.log('\nTEST 2: Population Slot Requirements'); let unlockedCount = 0; let lockedCount = 0; town.populationSlots.forEach((slot, index) => { if (slot.unlocked) { unlockedCount++; } else { lockedCount++; if (index < 10) { // Show first few console.log(` Slot ${index}:`, JSON.stringify(slot.requirement)); } } }); console.log(' Unlocked:', unlockedCount, 'โœ…'); console.log(' Locked:', lockedCount, 'โœ…'); // Test 3: Check for new unlocks console.log('\nTEST 3: Checking for new unlocks...'); const newUnlocks = town.checkPopulationUnlocks(); console.log(' New slots unlocked:', newUnlocks, 'โœ…'); console.log('\nโœ… Town Growth tests complete!\n'); } testSaveLoad() { console.log('\n๐Ÿ’พ === TESTING SAVE/LOAD SYSTEM ===\n'); // Test 1: Save all systems console.log('TEST 1: Saving all systems...'); const saveData = this.masterSystems.saveAllSystems(); console.log(' Save data created:', saveData ? 'โœ…' : 'โŒ'); console.log(' Systems saved:', Object.keys(saveData.systems).length); // Test 2: Store in localStorage console.log('\nTEST 2: Storing to localStorage...'); try { localStorage.setItem('game_save_test', JSON.stringify(saveData)); console.log(' Stored successfully โœ…'); } catch (error) { console.error(' Storage failed โŒ', error); } // Test 3: Modify state console.log('\nTEST 3: Modifying state...'); const originalMoney = this.player.money; this.player.money = 999999; console.log(' Money changed:', originalMoney, 'โ†’', this.player.money, 'โœ…'); // Test 4: Load from localStorage console.log('\nTEST 4: Loading from localStorage...'); try { const loadedData = JSON.parse(localStorage.getItem('game_save_test')); this.masterSystems.loadAllSystems(loadedData); console.log(' Loaded successfully โœ…'); } catch (error) { console.error(' Load failed โŒ', error); } console.log('\nโœ… Save/Load tests complete!\n'); } runAllTests() { console.log('\n๐Ÿ”ฌ === RUNNING ALL TESTS ===\n'); this.testSleepSystem(); this.testCraftingSystem(); this.testBakerySystem(); this.testTownGrowth(); this.testSaveLoad(); console.log('\nโœ… ALL TESTS COMPLETE!\n'); } showError(message) { this.add.text(512, 600, 'โŒ ERROR: ' + message, { fontSize: '18px', color: '#ff0000', fontFamily: 'monospace' }).setOrigin(0.5); } update(time, delta) { // Update master systems if (this.masterSystems) { this.masterSystems.update(time, delta); } } }