const { DataTypes } = require("sequelize");
const sequelize = require("../config/db");

const PlayerQuest = sequelize.define(
  "PlayerQuest",
  {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    playerId: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    questId: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    status: {
      type: DataTypes.ENUM("active", "ready", "completed"),
      defaultValue: "active",
    },
    progress: {
      type: DataTypes.JSON,
      defaultValue: [],
    },
  },
  {
    timestamps: true,
    tableName: "player_quests",
    indexes: [
      {
        unique: true,
        fields: ["playerId", "questId"],
      },
    ],
  },
);

module.exports = PlayerQuest;
