Skip to content

Commit

Permalink
Fix some issues with the gallery builder script
Browse files Browse the repository at this point in the history
  • Loading branch information
madelson committed Nov 7, 2024
1 parent c6a5829 commit 4e6106b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
11 changes: 8 additions & 3 deletions gallery/BuildGallery.linq
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async Task Main()
foreach (var card in universesBeyondCards)
{
var universesBeyondName = card.Card.Flavor_Name ?? card.Card.Name;
var universesWithinCard = universesWithinCardsByName.TryGetValue(card.Card.Name, out var c) ? c
var universesWithinCard = !card.Card.Layout.Contains("token") && universesWithinCardsByName.TryGetValue(card.Card.Name, out var c) ? c
: universesWithinCardsByName.TryGetValue(DisambiguatedName(card.Card), out c) ? c
: null;
var universesWithinName = card.OfficialUniversesWithinCard?.Name ?? universesWithinCard?.Info.Nickname;
Expand Down Expand Up @@ -372,10 +372,14 @@ async Task<List<CardInfo>> GetUniversesBeyondCardsAsync()
{
var allCards = await CacheAsync("all-cards", GetAllCardsAsync);
// unique:prints is needed to make sure we capture all sets that contain UB cards. Some promo set codes like pltr won't show up otherwise
var universesBeyondCards = await CacheAsync("universes-beyond-cards", () => SearchAsync("is:ub -is:reprint unique:prints"));
var universesBeyondCards = await CacheAsync("universes-beyond-cards", () => SearchAsync("is:ub -is:reprint -is:digital unique:prints"));

var allCardsByOracleId = allCards.ToLookup(c => c.Oracle_Id);
var universesBeyondSets = universesBeyondCards.Select(c => c.Set).ToHashSet();
// Above we exclude reprints since we don't care to include in-universe cards which were reprinted in UB sets. However, pltc is a case where
// a UB card was reprinted in another UB set. We need to make sure that set is tagged as UB so that it doesn't look like an official UW printing.
// This is not a complete solution because at some point we'll surely get a UB reprint into a non-promotional UB set.
universesBeyondSets.UnionWith(universesBeyondSets.Select(s => "p" + s).ToArray());

return universesBeyondCards.GroupBy(c => c.Oracle_Id)
.Select(g => g.MinBy(c => c.Released_At)!)
Expand Down Expand Up @@ -443,7 +447,8 @@ record Card(
CardFace[] Card_Faces,
string Set,
DateTime Released_At,
string Collector_Number)
string Collector_Number,
string Layout)
{
public string GetFrontImage() => (Image_Uris ?? Card_Faces[0].Image_Uris)["normal"];
public string? GetBackImage() => Card_Faces?[1].Image_Uris?["normal"];
Expand Down
6 changes: 0 additions & 6 deletions gallery/cardData.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,6 @@
"nickname": "Cliffhaven Sanctifier",
"image": "https://madelson.github.io/universes-within-collection/cards/Space%20Marine%20Devastator.png"
},
{
"oracleId": "d74a5638-83cc-480b-bb02-caecc6a8ff2e",
"name": "Space Marine Devastator",
"nickname": "Cliffhaven Sanctifier",
"image": "https://madelson.github.io/universes-within-collection/cards/Space%20Marine%20Devastator.png"
},
{
"oracleId": "3e924a35-0e08-4050-b33a-a143d2ab5aea",
"name": "Starscream, Power Hungry // Starscream, Seeker Leader",
Expand Down
34 changes: 13 additions & 21 deletions gallery/galleryData.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ const data = {
"universesBeyondImage": "https://cards.scryfall.io/normal/front/4/a/4a821438-2b60-421e-9fd2-3ce3ec958eb7.jpg?1673308496",
"universesWithinImage": "./cards/Space%20Marine%20Devastator.png"
},
{
"name": "Space Marine Devastator",
"nickname": "Cliffhaven Sanctifier",
"contributionInfo": {
"contributor": "cgregory",
"front": {
"artist": "Nickolas Paris",
"artistUrl": "https://nickolasparis.com",
"artName": "Kor Mage",
"artUrl": "https://nickolasparis.com/projects/BXVe19?album_id=8299747",
"mtgCardBuilderId": "208242"
}
},
"universesBeyondImage": "https://cards.scryfall.io/normal/front/a/a/aa796e45-1d95-44f7-927d-0cdd2f67da78.jpg?1675455163",
"universesWithinImage": "./cards/Space%20Marine%20Devastator.png"
},
{
"name": "Battlefield Improvisation",
"contributionInfo": {
Expand Down Expand Up @@ -1641,6 +1625,10 @@ const data = {
"name": "Imotekh the Stormlord",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/2/8/286ff901-1faf-4a02-a37a-fa165989112f.jpg?1674058380"
},
{
"name": "Space Marine Devastator",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/a/a/aa796e45-1d95-44f7-927d-0cdd2f67da78.jpg?1675455163"
},
{
"name": "Primaris Eliminator",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/d/b/db7ab081-d6cd-4323-98bf-536e4df95115.jpg?1677541618"
Expand Down Expand Up @@ -5502,6 +5490,10 @@ const data = {
"name": "Layla Hassan",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/2/2/2278d97e-791a-4843-a385-65bac79bde7a.jpg?1721423616"
},
{
"name": "The Capitoline Triad Emblem",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/0/5/05402b51-8cf9-4f69-aa12-8a9d5981f8b1.jpg?1730837194"
},
{
"name": "Apple of Eden, Isu Relic",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/1/7/17dd0b7f-bd26-4a46-a7a1-bc65138d54ed.jpg?1721424175"
Expand Down Expand Up @@ -5552,23 +5544,23 @@ const data = {
},
{
"name": "Captain America, First Avenger",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/b/b/bba7e9c8-c24c-4bd3-b398-fe42b1fcfb5d.jpg?1729528769"
"universesBeyondImage": "https://cards.scryfall.io/normal/front/b/b/bba7e9c8-c24c-4bd3-b398-fe42b1fcfb5d.jpg?1730758326"
},
{
"name": "Iron Man, Titan of Innovation",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/7/5/7542b1d1-e34d-46dc-af24-1b718034c0e4.jpg?1729295830"
"universesBeyondImage": "https://cards.scryfall.io/normal/front/7/5/7542b1d1-e34d-46dc-af24-1b718034c0e4.jpg?1730758324"
},
{
"name": "Wolverine, Best There Is",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/e/b/ebe83332-195e-4ac1-878f-f52eef62ce6a.jpg?1729387116"
"universesBeyondImage": "https://cards.scryfall.io/normal/front/e/b/ebe83332-195e-4ac1-878f-f52eef62ce6a.jpg?1730758319"
},
{
"name": "Storm, Force of Nature",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/6/a/6af7766e-7438-4128-a1f2-8b3b3ba3c650.jpg?1729272972"
"universesBeyondImage": "https://cards.scryfall.io/normal/front/6/a/6af7766e-7438-4128-a1f2-8b3b3ba3c650.jpg?1730758321"
},
{
"name": "Black Panther, Wakandan King",
"universesBeyondImage": "https://cards.scryfall.io/normal/front/3/a/3a93a12d-6913-4d9e-8e9c-8067147e37f2.jpg?1729274053"
"universesBeyondImage": "https://cards.scryfall.io/normal/front/3/a/3a93a12d-6913-4d9e-8e9c-8067147e37f2.jpg?1730758329"
}
]
}; export default data;

0 comments on commit 4e6106b

Please sign in to comment.