Files
novafarma/EMERGENCY_SYSTEMS_RECOVERY/ScooterRepairSystem.js
2026-01-16 02:43:46 +01:00

161 lines
4.4 KiB
JavaScript

/**
* SCOOTER REPAIR SYSTEM
* Broken scooter needs parts + tools to repair before being driveable
*/
class ScooterRepairSystem {
constructor(scene) {
this.scene = scene;
// Required parts for repair
this.requiredParts = {
scooter_engine: 1,
scooter_wheel: 2,
scooter_fuel_tank: 1,
scooter_handlebars: 1
};
// Required tools
this.requiredTools = {
wrench: 1,
screwdriver: 1
};
this.isRepaired = false;
}
/**
* Check if player has all required parts
*/
hasAllParts() {
const inv = this.scene.inventorySystem;
if (!inv) return false;
for (const [part, count] of Object.entries(this.requiredParts)) {
if (!inv.hasItem(part) || inv.getItemCount(part) < count) {
console.log(`🚫 Missing: ${part} (Need ${count})`);
return false;
}
}
return true;
}
/**
* Check if player has required tools
*/
hasAllTools() {
const inv = this.scene.inventorySystem;
if (!inv) return false;
for (const [tool, count] of Object.entries(this.requiredTools)) {
if (!inv.hasItem(tool) || inv.getItemCount(tool) < count) {
console.log(`🚫 Missing tool: ${tool} (Need ${count})`);
return false;
}
}
return true;
}
/**
* Attempt to repair scooter
*/
repairScooter() {
if (this.isRepaired) {
console.log('✅ Scooter already repaired!');
return false;
}
if (!this.hasAllParts()) {
console.log('🚫 Missing required parts!');
this.listMissingParts();
return false;
}
if (!this.hasAllTools()) {
console.log('🚫 Missing required tools!');
return false;
}
// Consume parts (tools are NOT consumed)
const inv = this.scene.inventorySystem;
for (const [part, count] of Object.entries(this.requiredParts)) {
inv.removeItem(part, count);
}
this.isRepaired = true;
console.log('✅🛵 SCOOTER REPAIRED! Press V to drive!');
// Find scooter entity and enable it
if (this.scene.vehicles) {
for (const vehicle of this.scene.vehicles) {
if (vehicle.type === 'scooter') {
vehicle.isEnabled = true;
vehicle.updateVisual(); // Make it look new
}
}
}
// Visual feedback
this.scene.events.emit('show-floating-text', {
x: this.scene.player.sprite.x,
y: this.scene.player.sprite.y - 100,
text: '🛵 REPAIRED!',
color: '#00FF00'
});
return true;
}
/**
* List missing parts for repair
*/
listMissingParts() {
const inv = this.scene.inventorySystem;
if (!inv) return;
console.log('📋 SCOOTER REPAIR CHECKLIST:');
console.log('===========================');
console.log('PARTS:');
for (const [part, needed] of Object.entries(this.requiredParts)) {
const has = inv.getItemCount(part) || 0;
const status = has >= needed ? '✅' : '🚫';
console.log(`${status} ${part}: ${has}/${needed}`);
}
console.log('\nTOOLS:');
for (const [tool, needed] of Object.entries(this.requiredTools)) {
const has = inv.getItemCount(tool) || 0;
const status = has >= needed ? '✅' : '🚫';
console.log(`${status} ${tool}: ${has}/${needed}`);
}
}
/**
* Spawn scooter part as loot
*/
spawnPart(x, y, partType) {
if (!this.scene.interactionSystem) return;
const validParts = Object.keys(this.requiredParts);
const part = partType || validParts[Math.floor(Math.random() * validParts.length)];
this.scene.interactionSystem.spawnLoot(x, y, part, 1);
console.log(`🔧 Spawned scooter part: ${part} at ${x},${y}`);
}
/**
* Random loot drop chance for parts (from zombies, chests, etc.)
*/
tryDropPart(x, y, dropChance = 0.1) {
if (this.isRepaired) return; // Don't drop if already repaired
if (Math.random() < dropChance) {
this.spawnPart(x, y);
return true;
}
return false;
}
}