Skip to content

Commit 9be55e8

Browse files
sookmaxcpojer
andauthored
Improve PlayerCard UI (#38)
Co-authored-by: cpojer <christoph.pojer@gmail.com>
1 parent 9b9c819 commit 9be55e8

File tree

1 file changed

+99
-80
lines changed

1 file changed

+99
-80
lines changed

hera/ui/PlayerCard.tsx

+99-80
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export default memo(function PlayerCard({
226226
<span style={{ color }}>{player.id}.</span> {user?.displayName}
227227
{isBot(player) && <Icon className={iconStyle} icon={Android} />}
228228
</div>
229-
<Stack className={offsetStyle} gap nowrap stretch>
229+
<Stack className={offsetStyle} gap={16} nowrap stretch>
230230
<Funds
231231
className={cx(
232232
ellipsis,
@@ -236,97 +236,115 @@ export default memo(function PlayerCard({
236236
)}
237237
value={shouldShow ? player.funds : '???'}
238238
/>
239-
{winConditions
240-
.filter(
241-
(condition) =>
242-
!condition.hidden &&
243-
(winConditionHasAmounts(condition) ||
244-
condition.type === WinCriteria.Survival) &&
245-
matchesPlayerList(condition.players, player.id),
246-
)
247-
.map((condition, index) => {
248-
const [icon, status, amount] =
249-
condition.type === WinCriteria.DefeatAmount
250-
? [
251-
Crosshair,
252-
player.stats.destroyedUnits,
253-
condition.amount,
254-
]
255-
: condition.type === WinCriteria.CaptureAmount
239+
<Stack gap>
240+
{winConditions
241+
.filter(
242+
(condition) =>
243+
!condition.hidden &&
244+
(winConditionHasAmounts(condition) ||
245+
condition.type === WinCriteria.Survival) &&
246+
matchesPlayerList(condition.players, player.id) &&
247+
!condition.completed?.has(player.id),
248+
)
249+
.map((condition, index) => {
250+
const [icon, status, amount] =
251+
condition.type === WinCriteria.DefeatAmount
256252
? [
257-
Flag,
258-
capturedByPlayer(map, player.id),
253+
Crosshair,
254+
player.stats.destroyedUnits,
259255
condition.amount,
260256
]
261-
: condition.type === WinCriteria.DestroyAmount
257+
: condition.type === WinCriteria.CaptureAmount
262258
? [
263-
Buildings,
264-
destroyedBuildingsByPlayer(map, player.id),
259+
Flag,
260+
capturedByPlayer(map, player.id),
265261
condition.amount,
266262
]
267-
: condition.type === WinCriteria.EscortAmount
263+
: condition.type === WinCriteria.DestroyAmount
268264
? [
269-
Escort,
270-
escortedByPlayer(
271-
map,
272-
player.id,
273-
condition.vectors,
274-
condition.label,
275-
),
265+
Buildings,
266+
destroyedBuildingsByPlayer(map, player.id),
276267
condition.amount,
277268
]
278-
: condition.type === WinCriteria.Survival
279-
? [Hourglass, map.round, condition.rounds]
280-
: [null, null];
281-
282-
return (
283-
(icon && status != null && (
284-
<Stack className={nowrapStyle} gap={2} key={index} nowrap>
285-
<div>
286-
<Icon className={winConditionIconStyle} icon={icon} />
287-
{status}
288-
</div>
289-
<div>/</div>
290-
<div>{amount}</div>
291-
</Stack>
292-
)) ||
293-
null
294-
);
295-
})}
269+
: condition.type === WinCriteria.EscortAmount
270+
? [
271+
Escort,
272+
escortedByPlayer(
273+
map,
274+
player.id,
275+
condition.vectors,
276+
condition.label,
277+
),
278+
condition.amount,
279+
]
280+
: condition.type === WinCriteria.Survival
281+
? [Hourglass, map.round, condition.rounds]
282+
: [null, null];
283+
284+
return (
285+
(icon && status != null && (
286+
<Stack
287+
className={nowrapStyle}
288+
gap={2}
289+
key={index}
290+
nowrap
291+
>
292+
<div>
293+
<Icon
294+
className={winConditionIconStyle}
295+
icon={icon}
296+
/>
297+
{status}
298+
</div>
299+
<div>/</div>
300+
<div>{amount}</div>
301+
</Stack>
302+
)) ||
303+
null
304+
);
305+
})}
306+
</Stack>
296307
</Stack>
297308
{wide && (
298-
<Stack className={offsetStyle} gap nowrap start>
299-
{(
300-
[
301-
[Reload, () => calculateFunds(map, player)],
309+
<Stack className={offsetStyle} gap={16} nowrap>
310+
<Stack className={cx(playerStatsStyle, nowrapStyle)}>
311+
<Icon className={playerStatsBeforeIconStyle} icon={Reload} />
312+
<span>
313+
{shouldShow ? calculateFunds(map, player) : '???'}
314+
</span>
315+
</Stack>
316+
<Stack gap>
317+
{(
302318
[
303-
HumanHandsdown,
304-
() =>
305-
map.units.filter((unit) =>
306-
map.matchesPlayer(unit, player),
307-
).size,
308-
],
309-
[
310-
Buildings,
311-
() =>
312-
map.buildings.filter((building) =>
313-
map.matchesPlayer(building, player),
314-
).size,
315-
],
316-
] as const
317-
).map(([icon, getValue], index) => (
318-
<Stack
319-
className={cx(playerStatsStyle, nowrapStyle)}
320-
key={index}
321-
>
322-
<Icon
323-
className={playerStatsBeforeIconStyle}
324-
icon={icon}
325-
key="icon"
326-
/>
327-
<span>{shouldShow ? getValue() : '???'}</span>
328-
</Stack>
329-
))}
319+
[
320+
HumanHandsdown,
321+
() =>
322+
map.units.filter((unit) =>
323+
map.matchesPlayer(unit, player),
324+
).size,
325+
],
326+
[
327+
Buildings,
328+
() =>
329+
map.buildings.filter((building) =>
330+
map.matchesPlayer(building, player),
331+
).size,
332+
],
333+
] as const
334+
).map(([icon, getValue], index) => (
335+
<Stack
336+
className={cx(playerStatsStyle, nowrapStyle)}
337+
key={index}
338+
>
339+
<Icon
340+
className={playerStatsBeforeIconStyle}
341+
icon={icon}
342+
key="icon"
343+
/>
344+
<span>{shouldShow ? getValue() : '???'}</span>
345+
</Stack>
346+
))}
347+
</Stack>
330348
</Stack>
331349
)}
332350
</Stack>
@@ -474,6 +492,7 @@ const skillStyle = css`
474492

475493
const fundStyle = css`
476494
margin-top: -1px;
495+
flex-shrink: 0;
477496
`;
478497

479498
const playerStatsStyle = css`

0 commit comments

Comments
 (0)