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

const CommunityItem = sequelize.define('community-item', {
  id: {
    type: DataTypes.INTEGER,
    autoIncrement: true,
    primaryKey: true,
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: false,
  },
  effectData: { 
    type: DataTypes.JSON, 
    allowNull: true 
  },
  price: {
    type: DataTypes.INTEGER,
    allowNull: false,
  },
  rarity: {
    type: DataTypes.INTEGER,
    allowNull: false,
  },
  dropChance: {
    type: DataTypes.FLOAT,
    allowNull: false,
    defaultValue: 1,
  },
  type: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  duration: { 
    type: DataTypes.INTEGER, 
    allowNull: true 
  },
  canBeEquipped: { 
    type: DataTypes.BOOLEAN, 
    defaultValue: false 
  },
  img: {
    type: DataTypes.STRING,
    allowNull: true,
    defaultValue: 'template.png',
  },
  createdAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    allowNull: true,
  },
  updatedAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    allowNull: true,
  },
});

module.exports = { CommunityItem };
