npm package: @noirrzz/spacecraft-control
Description: A spacecraft control system with power management and sensor capabilities
Author: noirrzz
Latest version: 1.0.1

# Spacecraft Control System

A comprehensive Node.js-based spacecraft control system featuring power management, movement controls, sensor systems, and real-time status monitoring.

## Complete Setup Guide

### Prerequisites
- Node.js (v12 or higher)
- npm (v6 or higher)

### Project Setup

1. Create a new directory and initialize:
```bash
mkdir spacecraft-control
cd spacecraft-control
npm init -y
```

2. Install required dependencies:
```bash
npm install express body-parser
```

3. Create the project structure:
```
spacecraft-control/
├── public/
│   ├── images/
│   │   └── rover.png
│   ├── styles/
│   │   └── styles.css
│   ├── scripts/
│   │   └── scripts.js
│   └── index.html
├── server.js
├── package.json
└── .npmignore
```

4. Add to package.json:
```json
{
  "name": "@noirrzz/spacecraft-control",
  "version": "1.0.0",
  "description": "A spacecraft control system with power management and sensor capabilities",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.18.2",
    "body-parser": "^1.20.2"
  }
}
```

## Features

### 🚀 Movement Control
- Forward and backward movement at 200 km/h
- Emergency stop functionality
- Direction indicator
- Automatic substance detection during movement

### ⚡ Power Management
- Battery level monitoring
- Sleep mode for instant recharging
- Wake/Sleep state tracking
- Power consumption during movement
- Visual power level indicators

### ⛽ Fuel System
- Fuel level monitoring
- Refueling capability (+25% per refuel)
- Fuel consumption during movement
- Visual fuel level indicators

### 🔍 Sensor Systems
- Mineral detection
- Ground substance analysis
- Real-time sensor readings
- Activatable/Deactivatable sensors

## API Reference

### Endpoints

#### GET /status
Returns the current status of the spacecraft:
```json
{
    "battery": "100%",
    "speed": "200 km/h (forward)",
    "fuel": "85%",
    "minerals": "Iron, Copper, Silicon",
    "groundSubstances": "Water, Methane",
    "status": "Awake"
}
```

#### POST /action
Send commands to control the spacecraft.

**Available Actions:**

1. Movement Control
```json
{
    "action": "move",
    "value": "forward" | "backward" | "stop"
}
```

2. Power Management
```json
{
    "action": "power",
    "value": "sleep" | "wake"
}
```

3. Sensor Control
```json
{
    "action": "sensors",
    "value": "on" | "off"
}
```

4. Fuel Management
```json
{
    "action": "fuel",
    "value": "refuel"
}
```

## System Specifications

### Power System
- Full battery: 100%
- Movement consumption: 5% per action
- Wake-up consumption: 2%
- Sleep mode: Instant recharge to 100%

### Fuel System
- Full tank: 100%
- Movement consumption: 2% per action
- Refuel amount: +25% per refuel
- Cannot move when fuel is depleted

### Movement System
- Speed: 200 km/h
- Directions: Forward/Backward
- Emergency stop available
- Requires both power and fuel to move

## File Structure Details

### server.js
Main server file handling:
- Express server setup
- API endpoints
- Spacecraft state management
- Action handlers

### public/index.html
Frontend interface containing:
- Control panel layout
- Status displays
- Interactive buttons
- Progress bars

### public/styles/styles.css
Styling including:
- Layout and grid system
- Color schemes
- Animations
- Responsive design

### public/scripts/scripts.js
Frontend logic handling:
- API calls
- Status updates
- UI animations
- Error handling

## Publishing to npm

1. Login to npm:
```bash
npm login
```

2. Create .npmignore:
```
.git
.gitignore
node_modules
.env
.DS_Store
```

3. Publish package:
```bash
npm publish --access public
```

## Usage Example
```javascript
// Move forward
fetch('/action', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        action: 'move',
        value: 'forward'
    })
});

// Enter sleep mode to recharge
fetch('/action', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        action: 'power',
        value: 'sleep'
    })
});
```

## Running the Project

1. Start the server:
```bash
npm start
```

2. Access the control panel:
```
http://localhost:3000
```

## Error Handling

The system provides clear error messages for:
- Insufficient power
- Insufficient fuel
- Sleep mode movement attempts
- Invalid commands
- System state conflicts

## Author

noirrzz