Fraser commited on
Commit
b097ab2
·
1 Parent(s): 3c5445c
src/lib/components/MonsterGenerator/MonsterGenerator.svelte CHANGED
@@ -35,12 +35,6 @@ Guidelines:
35
  - Add a mouth, beak, or feeding apparatus if appropriate
36
  - Add creature elements like tail, fins, claws, or horns where fitting
37
 
38
- Rarity assessment - Rate objects based on their real-world availability and value:
39
- • COMMON: Everyday items everyone has (stationery, grass, rocks, basic furniture, common tools)
40
- • UNCOMMON: Items that cost money but are widely available (electronics, appliances, vehicles, branded items)
41
- • RARE: Expensive or specialized items (luxury goods, professional equipment, gold jewelry, antiques)
42
- • LEGENDARY: Priceless or one-of-a-kind items (crown jewels, world wonders, famous artifacts, masterpiece art)
43
-
44
  Include:
45
  - A creative name that hints at the original object
46
  - Physical description showing how the object becomes a creature
@@ -50,7 +44,6 @@ Include:
50
  Format your response as:
51
  \`\`\`
52
  # {monster name}
53
- Object Rarity: {common, uncommon, rare, legendary}
54
  ## Monster Visual Description
55
  ...
56
  ## Monster Lore
@@ -301,19 +294,8 @@ Focus on: colors, body shape, eyes, limbs, mouth, and key visual features. Omit
301
  throw new Error('Text generation service not available or no concept');
302
  }
303
 
304
- // Extract tier from the joy-caption output
305
- let tier: 'low' | 'medium' | 'high' | 'legendary' = 'medium'; // default
306
- const rarityMatch = state.monsterConcept.match(/Object Rarity:\s*(common|uncommon|rare|legendary)/i);
307
- if (rarityMatch) {
308
- // Map rarity to tier
309
- const tierMap: { [key: string]: 'low' | 'medium' | 'high' | 'legendary' } = {
310
- 'common': 'low',
311
- 'uncommon': 'medium',
312
- 'rare': 'high',
313
- 'legendary': 'legendary'
314
- };
315
- tier = tierMap[rarityMatch[1].toLowerCase()] || 'medium';
316
- }
317
 
318
  // Extract monster name from the concept
319
  const nameMatch = state.monsterConcept.match(/^#\s+(.+)$/m);
@@ -327,11 +309,18 @@ Focus on: colors, body shape, eyes, limbs, mouth, and key visual features. Omit
327
  const statsPrompt = `Based on this monster concept, generate a JSON object with battle stats and abilities:
328
  "${state.monsterConcept}"
329
 
 
 
 
 
 
 
330
  The output should be formatted as a JSON instance that conforms to the JSON schema below.
331
 
332
  \`\`\`json
333
  {
334
  "properties": {
 
335
  "HP": {"type": "integer", "minimum": 0, "maximum": 100, "description": "Health/vitality stat (0=fragile, 100=incredibly tanky)"},
336
  "defence": {"type": "integer", "minimum": 0, "maximum": 100, "description": "Defensive/armor stat (0=paper thin, 100=impenetrable fortress)"},
337
  "attack": {"type": "integer", "minimum": 0, "maximum": 100, "description": "Physical attack power (0=harmless, 100=devastating force)"},
@@ -346,14 +335,14 @@ The output should be formatted as a JSON instance that conforms to the JSON sche
346
  "specialActionName": {"type": "string", "description": "Name of the monster's ultimate move (one use per battle)"},
347
  "specialActionDescription": {"type": "string", "description": "Describe this powerful finishing move and its dramatic effects in battle"}
348
  },
349
- "required": ["HP", "defence", "attack", "speed", "specialPassiveTraitDescription", "attackActionName", "attackActionDescription", "buffActionName", "buffActionDescription", "debuffActionName", "debuffActionDescription", "specialActionName", "specialActionDescription"]
350
  }
351
  \`\`\`
352
 
353
- Base the HP, defence, attack, and speed stats on the tier level:
354
- - low: stats should be 10-40
355
- - medium: stats should be 30-60
356
- - high: stats should be 50-80
357
  - legendary: stats should be 70-100
358
 
359
  Write your response within \`\`\`json\`\`\``;
@@ -399,7 +388,7 @@ Write your response within \`\`\`json\`\`\``;
399
  const parsedStats = JSON.parse(cleanJson.trim());
400
 
401
  // Remove any extra fields not in our schema
402
- const allowedFields = ['HP', 'defence', 'attack', 'speed',
403
  'specialPassiveTraitDescription', 'attackActionName', 'attackActionDescription',
404
  'buffActionName', 'buffActionDescription', 'debuffActionName', 'debuffActionDescription',
405
  'specialActionName', 'specialActionDescription', 'boostActionName', 'boostActionDescription',
@@ -411,7 +400,18 @@ Write your response within \`\`\`json\`\`\``;
411
  }
