const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const npc_relationships = sequelize.define(
    'npc_relationships',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

relationship_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"acquaintance",


"friend",


"best_friend",


"rival"

        ],

      },

friendship_points: {
        type: DataTypes.DECIMAL,
      
      

      },

trust_points: {
        type: DataTypes.DECIMAL,
      
      

      },

last_interaction_at: {
        type: DataTypes.DATE,
      
      

      },

is_unlocked: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  npc_relationships.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity



















































//end loop



    db.npc_relationships.belongsTo(db.player_profiles, {
      as: 'player_profile',
      foreignKey: {
        name: 'player_profileId',
      },
      constraints: false,
    });

    db.npc_relationships.belongsTo(db.npcs, {
      as: 'npc',
      foreignKey: {
        name: 'npcId',
      },
      constraints: false,
    });




    db.npc_relationships.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.npc_relationships.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return npc_relationships;
};


