X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=prisma%2Fseed%2Fmonsters.ts;fp=prisma%2Fseed%2Fmonsters.ts;h=bc9e63b961ee9bd3c0fddb8f0917233e160860ed;hp=0000000000000000000000000000000000000000;hb=b5d3cc37fddebff8dcdf1ef0cdd3a626811f14d3;hpb=20dc560a75cfd6ddc8a66956315a30001779ec24 diff --git a/prisma/seed/monsters.ts b/prisma/seed/monsters.ts new file mode 100644 index 0000000..bc9e63b --- /dev/null +++ b/prisma/seed/monsters.ts @@ -0,0 +1,242 @@ +import {Biome, MonsterType} from '@prisma/client'; +import { prisma } from '../../src/lib/db'; + +const monsterList = [ + { + name: "Rat", + monster_type: [MonsterType.BEAST], + availability: [ + { + type: Biome.PLAINS, + weight: 0.5, + time: [{min: 0, max: 30}] + }, + { + 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.PLAINS, + weight: 0.3, + time: [{min: 0, max: 29}] + }, + { + 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}] + } + ] + } +]; + + +// wipe all monsters! +export async function down() { + await prisma.fight.deleteMany(); + await prisma.monsterBiome.deleteMany(); + await prisma.monster.deleteMany(); +} + +export async function up() { + 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 + } + }) + }); + }); +}