412
  }
413
 
414
- // Add the name, description, and tier that we already extracted
 
 
 
 
 
 
 
 
 
 
 
415
  parsedStats.name = monsterName;
416
  parsedStats.description = monsterLore;
417
  parsedStats.tier = tier;
 
35
  - Add a mouth, beak, or feeding apparatus if appropriate
36
  - Add creature elements like tail, fins, claws, or horns where fitting
37
 
 
 
 
 
 
 
38
  Include:
39
  - A creative name that hints at the original object
40
  - Physical description showing how the object becomes a creature
 
44
  Format your response as:
45
  \`\`\`
46
  # {monster name}
 
47
  ## Monster Visual Description
48
  ...
49
  ## Monster Lore
 
294
  throw new Error('Text generation service not available or no concept');
295
  }
296
 
297
+ // Default tier (will be set from the generated stats)
298
+ let tier: 'low' | 'medium' | 'high' | 'legendary' = 'medium';
 
 
 
 
 
 
 
 
 
 
 
299
 
300
  // Extract monster name from the concept
301
  const nameMatch = state.monsterConcept.match(/^#\s+(.+)$/m);
 
309
  const statsPrompt = `Based on this monster concept, generate a JSON object with battle stats and abilities:
310
  "${state.monsterConcept}"
311
 
312
+ First, assess the rarity of the original object based on real-world availability and value:
313
+ • COMMON: Everyday items everyone has (stationery, grass, rocks, basic furniture, common tools)
314
+ • UNCOMMON: Items that cost money but are widely available (electronics, appliances, vehicles, branded items)
315
+ • RARE: Expensive or specialized items (luxury goods, professional equipment, gold jewelry, antiques)
316
+ • LEGENDARY: Priceless or one-of-a-kind items (crown jewels, world wonders, famous artifacts, masterpiece art)
317
+
318
  The output should be formatted as a JSON instance that conforms to the JSON schema below.
319
 
320
  \`\`\`json
321
  {
322
  "properties": {
323
+ "rarity": {"type": "string", "enum": ["common", "uncommon", "rare", "legendary"], "description": "Rarity of the original object based on real-world availability and value"},
324
  "HP": {"type": "integer", "minimum": 0, "maximum": 100, "description": "Health/vitality stat (0=fragile, 100=incredibly tanky)"},
325
  "defence": {"type": "integer", "minimum": 0, "maximum": 100, "description": "Defensive/armor stat (0=paper thin, 100=impenetrable fortress)"},
326
  "attack": {"type": "integer", "minimum": 0, "maximum": 100, "description": "Physical attack power (0=harmless, 100=devastating force)"},
 
335
  "specialActionName": {"type": "string", "description": "Name of the monster's ultimate move (one use per battle)"},
336
  "specialActionDescription": {"type": "string", "description": "Describe this powerful finishing move and its dramatic effects in battle"}
337
  },
338
+ "required": ["rarity", "HP", "defence", "attack", "speed", "specialPassiveTraitDescription", "attackActionName", "attackActionDescription", "buffActionName", "buffActionDescription", "debuffActionName", "debuffActionDescription", "specialActionName", "specialActionDescription"]
339
  }
340
  \`\`\`
341
 
342
+ Base the HP, defence, attack, and speed stats on the rarity level:
343
+ - common: stats should be 10-40
344
+ - uncommon: stats should be 30-60
345
+ - rare: stats should be 50-80
346
  - legendary: stats should be 70-100
347
 
348
  Write your response within \`\`\`json\`\`\``;
 
388
  const parsedStats = JSON.parse(cleanJson.trim());
389
 
390
  // Remove any extra fields not in our schema
391
+ const allowedFields = ['rarity', 'HP', 'defence', 'attack', 'speed',
392
  'specialPassiveTraitDescription', 'attackActionName', 'attackActionDescription',
393
  'buffActionName', 'buffActionDescription', 'debuffActionName', 'debuffActionDescription',
394
  'specialActionName', 'specialActionDescription', 'boostActionName', 'boostActionDescription',
 
400
  }
401
  }
402
 
403
+ // Map rarity to tier
404
+ if (parsedStats.rarity) {
405
+ const tierMap: { [key: string]: 'low' | 'medium' | 'high' | 'legendary' } = {
406
+ 'common': 'low',
407
+ 'uncommon': 'medium',
408
+ 'rare': 'high',
409
+ 'legendary': 'legendary'
410
+ };
411
+ tier = tierMap[parsedStats.rarity.toLowerCase()] || 'medium';
412
+ }
413
+
414
+ // Add the name, description, and tier that we extracted/mapped
415
  parsedStats.name = monsterName;
416
  parsedStats.description = monsterLore;
417
  parsedStats.tier = tier;