Fraser commited on
Commit
fba600d
·
1 Parent(s): 8d5e74d
src/lib/components/PicletGenerator/PicletGenerator.svelte CHANGED
@@ -335,7 +335,7 @@ Format your response EXACTLY as follows:
335
  {Include brand/model/landmark name when identifiable}
336
 
337
  # Variation
338
- {OPTIONAL: one distinctive attribute like "silver", "pro", "night", "gaming", or NONE if not applicable}
339
 
340
  # Object Rarity
341
  {common, uncommon, rare, epic, or legendary based on object uniqueness}
@@ -645,7 +645,17 @@ Create a concise visual description (1-3 sentences, max 100 words). Focus only o
645
  console.log('- stats:', cleanStats);
646
 
647
  // Convert to PicletInstance format and save as caught
648
- const picletInstance = await generatedDataToPicletInstance(picletData);
 
 
 
 
 
 
 
 
 
 
649
 
650
  // Override the caught status to auto-capture scanned Piclets
651
  picletInstance.caught = true;
 
335
  {Include brand/model/landmark name when identifiable}
336
 
337
  # Variation
338
+ {OPTIONAL: one distinctive attribute like "silver", "pro", "night", "gaming", OR use "canonical" if this is the standard/default version with no special variation}
339
 
340
  # Object Rarity
341
  {common, uncommon, rare, epic, or legendary based on object uniqueness}
 
645
  console.log('- stats:', cleanStats);
646
 
647
  // Convert to PicletInstance format and save as caught
648
+ // Extract variation from objectAttributes (first attribute if any, otherwise undefined)
649
+ const variation = workflowState.objectAttributes && workflowState.objectAttributes.length > 0
650
+ ? workflowState.objectAttributes[0]
651
+ : undefined;
652
+
653
+ const picletInstance = await generatedDataToPicletInstance(
654
+ picletData,
655
+ workflowState.objectName,
656
+ variation,
657
+ workflowState.objectAttributes
658
+ );
659
 
660
  // Override the caught status to auto-capture scanned Piclets
661
  picletInstance.caught = true;
src/lib/components/Piclets/PicletCard.svelte CHANGED
@@ -33,9 +33,9 @@
33
  </div>
34
 
35
  <div class="details-section">
36
- <p class="nickname">{piclet.typeId}</p>
37
  <div class="types-section">
38
- <span class="type primary">{piclet.primaryType}</span>
39
  </div>
40
  </div>
41
  </button>
 
33
  </div>
34
 
35
  <div class="details-section">
36
+ <p class="nickname">{piclet.nickname || piclet.objectName}</p>
37
  <div class="types-section">
38
+ <span class="type primary">{piclet.primaryType.toUpperCase()}</span>
39
  </div>
40
  </div>
41
  </button>
src/lib/db/piclets.ts CHANGED
@@ -2,6 +2,7 @@ import { db } from './index';
2
  import type { PicletInstance } from './schema';
3
  import { PicletType } from '../types/picletTypes';
4
  import type { PicletStats } from '../types';
 
5
 
6
  // Interface for generated piclet data (from PicletResult component)
7
  interface GeneratedPicletData {
@@ -19,6 +20,7 @@ interface GeneratedPicletData {
19
  export async function generatedDataToPicletInstance(
20
  data: GeneratedPicletData,
21
  objectName?: string,
 
22
  attributes?: string[],
23
  visualDetails?: string
24
  ): Promise<Omit<PicletInstance, 'id'>> {
@@ -31,8 +33,9 @@ export async function generatedDataToPicletInstance(
31
  // Map tier from stats to discovery rarity
32
  let tier: string = stats.tier || 'common';
33
 
34
- // Generate unique typeId
35
- const typeId = `${objectName || stats.name}_${Date.now()}`;
 
36
 
37
  return {
38
  // Basic Info
 
2
  import type { PicletInstance } from './schema';
3
  import { PicletType } from '../types/picletTypes';
4
  import type { PicletStats } from '../types';
5
+ import { generatePicletId } from '../utils/picletId';
6
 
7
  // Interface for generated piclet data (from PicletResult component)
8
  interface GeneratedPicletData {
 
20
  export async function generatedDataToPicletInstance(
21
  data: GeneratedPicletData,
22
  objectName?: string,
23
+ variation?: string,
24
  attributes?: string[],
25
  visualDetails?: string
26
  ): Promise<Omit<PicletInstance, 'id'>> {
 
33
  // Map tier from stats to discovery rarity
34
  let tier: string = stats.tier || 'common';
35
 
36
+ // Generate typeId using normalized object name + variation (or just object if variation is "canonical")
37
+ const normalizedObjectName = objectName || stats.name;
38
+ const typeId = generatePicletId(normalizedObjectName, variation && variation !== 'canonical' ? variation : undefined);
39
 
40
  return {
41
  // Basic Info