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