exploring/fighting is functional
[sketchy-heroes.git] / prisma / seed.ts
1 import {Biome, MonsterType} from '@prisma/client';
2 import { prisma } from '../src/lib/db';
3
4
5 const monsterList = [
6   {
7     name: "Rat",
8     monster_type: [MonsterType.BEAST],
9     availability: [
10       {
11         type: Biome.FIELDS,
12         weight: 0.5,
13         time: [{min: 0, max: 24}]
14       },
15       {
16         type: Biome.WOODLAND,
17         weight: 0.6,
18         time: [{min: 0, max: 24}]
19       }
20     ]
21   },
22   {
23     name: "Bat",
24     monster_type: [MonsterType.FLYING],
25     availability: [
26       {
27         type: Biome.FIELDS,
28         weight: 0.2,
29         time: [{min: 0, max: 4}, {min: 20, max: 24}]
30       },
31       {
32         type: Biome.WOODLAND,
33         weight: 0.4,
34         time: [{min: 0, max: 4}, {min: 20, max: 24}]
35       },
36       {
37         type: Biome.FOREST,
38         weight: 0.4,
39         time: [{min: 0, max: 4}, {min: 20, max: 24}]
40       }
41     ]
42   },
43   {
44     name: "Wild Boar",
45     monster_type: [MonsterType.BEAST],
46     availability: [
47       {
48         type: Biome.FIELDS,
49         weight: 0.3,
50         time: [{min: 0, max: 24}]
51       },
52       {
53         type: Biome.WOODLAND,
54         weight: 0.3,
55         time: [{min: 0, max: 24}]
56       }
57     ]
58   },
59   {
60     name: "Bandit",
61     monster_type: [MonsterType.HUMANOID],
62     availability: [
63       {
64         type: Biome.FIELDS,
65         weight: 0.3,
66         time: [{min: 0, max: 5}, {min: 16, max: 24}]
67       },
68       {
69         type: Biome.WOODLAND,
70         weight: 0.3,
71         time: [{min: 0, max: 5}, {min: 16, max: 24}]
72       },
73       {
74         type: Biome.FOREST,
75         weight: 0.1,
76         time: [{min: 0, max: 5}, {min: 16, max: 24}]
77       }
78     ]
79   },
80   {
81     name: "Thief",
82     monster_type: [MonsterType.HUMANOID],
83     availability: [
84       {
85         type: Biome.FIELDS,
86         weight: 0.3,
87         time: [{min: 0, max: 5}, {min: 18, max: 24}]
88       },
89       {
90         type: Biome.WOODLAND,
91         weight: 0.3,
92         time: [{min: 0, max: 5}, {min: 16, max: 24}]
93       },
94       {
95         type: Biome.FOREST,
96         weight: 0.1,
97         time: [{min: 0, max: 5}, {min: 16, max: 24}]
98       }
99     ]
100   },
101   {
102     name: "Sunstrider",
103     monster_type: [MonsterType.INSECT],
104     availability: [
105       {
106         type: Biome.FIELDS,
107         weight: 0.15,
108         time: [{min: 8, max: 15}]
109       },
110       {
111         type: Biome.PLAINS,
112         weight: 0.3,
113         time: [{min: 8, max: 17}]
114       }
115     ]
116   },
117   {
118     name: "Lich",
119     monster_type: [MonsterType.UNDEAD],
120     availability: [
121       {
122         type: Biome.FOREST,
123         weight: 0.15,
124         time: [{min: 19, max: 24}, {min: 0, max: 3}]
125       },
126       {
127         type: Biome.WOODLAND,
128         weight: 0.05,
129         time: [{min: 19, max: 24}, {min: 0, max: 3}]
130       }
131     ]
132   },
133   {
134     name: "Centaur",
135     monster_type: [MonsterType.HUMANOID, MonsterType.BEAST],
136     availability: [
137       {
138         type: Biome.WOODLAND,
139         weight: 0.2,
140         time: [{min: 0, max: 24}]
141       }
142     ]
143   },
144   {
145     name: "Giant Scorpion",
146     monster_type: [MonsterType.INSECT, MonsterType.GIANT],
147     availability: [
148       {
149         type: Biome.DESERT,
150         weight: 0.3,
151         time: [{min: 0, max: 24}]
152       }
153     ]
154   },
155   {
156     name: "Wolf",
157     onster_type: [MonsterType.BEAST],
158     availability: [
159       {
160         type: Biome.MOUNTAIN,
161         weight: 0.3,
162         time: [{min: 0, max: 24}]
163       },
164       {
165         type: Biome.FOREST,
166         weight: 0.3,
167         time: [{min: 0, max: 24}]
168       }
169     ]
170   },
171   {
172     name: "Bear",
173     monster_type: [MonsterType.BEAST],
174     availability: [
175       {
176         type: Biome.MOUNTAIN,
177         weight: 0.3,
178         time: [{min: 0, max: 24}]
179       },
180       {
181         type: Biome.FOREST,
182         weight: 0.3,
183         time: [{min: 0, max: 24}]
184       }
185     ]
186   },
187   {
188     name: "Troll",
189     monster_type: [MonsterType.HUMANOID],
190     availability: [
191       {
192         type: Biome.MOUNTAIN,
193         weight: 0.3,
194         time: [{min: 0, max: 4}, {min: 20, max: 24}]
195       },
196       {
197         type: Biome.FOREST,
198         weight: 0.3,
199         time: [{min: 0, max: 4}, {min: 20, max: 24}]
200       }
201     ]
202   }
203 ];
204
205 monsterList.forEach(async monster => {
206   const createdMonster = await prisma.monster.create({
207     data: {
208       name: monster.name,
209       monsterType: monster.monster_type
210     }
211   });
212
213   await prisma.monsterBiome.createMany({
214     data: monster.availability.map(availability => {
215       return {
216         biome: availability.type,
217         monsterId: createdMonster.id,
218         weight: availability.weight,
219         time: availability.time
220       }
221     })
222   });
223 });
224