mtg-chair-ai/card-search.js

19 lines
545 B
JavaScript
Raw Normal View History

2024-05-20 22:47:54 +00:00
//TODO: Use args for search strings, input, and output files
const fs = require("fs")
var cardArray = JSON.parse(fs.readFileSync("output.json", "utf8"))
var searchStrings = ["chair", "throne", "seat"]
var searchResults = cardArray.filter((card) => {
return (
card.caption &&
searchStrings.some((searchString) =>
card.caption.toLowerCase().includes(searchString)
)
)
})
console.log(`Found ${searchResults.length} cards with search strings`)
fs.writeFileSync("search-results.json", JSON.stringify(searchResults), "utf8")