Commit 5e856f04 authored by nanahira's avatar nanahira

double text & ygopro2 build

parent c2a26668
Pipeline #29947 passed with stages
in 2 minutes and 28 seconds
stages: stages:
- generate - generate
- deploy - deploy
- deploy2
variables: variables:
GIT_DEPTH: "1" GIT_DEPTH: "1"
...@@ -47,6 +48,7 @@ env408: ...@@ -47,6 +48,7 @@ env408:
DATE: '2006-05-15' DATE: '2006-05-15'
CARD_SYMBOL: '408环境' CARD_SYMBOL: '408环境'
FILE_SYMBOL: 'env408' FILE_SYMBOL: 'env408'
OLD_TEXT_DB_PATH: ./extras/2012.cdb
upload_to_minio: upload_to_minio:
stage: deploy stage: deploy
...@@ -109,3 +111,9 @@ deploy_server_env408: ...@@ -109,3 +111,9 @@ deploy_server_env408:
deploy_mycard_env408: deploy_mycard_env408:
extends: .deploy_mycard extends: .deploy_mycard
deploy_mycard2_env408:
extends: .deploy_mycard
stage: deploy2
variables:
APP_ID: ygopro2-408
File added
...@@ -5,6 +5,7 @@ export interface Config { ...@@ -5,6 +5,7 @@ export interface Config {
postDepth: number; postDepth: number;
jpDatabasePath: string; jpDatabasePath: string;
cnDatabasePath: string; cnDatabasePath: string;
oldTextDbPath: string;
cardListDatabasePath: string; cardListDatabasePath: string;
outputPath: string; outputPath: string;
descSymbol: string; descSymbol: string;
...@@ -18,6 +19,7 @@ export async function loadConfig(): Promise<Config> { ...@@ -18,6 +19,7 @@ export async function loadConfig(): Promise<Config> {
postDepth: process.env.POST_DEPTH ? parseInt(process.env.POST_DEPTH) : 5, postDepth: process.env.POST_DEPTH ? parseInt(process.env.POST_DEPTH) : 5,
jpDatabasePath: process.env.JP_DATABASE_PATH || "./ygopro-database/locales/ja-JP/cards.cdb", 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", cnDatabasePath: process.env.SOURCE_TARGET_PATH || "./ygopro-database/locales/zh-CN/cards.cdb",
oldTextDbPath: process.env.OLD_TEXT_DB_PATH || "",
cardListDatabasePath: process.env.CARD_LIST_DATABASE_PATH || "./pack.db", cardListDatabasePath: process.env.CARD_LIST_DATABASE_PATH || "./pack.db",
outputPath: process.env.OUTPUT_PATH || "./output", outputPath: process.env.OUTPUT_PATH || "./output",
descSymbol: process.env.CARD_SYMBOL || "简体中文卡", descSymbol: process.env.CARD_SYMBOL || "简体中文卡",
......
...@@ -114,6 +114,7 @@ export class DBReader extends Base { ...@@ -114,6 +114,7 @@ export class DBReader extends Base {
jpdb: Database; jpdb: Database;
cndb: Database; cndb: Database;
outputdb: Database; outputdb: Database;
oldTextDb: Database;
async openDatabase(path: string) { async openDatabase(path: string) {
return await open({ return await open({
filename: path, filename: path,
...@@ -125,6 +126,7 @@ export class DBReader extends Base { ...@@ -125,6 +126,7 @@ export class DBReader extends Base {
this.log.debug(`Opening databases...`); this.log.debug(`Opening databases...`);
this.cndb = await this.openDatabase(this.config.cnDatabasePath); this.cndb = await this.openDatabase(this.config.cnDatabasePath);
this.jpdb = await this.openDatabase(this.config.jpDatabasePath); this.jpdb = await this.openDatabase(this.config.jpDatabasePath);
this.oldTextDb = this.config.oldTextDbPath ? await this.openDatabase(this.config.oldTextDbPath) : null;
} }
async finalize() { async finalize() {
await this.cndb.close(); await this.cndb.close();
...@@ -132,6 +134,9 @@ export class DBReader extends Base { ...@@ -132,6 +134,9 @@ export class DBReader extends Base {
if (this.outputdb) { if (this.outputdb) {
await this.outputdb.close(); await this.outputdb.close();
} }
if (this.oldTextDb) {
await this.oldTextDb.close();
}
} }
private async openOutputDatabase() { private async openOutputDatabase() {
const fullPath = `${this.config.outputPath}/expansions/${this.config.fileSymbol}.cdb`; const fullPath = `${this.config.outputPath}/expansions/${this.config.fileSymbol}.cdb`;
...@@ -230,12 +235,20 @@ export class DBReader extends Base { ...@@ -230,12 +235,20 @@ export class DBReader extends Base {
await Promise.all(cards.map(card => card.loadData(this.cndb))); await Promise.all(cards.map(card => card.loadData(this.cndb)));
const extendedCards = (await Promise.all(cards.map(card => card.getRelatedCards(this.cndb)))).flat(); const extendedCards = (await Promise.all(cards.map(card => card.getRelatedCards(this.cndb)))).flat();
const allCards = _.uniqBy(cards.concat(extendedCards), (s) => s.code); const allCards = _.uniqBy(cards.concat(extendedCards), (s) => s.code);
allCards.forEach((card) => { await Promise.all(allCards.map(async(card) => {
if (this.config.fileSymbol === 'cn') { if (this.config.fileSymbol === 'cn') {
card.datas.ot |= 0x8; 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}`;
}
}
card.texts.desc += '\r\n\r\n\u2605' + this.config.descSymbol; card.texts.desc += '\r\n\r\n\u2605' + this.config.descSymbol;
}) }));
const queries = allCards.flatMap(card => card.getSQLQueries()); const queries = allCards.flatMap(card => card.getSQLQueries());
await this.openOutputDatabase(); await this.openOutputDatabase();
await this.outputdb.run("BEGIN TRANSACTION;"); await this.outputdb.run("BEGIN TRANSACTION;");
......
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