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

const Weapon = sequelize.define(
  "Weapon",
  {
    itemId: {
      type: DataTypes.STRING,
      primaryKey: true,
      references: { model: Item, key: "id" },
    },
    damage: { type: DataTypes.INTEGER },
    criticalChance: { type: DataTypes.FLOAT },
    attackRate: { type: DataTypes.INTEGER },
  },
  { timestamps: false },
);

const Armour = sequelize.define(
  "Armour",
  {
    itemId: {
      type: DataTypes.STRING,
      primaryKey: true,
      references: { model: Item, key: "id" },
    },
    health: { type: DataTypes.INTEGER },
    resistance: { type: DataTypes.FLOAT },
    defenceRating: { type: DataTypes.INTEGER },
    reflectChance: { type: DataTypes.FLOAT },
    category: {
      type: DataTypes.ENUM(
        "BACKPACK",
        "BODY",
        "BOOTS",
        "HANDS",
        "HELMET",
        "PANTS",
      ),
    },
  },
  { timestamps: false },
);

const Material = sequelize.define(
  "Material",
  {
    itemId: {
      type: DataTypes.STRING,
      primaryKey: true,
      references: { model: Item, key: "id" },
    },
    category: {
      type: DataTypes.ENUM("ELECTRONICS", "BIO", "CHEMICAL"),
    },
  },
  { timestamps: false },
);

module.exports = { Weapon, Armour, Material };
