Skip to content
Permalink
Browse files

metadata bad cloning

  • Loading branch information...
Manuel-777 committed Oct 8, 2019
1 parent 0f7c456 commit 4662782ce635b7164fefeada509cbc88b77403b3
Showing with 40 additions and 3 deletions.
  1. +7 −3 scripts/metadata.js
  2. +33 −0 shared/database.js
@@ -3,6 +3,7 @@ const path = require("path");
const fs = require("fs");
var http = require("https");
const readline = require("readline");
const _ = require("lodash");

const manifestParser = require("./manifest-parser");
const { generateMetadata } = require("./metadata-generator");
@@ -254,8 +255,9 @@ function generateScryfallDatabase() {
if (obj.layout == "adventure") {
obj.card_faces.forEach(face => {
let name = face.name;
let newObj = Object.assign(_.cloneDeep(obj), face);
scryfallDataAdd(
Object.assign(obj, face),
newObj,
obj.lang,
obj.set,
name,
@@ -266,8 +268,9 @@ function generateScryfallDatabase() {
if (obj.layout == "transform") {
obj.card_faces.forEach(face => {
let name = face.name;
let newObj = Object.assign(_.cloneDeep(obj), face);
scryfallDataAdd(
Object.assign(obj, face),
newObj,
obj.lang,
obj.set,
name,
@@ -278,8 +281,9 @@ function generateScryfallDatabase() {
if (obj.layout == "split") {
obj.card_faces.forEach(face => {
let name = face.name;
let newObj = Object.assign(_.cloneDeep(obj), face);
scryfallDataAdd(
Object.assign(obj, face),
newObj,
obj.lang,
obj.set,
name,
@@ -8,6 +8,30 @@ const cachePath =
? path.join((app || remote.app).getPath("userData"), "database.json")
: null;

/*
This is cool for debugging the metadata files, so we can
test and view the output files without copypasta.
const cachePath =
app || (remote && remote.app)
? path.join(
(app || remote.app).getPath("userData"),
"..",
"Electron",
"external",
"v22-zh-cn-database.json"
)
: null;
const scryfallDataPath = path.join(
(app || remote.app).getPath("userData"),
"..",
"Electron",
"external",
"scryfall-cards.json"
);
*/

// Some other things should go here later, like updating from MTGA Servers themselves.
class Database {
constructor() {
@@ -34,6 +58,15 @@ class Database {
dbUri = cachePath;
}
const defaultDb = fs.readFileSync(dbUri, "utf8");
/*
try {
let scryfallData = fs.readFileSync(scryfallDataPath, "utf8");
this.scryfallData = JSON.parse(scryfallData);
} catch (e) {
console.log("Error parsing scryfall data", e);
}
*/

this.handleSetDb(null, defaultDb);

Database.instance = this;

0 comments on commit 4662782

Please sign in to comment.
You can’t perform that action at this time.