Skip to content

Commit 8a07869

Browse files
committed
games: Render Splendor card tokens as rectangles instead of squares
1 parent 0c4ef24 commit 8a07869

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

src/ps/games/splendor/render.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,31 +112,40 @@ function getCardStyles(imageSrc: string | null): CSSProperties {
112112
};
113113
}
114114

115-
function TypeToken({ type, square }: { type: TOKEN_TYPE; square?: boolean | undefined }): ReactElement {
115+
function TypeToken({ type, rectangle }: { type: TOKEN_TYPE; rectangle?: boolean | undefined }): ReactElement {
116116
const data = metadata.types[type];
117117

118-
const imgUrl = square && type === TOKEN_TYPE.DRAGON ? getArtUrl('other', 'question-mark.png') : getArtUrl('type', data.art);
119-
const size = square ? '94%' : '77%';
118+
const imgUrl = rectangle && type === TOKEN_TYPE.DRAGON ? getArtUrl('other', 'question-mark.png') : getArtUrl('type', data.art);
119+
const size = rectangle ? '94%' : '77%';
120+
121+
const dimensions = rectangle ? { height: 120, width: 96 } : { height: 108, width: 108 };
120122

121123
return (
122124
<div
123125
style={{
124-
height: 108,
125-
width: 108,
126+
...dimensions,
126127
margin: 8,
127128
marginBottom: -12,
128-
borderRadius: square ? 12 : 99,
129+
borderRadius: rectangle ? 12 : 99,
129130
display: 'inline-block',
130131
background: `no-repeat center/${size} ${imgUrl}, ${TOKEN_COLOURS[type]}`,
131132
}}
132133
/>
133134
);
134135
}
135136

136-
function TypeTokenCount({ type, count, square }: { type: TOKEN_TYPE; count: number; square?: boolean | undefined }): ReactElement {
137+
function TypeTokenCount({
138+
type,
139+
count,
140+
rectangle,
141+
}: {
142+
type: TOKEN_TYPE;
143+
count: number;
144+
rectangle?: boolean | undefined;
145+
}): ReactElement {
137146
return (
138147
<div style={{ display: 'inline-block', margin: '0 12px 0 0' }}>
139-
<TypeToken type={type} square={square} />
148+
<TypeToken type={type} rectangle={rectangle} />
140149
<span style={{ position: 'relative', bottom: 18, color: count === 0 ? '#aaa' : undefined, fontSize: 72 }}>
141150
×<b>{count}</b>
142151
</span>
@@ -162,7 +171,7 @@ export function TrainerCard({ data }: { data: Trainer }): ReactElement {
162171
}}
163172
>
164173
<div style={{ background: '#1119', borderBottom: '1px solid black', textAlign: 'right' }}>
165-
<strong style={{ fontSize: '36px', marginRight: 12, position: 'relative', top: 4 }}>{data.points}</strong>
174+
<strong style={{ fontSize: '32px', marginRight: 12, position: 'relative', top: 4 }}>{data.points}</strong>
166175
<div
167176
style={{
168177
position: 'absolute',
@@ -176,7 +185,7 @@ export function TrainerCard({ data }: { data: Trainer }): ReactElement {
176185
>
177186
{(Object.entries(data.types) as [TOKEN_TYPE, number][]).map(([tokenType, cost]) => (
178187
<div>
179-
<TypeTokenCount type={tokenType} count={cost} square />
188+
<TypeTokenCount type={tokenType} count={cost} rectangle />
180189
</div>
181190
))}
182191
</div>
@@ -622,7 +631,7 @@ export function ActivePlayer({
622631
<details open style={{ display: 'inline-block', verticalAlign: 'top' }}>
623632
<summary style={{ ...RESOURCE_STYLES, cursor: 'pointer' }}>
624633
{cards.map(([tokenType, { length: count }]) => (
625-
<TypeTokenCount type={tokenType} count={count} square />
634+
<TypeTokenCount type={tokenType} count={count} rectangle />
626635
))}
627636
</summary>
628637
<div style={{ zoom: '75%', display: 'inline' }}>
@@ -684,7 +693,7 @@ export function PlayerSummary({ data }: { data: PlayerData }): ReactElement {
684693

685694
const cardsEl = AllTokenTypes.filterMap(type => {
686695
const count = cards[type]?.length;
687-
if (count) return <TypeTokenCount type={type} count={count} square />;
696+
if (count) return <TypeTokenCount type={type} count={count} rectangle />;
688697
});
689698
const tokensEl = AllTokenTypes.filterMap(type => {
690699
const count = data.tokens[type];

0 commit comments

Comments
 (0)