X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=prisma%2Fseed.ts;fp=prisma%2Fseed.ts;h=f6bf7298808f3c13668751c92af8881d2594cd88;hp=4bf244148efe4bcbb9fd229fdb8e56e6ba4c3a12;hb=b5d3cc37fddebff8dcdf1ef0cdd3a626811f14d3;hpb=20dc560a75cfd6ddc8a66956315a30001779ec24 diff --git a/prisma/seed.ts b/prisma/seed.ts index 4bf2441..f6bf729 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,224 +1,8 @@ -import {Biome, MonsterType} from '@prisma/client'; -import { prisma } from '../src/lib/db'; +import * as monster from './seed/monsters'; +import * as equipment from './seed/equipment'; -const monsterList = [ - { - name: "Rat", - monster_type: [MonsterType.BEAST], - availability: [ - { - type: Biome.FIELDS, - weight: 0.5, - time: [{min: 0, max: 24}] - }, - { - type: Biome.WOODLAND, - weight: 0.6, - time: [{min: 0, max: 24}] - } - ] - }, - { - name: "Bat", - monster_type: [MonsterType.FLYING], - availability: [ - { - type: Biome.FIELDS, - weight: 0.2, - time: [{min: 0, max: 4}, {min: 20, max: 24}] - }, - { - type: Biome.WOODLAND, - weight: 0.4, - time: [{min: 0, max: 4}, {min: 20, max: 24}] - }, - { - type: Biome.FOREST, - weight: 0.4, - time: [{min: 0, max: 4}, {min: 20, max: 24}] - } - ] - }, - { - name: "Wild Boar", - monster_type: [MonsterType.BEAST], - availability: [ - { - type: Biome.FIELDS, - weight: 0.3, - time: [{min: 0, max: 24}] - }, - { - type: Biome.WOODLAND, - weight: 0.3, - time: [{min: 0, max: 24}] - } - ] - }, - { - name: "Bandit", - monster_type: [MonsterType.HUMANOID], - availability: [ - { - type: Biome.FIELDS, - weight: 0.3, - time: [{min: 0, max: 5}, {min: 16, max: 24}] - }, - { - type: Biome.WOODLAND, - weight: 0.3, - time: [{min: 0, max: 5}, {min: 16, max: 24}] - }, - { - type: Biome.FOREST, - weight: 0.1, - time: [{min: 0, max: 5}, {min: 16, max: 24}] - } - ] - }, - { - name: "Thief", - monster_type: [MonsterType.HUMANOID], - availability: [ - { - type: Biome.FIELDS, - weight: 0.3, - time: [{min: 0, max: 5}, {min: 18, max: 24}] - }, - { - type: Biome.WOODLAND, - weight: 0.3, - time: [{min: 0, max: 5}, {min: 16, max: 24}] - }, - { - type: Biome.FOREST, - weight: 0.1, - time: [{min: 0, max: 5}, {min: 16, max: 24}] - } - ] - }, - { - name: "Sunstrider", - monster_type: [MonsterType.INSECT], - availability: [ - { - type: Biome.FIELDS, - weight: 0.15, - time: [{min: 8, max: 15}] - }, - { - type: Biome.PLAINS, - weight: 0.3, - time: [{min: 8, max: 17}] - } - ] - }, - { - name: "Lich", - monster_type: [MonsterType.UNDEAD], - availability: [ - { - type: Biome.FOREST, - weight: 0.15, - time: [{min: 19, max: 24}, {min: 0, max: 3}] - }, - { - type: Biome.WOODLAND, - weight: 0.05, - time: [{min: 19, max: 24}, {min: 0, max: 3}] - } - ] - }, - { - name: "Centaur", - monster_type: [MonsterType.HUMANOID, MonsterType.BEAST], - availability: [ - { - type: Biome.WOODLAND, - weight: 0.2, - time: [{min: 0, max: 24}] - } - ] - }, - { - name: "Giant Scorpion", - monster_type: [MonsterType.INSECT, MonsterType.GIANT], - availability: [ - { - type: Biome.DESERT, - weight: 0.3, - time: [{min: 0, max: 24}] - } - ] - }, - { - name: "Wolf", - onster_type: [MonsterType.BEAST], - availability: [ - { - type: Biome.MOUNTAIN, - weight: 0.3, - time: [{min: 0, max: 24}] - }, - { - type: Biome.FOREST, - weight: 0.3, - time: [{min: 0, max: 24}] - } - ] - }, - { - name: "Bear", - monster_type: [MonsterType.BEAST], - availability: [ - { - type: Biome.MOUNTAIN, - weight: 0.3, - time: [{min: 0, max: 24}] - }, - { - type: Biome.FOREST, - weight: 0.3, - time: [{min: 0, max: 24}] - } - ] - }, - { - name: "Troll", - monster_type: [MonsterType.HUMANOID], - availability: [ - { - type: Biome.MOUNTAIN, - weight: 0.3, - time: [{min: 0, max: 4}, {min: 20, max: 24}] - }, - { - type: Biome.FOREST, - weight: 0.3, - time: [{min: 0, max: 4}, {min: 20, max: 24}] - } - ] - } -]; - -monsterList.forEach(async monster => { - const createdMonster = await prisma.monster.create({ - data: { - name: monster.name, - monsterType: monster.monster_type - } - }); - - await prisma.monsterBiome.createMany({ - data: monster.availability.map(availability => { - return { - biome: availability.type, - monsterId: createdMonster.id, - weight: availability.weight, - time: availability.time - } - }) - }); -}); - +equipment.down() + .then(() => equipment.up()) + .then(() => monster.down()) + .then(() => monster.up())