test lexicon
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
"description": "Migrated card data from api.syui.ai",
|
"description": "Migrated card data from api.syui.ai",
|
||||||
"record": {
|
"record": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["user", "cards", "migratedAt"],
|
"required": ["user", "card", "migratedAt"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"user": {
|
"user": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -24,18 +24,17 @@
|
|||||||
"updatedAt": { "type": "string", "format": "datetime" }
|
"updatedAt": { "type": "string", "format": "datetime" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cards": {
|
"card": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["id", "card", "cp"],
|
"required": ["id", "cp", "rare", "cid", "unique"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "integer" },
|
"id": { "type": "integer", "description": "Card type ID" },
|
||||||
"card": { "type": "integer" },
|
"cp": { "type": "integer", "description": "Card power" },
|
||||||
"cp": { "type": "integer" },
|
"rare": { "type": "integer", "description": "Rarity level" },
|
||||||
"status": { "type": "string" },
|
"cid": { "type": "string", "description": "Unique card instance ID" },
|
||||||
"skill": { "type": "string" },
|
"unique": { "type": "boolean", "description": "Unique card flag" }
|
||||||
"createdAt": { "type": "string", "format": "datetime" }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["id", "cp", "rare", "cid"],
|
"required": ["id", "cp", "rare", "cid", "unique"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "integer", "description": "Card type ID" },
|
"id": { "type": "integer", "description": "Card type ID" },
|
||||||
"cp": { "type": "integer", "description": "Card power" },
|
"cp": { "type": "integer", "description": "Card power" },
|
||||||
"rare": { "type": "integer", "description": "Rarity level" },
|
"rare": { "type": "integer", "description": "Rarity level" },
|
||||||
"cid": { "type": "string", "description": "Unique card instance ID (TID format)" }
|
"cid": { "type": "string", "description": "Unique card instance ID" },
|
||||||
|
"unique": { "type": "boolean", "description": "Unique card flag" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["id", "cp", "mode", "unique", "shiny"],
|
"required": ["id", "cp", "rare", "cid", "unique"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "integer" },
|
"id": { "type": "integer", "description": "Character type ID" },
|
||||||
"cp": { "type": "integer" },
|
"cp": { "type": "integer", "description": "Character power" },
|
||||||
"mode": { "type": "integer" },
|
"rare": { "type": "integer", "description": "Rarity level" },
|
||||||
"unique": { "type": "boolean" },
|
"cid": { "type": "string", "description": "Unique character instance ID" },
|
||||||
"shiny": { "type": "boolean" }
|
"unique": { "type": "boolean", "description": "Unique character flag" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -29,13 +29,13 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["id", "cp", "mode", "unique", "shiny"],
|
"required": ["id", "cp", "rare", "cid", "unique"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "integer" },
|
"id": { "type": "integer", "description": "Item type ID" },
|
||||||
"cp": { "type": "integer" },
|
"cp": { "type": "integer", "description": "Item power" },
|
||||||
"mode": { "type": "integer" },
|
"rare": { "type": "integer", "description": "Rarity level" },
|
||||||
"unique": { "type": "boolean" },
|
"cid": { "type": "string", "description": "Unique item instance ID" },
|
||||||
"shiny": { "type": "boolean" }
|
"unique": { "type": "boolean", "description": "Unique item flag" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -42,8 +42,8 @@
|
|||||||
"xghh6ketlbszv",
|
"xghh6ketlbszv",
|
||||||
"rjv6rgjtpjn2n",
|
"rjv6rgjtpjn2n",
|
||||||
"7numrfd5dlm2v",
|
"7numrfd5dlm2v",
|
||||||
"aunhtmv67bb3e",
|
|
||||||
"57vsoautyqq6e",
|
"57vsoautyqq6e",
|
||||||
|
"aunhtmv67bb3e",
|
||||||
"lt3z6yvsomyjd",
|
"lt3z6yvsomyjd",
|
||||||
"ub7qhzkw6a5ns",
|
"ub7qhzkw6a5ns",
|
||||||
"jjfsk6e5ia4lm",
|
"jjfsk6e5ia4lm",
|
||||||
|
|||||||
@@ -38,12 +38,12 @@
|
|||||||
"wigv2qnon7pmg",
|
"wigv2qnon7pmg",
|
||||||
"smrgeplyw5wmr",
|
"smrgeplyw5wmr",
|
||||||
"p4l6y3qkmfscg",
|
"p4l6y3qkmfscg",
|
||||||
"imlara2baiopj",
|
|
||||||
"ygwc5lfiqugqr",
|
"ygwc5lfiqugqr",
|
||||||
"cuismxqmr5kjj",
|
"cuismxqmr5kjj",
|
||||||
"zcjwkbra3y224",
|
"zcjwkbra3y224",
|
||||||
"lgr6ni5clwg7r",
|
"imlara2baiopj",
|
||||||
"i3yrryvuobx44",
|
"i3yrryvuobx44",
|
||||||
|
"lgr6ni5clwg7r",
|
||||||
"ncxfpuml2yoqi",
|
"ncxfpuml2yoqi",
|
||||||
"oulyo5t5yavqz",
|
"oulyo5t5yavqz",
|
||||||
"gx5bssnv2h4vm",
|
"gx5bssnv2h4vm",
|
||||||
|
|||||||
@@ -72,37 +72,25 @@ export async function performMigration(user: OldApiUser, cards: OldApiCard[]): P
|
|||||||
// Merge cards by card number (sum cp, keep highest status)
|
// Merge cards by card number (sum cp, keep highest status)
|
||||||
const cardGroups = new Map<number, {
|
const cardGroups = new Map<number, {
|
||||||
card: number
|
card: number
|
||||||
|
firstId: number // First api.syui.ai card id
|
||||||
totalCp: number
|
totalCp: number
|
||||||
count: number
|
|
||||||
bestStatus: string
|
bestStatus: string
|
||||||
bestSkill: string
|
|
||||||
latestCreatedAt: string
|
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
for (const c of cards) {
|
for (const c of cards) {
|
||||||
const existing = cardGroups.get(c.card)
|
const existing = cardGroups.get(c.card)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.totalCp += c.cp
|
existing.totalCp += c.cp
|
||||||
existing.count++
|
// Keep highest status
|
||||||
// Keep highest status (super > shiny > first > normal)
|
if (statusToRare(c.status) > statusToRare(existing.bestStatus)) {
|
||||||
if (statusPriority(c.status) > statusPriority(existing.bestStatus)) {
|
|
||||||
existing.bestStatus = c.status || 'normal'
|
existing.bestStatus = c.status || 'normal'
|
||||||
}
|
}
|
||||||
if (c.skill && c.skill !== 'normal') {
|
|
||||||
existing.bestSkill = c.skill
|
|
||||||
}
|
|
||||||
// Keep latest createdAt
|
|
||||||
if (c.created_at > existing.latestCreatedAt) {
|
|
||||||
existing.latestCreatedAt = c.created_at
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
cardGroups.set(c.card, {
|
cardGroups.set(c.card, {
|
||||||
card: c.card,
|
card: c.card,
|
||||||
|
firstId: c.id,
|
||||||
totalCp: c.cp,
|
totalCp: c.cp,
|
||||||
count: 1,
|
|
||||||
bestStatus: c.status || 'normal',
|
bestStatus: c.status || 'normal',
|
||||||
bestSkill: c.skill || 'normal',
|
|
||||||
latestCreatedAt: c.created_at
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,25 +99,27 @@ export async function performMigration(user: OldApiUser, cards: OldApiCard[]): P
|
|||||||
const cardData = Array.from(cardGroups.values())
|
const cardData = Array.from(cardGroups.values())
|
||||||
.sort((a, b) => a.card - b.card)
|
.sort((a, b) => a.card - b.card)
|
||||||
.map(g => ({
|
.map(g => ({
|
||||||
id: g.card, // Use card number as id
|
cid: String(g.firstId), // Original api.syui.ai card id (string)
|
||||||
card: g.card,
|
id: g.card, // Card number
|
||||||
cp: g.totalCp,
|
cp: g.totalCp,
|
||||||
status: g.bestStatus,
|
rare: statusToRare(g.bestStatus),
|
||||||
skill: g.bestSkill,
|
unique: g.bestStatus === 'super',
|
||||||
createdAt: toUtcDatetime(g.latestCreatedAt),
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const result = await saveMigratedCardData(userData, cardData, checksum)
|
const result = await saveMigratedCardData(userData, cardData, checksum)
|
||||||
return result !== null
|
return result !== null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status priority for comparison (higher = better)
|
// Convert status to rare value
|
||||||
function statusPriority(status: string): number {
|
function statusToRare(status: string): number {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'super': return 3
|
case 'super': return 1
|
||||||
case 'shiny': return 2
|
case 'first': return 5
|
||||||
case 'first': return 1
|
case 'second': return 4
|
||||||
default: return 0
|
case 'third': return 3
|
||||||
|
case 'fourth': return 2
|
||||||
|
case 'fifth': return 1
|
||||||
|
default: return 0 // normal and others
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,23 +174,25 @@ export function renderMigrationPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Card grid - merge by card number (same as migration logic)
|
// Card grid - merge by card number (same as migration logic)
|
||||||
const cardGroups = new Map<number, { card: number, totalCp: number, rare: number }>()
|
const cardGroups = new Map<number, { card: number, totalCp: number, rare: number, isUnique: boolean }>()
|
||||||
for (const c of oldApiCards) {
|
for (const c of oldApiCards) {
|
||||||
const existing = cardGroups.get(c.card)
|
const existing = cardGroups.get(c.card)
|
||||||
const rare = statusPriority(c.status)
|
const rare = statusToRare(c.status)
|
||||||
|
const isUnique = c.status === 'super'
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.totalCp += c.cp
|
existing.totalCp += c.cp
|
||||||
if (rare > existing.rare) existing.rare = rare
|
if (rare > existing.rare) existing.rare = rare
|
||||||
|
if (isUnique) existing.isUnique = true
|
||||||
} else {
|
} else {
|
||||||
cardGroups.set(c.card, { card: c.card, totalCp: c.cp, rare })
|
cardGroups.set(c.card, { card: c.card, totalCp: c.cp, rare, isUnique })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortedGroups = Array.from(cardGroups.values())
|
const sortedGroups = Array.from(cardGroups.values())
|
||||||
.sort((a, b) => a.card - b.card)
|
.sort((a, b) => a.card - b.card)
|
||||||
|
|
||||||
const cardsHtml = sortedGroups.map(({ card, totalCp, rare }) => {
|
const cardsHtml = sortedGroups.map(({ card, totalCp, rare, isUnique }) => {
|
||||||
const rarityClass = rare === 3 ? 'unique' : rare === 2 ? 'shiny' : rare === 1 ? 'rare' : ''
|
const rarityClass = isUnique ? 'unique' : rare >= 4 ? 'shiny' : rare >= 1 ? 'rare' : ''
|
||||||
const effectsHtml = rarityClass ? `
|
const effectsHtml = rarityClass ? `
|
||||||
<div class="card-status pattern-${rarityClass}"></div>
|
<div class="card-status pattern-${rarityClass}"></div>
|
||||||
<div class="card-status color-${rarityClass}"></div>
|
<div class="card-status color-${rarityClass}"></div>
|
||||||
|
|||||||
@@ -386,12 +386,11 @@ export async function saveMigratedCardData(
|
|||||||
updatedAt: string
|
updatedAt: string
|
||||||
},
|
},
|
||||||
cards: {
|
cards: {
|
||||||
|
cid: string
|
||||||
id: number
|
id: number
|
||||||
card: number
|
|
||||||
cp: number
|
cp: number
|
||||||
status: string
|
rare: number
|
||||||
skill: string
|
unique: boolean
|
||||||
createdAt: string
|
|
||||||
}[],
|
}[],
|
||||||
checksum: string
|
checksum: string
|
||||||
): Promise<{ uri: string; cid: string } | null> {
|
): Promise<{ uri: string; cid: string } | null> {
|
||||||
|
|||||||
Reference in New Issue
Block a user