Commit 26f8222a authored by nanahira's avatar nanahira

override text

parent 5e856f04
......@@ -48,7 +48,7 @@ env408:
DATE: '2006-05-15'
CARD_SYMBOL: '408环境'
FILE_SYMBOL: 'env408'
OLD_TEXT_DB_PATH: ./extras/2012.cdb
OVERRIDE_TEXT_DB_PATH: ./extras/2012.cdb
upload_to_minio:
stage: deploy
......
......@@ -5,7 +5,7 @@ export interface Config {
postDepth: number;
jpDatabasePath: string;
cnDatabasePath: string;
oldTextDbPath: string;
overrideTextDbPath: string;
cardListDatabasePath: string;
outputPath: string;
descSymbol: string;
......@@ -19,7 +19,7 @@ export async function loadConfig(): Promise<Config> {
postDepth: process.env.POST_DEPTH ? parseInt(process.env.POST_DEPTH) : 5,
jpDatabasePath: process.env.JP_DATABASE_PATH || "./ygopro-database/locales/ja-JP/cards.cdb",
cnDatabasePath: process.env.SOURCE_TARGET_PATH || "./ygopro-database/locales/zh-CN/cards.cdb",
oldTextDbPath: process.env.OLD_TEXT_DB_PATH || "",
overrideTextDbPath: process.env.OVERRIDE_TEXT_DB_PATH || "",
cardListDatabasePath: process.env.CARD_LIST_DATABASE_PATH || "./pack.db",
outputPath: process.env.OUTPUT_PATH || "./output",
descSymbol: process.env.CARD_SYMBOL || "简体中文卡",
......
......@@ -114,7 +114,7 @@ export class DBReader extends Base {
jpdb: Database;
cndb: Database;
outputdb: Database;
oldTextDb: Database;
overrideTextDb: Database;
async openDatabase(path: string) {
return await open({
filename: path,
......@@ -126,7 +126,7 @@ export class DBReader extends Base {
this.log.debug(`Opening databases...`);
this.cndb = await this.openDatabase(this.config.cnDatabasePath);
this.jpdb = await this.openDatabase(this.config.jpDatabasePath);
this.oldTextDb = this.config.oldTextDbPath ? await this.openDatabase(this.config.oldTextDbPath) : null;
this.overrideTextDb = this.config.overrideTextDbPath ? await this.openDatabase(this.config.overrideTextDbPath) : null;
}
async finalize() {
await this.cndb.close();
......@@ -134,8 +134,8 @@ export class DBReader extends Base {
if (this.outputdb) {
await this.outputdb.close();
}
if (this.oldTextDb) {
await this.oldTextDb.close();
if (this.overrideTextDb) {
await this.overrideTextDb.close();
}
}
private async openOutputDatabase() {
......@@ -239,12 +239,10 @@ export class DBReader extends Base {
if (this.config.fileSymbol === 'cn') {
card.datas.ot |= 0x8;
}
if (this.oldTextDb) {
const oldTextEntry = await this.oldTextDb.get('SELECT desc FROM texts WHERE id = ?', [card.code]);
if (oldTextEntry) {
const oldText = oldTextEntry.desc;
const newText = card.texts.desc;
card.texts.desc = `旧效果:\r\n${oldText}\r\n\r\n新效果:\r\n${newText}`;
if (this.overrideTextDb) {
const overrideTextEntry = await this.overrideTextDb.get('SELECT desc FROM texts WHERE id = ?', [card.code]);
if (overrideTextEntry) {
card.texts.desc = overrideTextEntry.desc;
}
}
card.texts.desc += '\r\n\r\n\u2605' + this.config.descSymbol;
......
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