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

const TaxiGameState = sequelize.define('TaxiGameState', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  userId: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  currentLevel: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 1
  },
  totalScore: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0
  },
  totalMoney: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0
  },
  totalPassengersDelivered: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0
  },
  unlockedLevels: {
    type: DataTypes.JSON,
    allowNull: false,
    defaultValue: [1]
  },
  achievements: {
    type: DataTypes.JSON,
    allowNull: false,
    defaultValue: []
  },
  // createdAt/updatedAt via timestamps
}, {
  tableName: 'taxi_game_state',
  schema: 'taxi',
  timestamps: true,
  underscored: true,
  indexes: [
    {
      unique: true,
      fields: ['user_id']
    },
    {
      fields: ['total_score']
    },
    {
      fields: ['total_money']
    },
    {
      fields: ['total_passengers_delivered']
    }
  ]
});

export default TaxiGameState;
