Skip to content

Commit

Permalink
Upgrade card DB for dynamic card loads
Browse files Browse the repository at this point in the history
No ID in cards.csv yet though, so I've hard-coded the dynamic-card-image-loader-and-thumbnailer to Earth C.
  • Loading branch information
nie7321 committed Oct 27, 2023
1 parent 11de953 commit 823d2d1
Show file tree
Hide file tree
Showing 96 changed files with 41 additions and 17 deletions.
Binary file added src/cards/images/Set1_Chara001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara014.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara016.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara017.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara019.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara020.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara021.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara022.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara025.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cards/images/Set1_Chara026.png
Binary file added src/cards/images/Set1_Chara027.png
Binary file added src/cards/images/Set1_Chara028.png
Binary file added src/cards/images/Set1_Chara029.png
Binary file added src/cards/images/Set1_Chara030.png
Binary file added src/cards/images/Set1_Chara031.png
Binary file added src/cards/images/Set1_Chara032.png
Binary file added src/cards/images/Set1_Chara033.png
Binary file added src/cards/images/Set1_Chara034.png
Binary file added src/cards/images/Set1_Chara035.png
Binary file added src/cards/images/Set1_Chara036.png
Binary file added src/cards/images/Set1_Chara037.png
Binary file added src/cards/images/Set1_Chara038.png
Binary file added src/cards/images/Set1_Chara039.png
Binary file added src/cards/images/Set1_Chara040.png
Binary file added src/cards/images/Set1_Chara041.png
Binary file added src/cards/images/Set1_Chara042.png
Binary file added src/cards/images/Set1_Chara043.png
Binary file added src/cards/images/Set1_Chara044.png
Binary file added src/cards/images/Set1_Chara045.png
Binary file added src/cards/images/Set1_Chara046.png
Binary file added src/cards/images/Set1_Chara047.png
Binary file added src/cards/images/Set1_Chara048.png
Binary file added src/cards/images/Set1_Chara049.png
Binary file added src/cards/images/Set1_Exc001.png
Binary file added src/cards/images/Set1_Exc002.png
Binary file added src/cards/images/Set1_Exc003.png
Binary file added src/cards/images/Set1_Exc004.png
Binary file added src/cards/images/Set1_Exc005.png
Binary file added src/cards/images/Set1_Exc006.png
Binary file added src/cards/images/Set1_Exc007.png
Binary file added src/cards/images/Set1_Exc008.png
Binary file added src/cards/images/Set1_Exc009.png
Binary file added src/cards/images/Set1_Exc010.png
Binary file added src/cards/images/Set1_Exc011.png
Binary file added src/cards/images/Set1_Exc012.png
Binary file added src/cards/images/Set1_Exc013.png
Binary file added src/cards/images/Set1_Exc014.png
Binary file added src/cards/images/Set1_Exc015.png
Binary file added src/cards/images/Set1_Exc016.png
Binary file added src/cards/images/Set1_Exc017.png
Binary file added src/cards/images/Set1_Exc018.png
Binary file added src/cards/images/Set1_Exc019.png
Binary file added src/cards/images/Set1_Exc020.png
Binary file added src/cards/images/Set1_Exc021.png
Binary file added src/cards/images/Set1_Exc022.png
Binary file added src/cards/images/Set1_Inv001.png
Binary file added src/cards/images/Set1_Inv002.png
Binary file added src/cards/images/Set1_Inv003.png
Binary file added src/cards/images/Set1_Inv004.png
Binary file added src/cards/images/Set1_Inv005.png
Binary file added src/cards/images/Set1_Inv006.png
Binary file added src/cards/images/Set1_Inv007.png
Binary file added src/cards/images/Set1_Inv008.png
Binary file added src/cards/images/Set1_Inv009.png
Binary file added src/cards/images/Set1_Inv010.png
Binary file added src/cards/images/Set1_Inv011.png
Binary file added src/cards/images/Set1_Inv012.png
Binary file added src/cards/images/Set1_Inv013.png
Binary file added src/cards/images/Set1_Inv014.png
Binary file added src/cards/images/Set1_Inv015.png
Binary file added src/cards/images/Set1_Inv016.png
Binary file added src/cards/images/Set1_Inv017.png
Binary file added src/cards/images/Set1_Inv018.png
Binary file added src/cards/images/Set1_Inv019.png
Binary file added src/cards/images/Set1_Planet1.png
Binary file added src/cards/images/Set1_Planet1b.png
Binary file added src/cards/images/Set1_Planet2.png
Binary file added src/cards/images/Set1_Planet2b.png
47 changes: 31 additions & 16 deletions src/components/CardRow.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---
import { Image } from 'astro:assets';
import { getImage } from "astro:assets";
interface Props {
artCollection: {
[propName: string]: object;
};
card: {
TITLE: string;
SUBTITLE: string;
Expand All @@ -17,22 +23,27 @@ interface Props {
};
}
/**
TITLE: 'NO MERCY',
SUBTITLE: 'what is grief',
POWER: '',
ENTER: '2g',
TAGS: '',
'MAIN TEXT': '~ATH: your own chracter card. Execute: Gain 4 Grist.',
FLAVOR: '',
ART: '',
CREDIT: '',
STAR: '2',
AMOUNT: '1',
TEMPLATE: 'C:\\Users\\luche\\Documents\\Writing\\Games\\Homestuck ATCG\\nanDeck\\ND_ExecuteTemplate.png'
*/
const { card, artCollection } = Astro.props;
// For now, pretend we have this. It'll be available in the new revision of the export sheet.
const cardIdentifier = 'Set1_Planet2';
// Most cards have 1, but planets have 2, so we're using an array to deal with em.
let cardArt = [
artCollection[`${cardIdentifier}.png`],
artCollection[`${cardIdentifier}b.png`],
];
cardArt = await Promise.all(
cardArt.map(async (art) => {
const publicImage = await getImage({src: art});
const { card } = Astro.props;
return {
asset: art,
public: publicImage,
};
})
);
---
<tr>
<td>{card.TITLE}</td>
Expand All @@ -44,7 +55,11 @@ const { card } = Astro.props;
<td>{card['MAIN TEXT']}</td>
<td>{card.FLAVOR}</td>
<td>{card.CREDIT}</td>
<td>[img]</td>
<td>
<div class="flex flex-row">
{ cardArt.map((image) => <a class="ml-4" href={ image.public.src } target="_blank"><Image src={ image.asset } width="34" height="48" alt="Card {card.TITLE}"/></a>) }
</div>
</td>
<td>001 The Opening Note</td>
<td>XXX-Y</td>
</tr>
11 changes: 10 additions & 1 deletion src/pages/Cards.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ const cards = parse(cardCsv, {
columns: true,
skip_empty_lines: true
});
const cardArt = await Astro.glob('../cards/images/*.png');
const fileNameExtractor = /\/src\/cards\/images\/(.*)\?/;
const artCollection = Object.fromEntries(cardArt.map((art) => {
const imageName = art.default.src.match(fileNameExtractor)[1];
return [imageName, art.default];
}));
---
<SiteLayout title="Card Database" wide=true>
<h1 class="sr-only">Cards</h1>
Expand All @@ -31,7 +40,7 @@ const cards = parse(cardCsv, {
</tr>
</thead>
<tbody>
{ cards.map((card) => <CardRow card={card} />) }
{ cards.map((card) => <CardRow card={card} artCollection={artCollection} />) }
</tbody>
</table>
</div>
Expand Down

0 comments on commit 823d2d1

Please sign in to comment.