Skip to content

Commit

Permalink
New query for Magic sets as spreadsheet rows.
Browse files Browse the repository at this point in the history
  • Loading branch information
daggerhart committed Mar 7, 2021
1 parent edd9db7 commit 0a1696f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SCRYFALLSETS(fields, types, num_results)
`=SCRYFALLSETS("name")`

### List set details and limit the results to specific set types
`=SCRYFALLSETS("name code release type", "core expansion commander", 700)`
`=SCRYFALLSETS("name code release type", "core expansion commander")`

# "Bugs"

Expand Down
8 changes: 5 additions & 3 deletions scryfall-google-sheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ const scryfallSearch_ = (params, num_results = MAX_RESULTS_) => {
*
* @param {"name code released_at"} fields List of fields to return from Scryfall, "name" is default
* @param {"core expansion promo"} types List of set types to return from Scryfall, "all" set types is default
* @param {150} num_results Number of results (default 150, maximum 700)
* @param {700} num_results Number of results (default 150, maximum 700)
* @return List of Scryfall sets
* @customfunction
*/
const SCRYFALLSETS = (fields = "name", types = "all", num_results = 150) => {
const SCRYFALLSETS = (fields = "name", types = "all", num_results = 700) => {
if (num_results > MAX_RESULTS_) {
num_results = MAX_RESULTS_;
}
Expand All @@ -175,7 +175,7 @@ const SCRYFALLSETS = (fields = "name", types = "all", num_results = 150) => {
const sets = scryfallSets_(num_results);
let output = [];

sets.splice(0, num_results).forEach(set => {
sets.forEach(set => {
if (filter_types && types.indexOf(set.set_type) < 0) {
return ;
}
Expand All @@ -188,6 +188,8 @@ const SCRYFALLSETS = (fields = "name", types = "all", num_results = 150) => {
output.push(row);
});

output = output.splice(0, num_results);

return output;
};

Expand Down

0 comments on commit 0a1696f

Please sign in to comment.