X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=prisma%2Fseed.ts;fp=prisma%2Fseed.ts;h=4bf244148efe4bcbb9fd229fdb8e56e6ba4c3a12;hp=0000000000000000000000000000000000000000;hb=7aa7248bc4f3f59a002beb98fa889a9da3c25866;hpb=9cec2c639563092ed050716db1e7e4657f937bf5 diff --git a/prisma/seed.ts b/prisma/seed.ts new file mode 100644 index 0000000..4bf2441 --- /dev/null +++ b/prisma/seed.ts @@ -0,0 +1,224 @@ +import {Biome, MonsterType} from '@prisma/client'; +import { prisma } from '../src/lib/db'; + + +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 + } + }) + }); +}); +