Commit b26d75e2 authored by Chunchi Che's avatar Chunchi Che

add lscale and rscale support

parent 760de93a
Pipeline #23034 failed with stages
in 14 minutes and 10 seconds
...@@ -16,6 +16,8 @@ export interface CardData { ...@@ -16,6 +16,8 @@ export interface CardData {
level?: number; level?: number;
race?: number; race?: number;
attribute?: number; attribute?: number;
lscale?: number;
rscale?: number;
} }
export interface CardText { export interface CardText {
......
import { Database } from "sql.js"; import { Database } from "sql.js";
import { CardData, CardMeta, CardText } from "@/api"; import { CardData, CardMeta, CardText } from "@/api";
import { constructCardMeta } from ".";
const TYPE_MONSTER = 0x1; const TYPE_MONSTER = 0x1;
export interface FtsConditions { export interface FtsConditions {
...@@ -40,7 +42,7 @@ export function invokeFts(db: Database, params: FtsParams): CardMeta[] { ...@@ -40,7 +42,7 @@ export function invokeFts(db: Database, params: FtsParams): CardMeta[] {
const dataStmt = db.prepare(sql); const dataStmt = db.prepare(sql);
const data: CardData = dataStmt.getAsObject({ $id: id }); const data: CardData = dataStmt.getAsObject({ $id: id });
if (Object.values(data).filter((v) => v !== undefined).length > 0) { if (Object.values(data).filter((v) => v !== undefined).length > 0) {
ftsMetas.push({ id, data, text }); ftsMetas.push(constructCardMeta(id, data, text));
} }
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import initSqlJs, { Database } from "sql.js"; import initSqlJs, { Database } from "sql.js";
import { CardMeta } from "@/api/cards"; import { CardData, CardMeta, CardText } from "@/api/cards";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { pfetch } from "@/infra"; import { pfetch } from "@/infra";
...@@ -107,11 +107,16 @@ export default async function (action: sqliteAction): Promise<sqliteResult> { ...@@ -107,11 +107,16 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
} }
} }
function constructCardMeta( export function constructCardMeta(
id: number, id: number,
data: initSqlJs.ParamsObject, data: CardData,
text: initSqlJs.ParamsObject text: CardText
): CardMeta { ): CardMeta {
const level = data.level ?? 0;
data.level = level & 0xff;
data.lscale = (level >> 24) & 0xff;
data.rscale = (level >> 16) & 0xff;
return { return {
id, id,
data, data,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment