Shatteredvoid/src/database/migrations/004.5_missing_fleet_tables.js
MegaProxy 8d9ef427be feat: implement comprehensive combat system with plugin architecture
- Complete combat system with instant, turn-based, and tactical combat
- Plugin-based architecture with CombatPluginManager for extensibility
- Real-time combat events via WebSocket
- Fleet vs fleet and fleet vs colony combat support
- Comprehensive combat statistics and history tracking
- Admin panel for combat management and configuration
- Database migrations for combat tables and fleet system
- Complete test suite for combat functionality
- Combat middleware for validation and logging
- Service locator pattern for dependency management

Combat system features:
• Multiple combat resolution types with plugin support
• Real-time combat events and spectator support
• Detailed combat logs and casualty calculations
• Experience gain and veterancy system for ships
• Fleet positioning and tactical formations
• Combat configurations and modifiers
• Queue system for battle processing
• Comprehensive admin controls and monitoring

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 14:02:04 +00:00

70 lines
No EOL
3.3 KiB
JavaScript

/**
* Missing Fleet Tables Migration
* Adds fleet-related tables that were missing from previous migrations
*/
exports.up = function(knex) {
return knex.schema
// Create fleets table
.createTable('fleets', (table) => {
table.increments('id').primary();
table.integer('player_id').notNullable().references('players.id').onDelete('CASCADE');
table.string('name', 100).notNullable();
table.string('current_location', 20).notNullable(); // Coordinates
table.string('destination', 20).nullable(); // If moving
table.string('fleet_status', 20).defaultTo('idle')
.checkIn(['idle', 'moving', 'in_combat', 'constructing', 'repairing']);
table.timestamp('movement_started').nullable();
table.timestamp('arrival_time').nullable();
table.timestamp('last_updated').defaultTo(knex.fn.now());
table.timestamp('created_at').defaultTo(knex.fn.now());
table.index(['player_id']);
table.index(['current_location']);
table.index(['fleet_status']);
table.index(['arrival_time']);
})
// Create ship_designs table
.createTable('ship_designs', (table) => {
table.increments('id').primary();
table.integer('player_id').nullable().references('players.id').onDelete('CASCADE'); // NULL for public designs
table.string('name', 100).notNullable();
table.string('ship_class', 50).notNullable(); // 'fighter', 'corvette', 'destroyer', 'cruiser', 'battleship'
table.string('hull_type', 50).notNullable();
table.jsonb('components').notNullable(); // Weapon, shield, engine configurations
table.jsonb('stats').notNullable(); // Calculated stats: hp, attack, defense, speed, etc.
table.jsonb('cost').notNullable(); // Resource cost to build
table.integer('build_time').notNullable(); // In minutes
table.boolean('is_public').defaultTo(false); // Available to all players
table.boolean('is_active').defaultTo(true);
table.timestamp('created_at').defaultTo(knex.fn.now());
table.timestamp('updated_at').defaultTo(knex.fn.now());
table.index(['player_id']);
table.index(['ship_class']);
table.index(['is_public']);
table.index(['is_active']);
})
// Create fleet_ships table
.createTable('fleet_ships', (table) => {
table.increments('id').primary();
table.integer('fleet_id').notNullable().references('fleets.id').onDelete('CASCADE');
table.integer('ship_design_id').notNullable().references('ship_designs.id').onDelete('CASCADE');
table.integer('quantity').notNullable().defaultTo(1);
table.decimal('health_percentage', 5, 2).defaultTo(100.00);
table.integer('experience').defaultTo(0);
table.timestamp('created_at').defaultTo(knex.fn.now());
table.index(['fleet_id']);
table.index(['ship_design_id']);
});
};
exports.down = function(knex) {
return knex.schema
.dropTableIfExists('fleet_ships')
.dropTableIfExists('ship_designs')
.dropTableIfExists('fleets');
};