Commit c49b53b1 authored by nanahira's avatar nanahira

fixes

parent a0c92c8c
Pipeline #4900 passed with stages
in 1 minute and 48 seconds
...@@ -4,9 +4,13 @@ import _ from "underscore"; ...@@ -4,9 +4,13 @@ import _ from "underscore";
import { CNOCGFetcher } from "./src/cnocg"; import { CNOCGFetcher } from "./src/cnocg";
import { ExtraCards } from "./src/ExtraCards"; import { ExtraCards } from "./src/ExtraCards";
import { DirectFetcher } from "./src/direct"; import { DirectFetcher } from "./src/direct";
import Logger from "bunyan";
async function main() { async function main() {
const dbreader = new DBReader({ name: "Database" }); const dbreader = new DBReader({
name: "Database",
//level: Logger.DEBUG
});
await dbreader.init(); await dbreader.init();
//const cards = await CNOCGFetcher.fetchOnce(); //const cards = await CNOCGFetcher.fetchOnce();
//const missingExtraCards = ExtraCards.filter(c => !cards.some(cc => c.code === cc.code)); //const missingExtraCards = ExtraCards.filter(c => !cards.some(cc => c.code === cc.code));
......
...@@ -20,6 +20,7 @@ export class SQLQuery { ...@@ -20,6 +20,7 @@ export class SQLQuery {
this.values = values; this.values = values;
} }
async perform(db: Database) { async perform(db: Database) {
//console.log(db.config.filename, this.sql, this.values);
await db.run(this.sql, this.values); await db.run(this.sql, this.values);
} }
} }
...@@ -186,8 +187,8 @@ export class DBReader extends Base { ...@@ -186,8 +187,8 @@ export class DBReader extends Base {
return cards; return cards;
} }
async getOtherCardCodes(cnCodes: number[]) { async getOtherCardCodes(cnCodes: number[]) {
const sql = `SELECT id FROM datas WHERE 1 AND ${cnCodes.map(m => "id != ?").join(" AND ")}`; const sql = `SELECT id FROM datas WHERE id not IN (${cnCodes.join(",")})`;
const otherCodes: number[] = (await this.cndb.all(sql, cnCodes)).map(m => m.id); const otherCodes: number[] = (await this.cndb.all(sql)).map(m => m.id);
return otherCodes; return otherCodes;
} }
async generateBanlist(codes: number[]) { async generateBanlist(codes: number[]) {
...@@ -203,7 +204,7 @@ export class DBReader extends Base { ...@@ -203,7 +204,7 @@ export class DBReader extends Base {
await fs.writeFile(`${this.config.outputPath}/expansions/lflist.conf`, banlistString); await fs.writeFile(`${this.config.outputPath}/expansions/lflist.conf`, banlistString);
} }
async generatePatch(codes: number[]) { async generatePatch(codes: number[]) {
const patchString = `update datas set ot = ot | 0x8 where ${codes.map(code => `id = ${code}`).join(' or ')};`; const patchString = `update datas set ot = ot | 0x8 where id IN (${codes.join(',')});`;
await fs.writeFile(`${this.config.outputPath}/patch.sql`, patchString); await fs.writeFile(`${this.config.outputPath}/patch.sql`, patchString);
} }
private async categorizeCards(cards: Card[]): Promise<CardPool> { private async categorizeCards(cards: Card[]): Promise<CardPool> {
...@@ -233,12 +234,12 @@ export class DBReader extends Base { ...@@ -233,12 +234,12 @@ export class DBReader extends Base {
} }
await this.outputdb.run("COMMIT;"); await this.outputdb.run("COMMIT;");
const allCodes = allCards.map(card => card.code); const allCodes = allCards.map(card => card.code);
this.log.debug(`Database created.`); this.log.info(`Database created.`);
await this.generateBanlist(allCodes); await this.generateBanlist(allCodes);
this.log.debug(`LFList created.`); this.log.info(`LFList created.`);
await this.generatePatch(allCodes); await this.generatePatch(allCodes);
this.log.debug(`Patch created.`); this.log.info(`Patch created.`);
await this.generateDecks(cards); await this.generateDecks(cards);
this.log.debug(`Decks generated.`); this.log.info(`Decks generated.`);
} }
} }
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