import { DataTypes } from 'sequelize';
import { sequelize } from '../../utils/sequelize.js';

const TaxiMap = sequelize.define('TaxiMap', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  name: {
    type: DataTypes.STRING(100),
    allowNull: false
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true
  },
  width: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 8,
    comment: 'Map width in tiles'
  },
  height: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 8,
    comment: 'Map height in tiles'
  },
  tileSize: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 50,
    comment: 'Size of each tile in pixels'
  },
  mapTypeId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: 'Reference to TaxiMapType'
  },
  isActive: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: true
  },
  isDefault: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false,
    comment: 'Whether this is the default map for new games'
  },
  // createdAt/updatedAt via timestamps
}, {
  tableName: 'taxi_map',
  schema: 'taxi',
  timestamps: true,
  underscored: true,
  indexes: [
    {
      fields: ['name']
    },
    {
      fields: ['is_active']
    },
    {
      fields: ['is_default']
    },
  ]
});

export default TaxiMap;
