Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live release 5 feb 2024 #194

Merged
merged 8 commits into from
Feb 5, 2024
2 changes: 1 addition & 1 deletion src/components/CupResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CupResults = props => {
>
{results.map((r, no) => (
<ListRow key={r.KuskiIndex}>
<ListCell>{no + 1}.</ListCell>
<ListCell>{r.Position ? r.Position : no + 1}.</ListCell>
<ListCell>
{cup.TeamPoints ? (
<Kuski
Expand Down
6 changes: 4 additions & 2 deletions src/features/LevelList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ export default function LevelList({
</FormControl>
<KuskiFilter>
<KuskiAutoComplete
disabled={finished === 'all'}
list={kuskiOptions}
value={finishedBy}
selected={finishedBy}
onChange={newValue => {
if (finished === 'all') {
setFinished(true);
}
setFinishedBy(newValue);
updatePage(0);
}}
Expand Down
66 changes: 30 additions & 36 deletions src/features/LevelMap/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ const LevelMap = ({
{rating && <RatingContainer>{rating}</RatingContainer>}
</MapContainer>
)}
<svg>
<clipPath id="up__clip-path" clipPathUnits="objectBoundingBox">
<polygon
transform="scale(.01)"
points="50 0, 100 40, 70 40, 70 100, 30 100,30 40, 0 40"
/>
</clipPath>
<clipPath id="left__clip-path" clipPathUnits="objectBoundingBox">
<polygon
transform="scale(.01)"
points="40 0, 40 30, 100 30, 100 70, 40 70, 40 100, 0 50"
/>
</clipPath>
<clipPath id="down__clip-path" clipPathUnits="objectBoundingBox">
<polygon
transform="scale(.01)"
points="50 100, 100 60, 70 60, 70 0, 30 0, 30 60, 0 60"
/>
</clipPath>
<clipPath id="right__clip-path" clipPathUnits="objectBoundingBox">
<polygon
transform="scale(.01)"
points="0 30, 60 30, 60 0, 100 50, 60 100, 60 70, 0 70"
/>
</clipPath>
</svg>
</>
);
};
Expand Down Expand Up @@ -123,51 +149,19 @@ const MapContainer = styled.div`
props.showGravityApples &&
`
svg .GRAV_UP {
clip-path: polygon(
50% 0,
100% 40%,
70% 40%,
70% 100%,
30% 100%,
30% 40%,
0 40%
);
clip-path: url("#up__clip-path")
}

svg .GRAV_LEFT {
clip-path: polygon(
40% 0%,
40% 30%,
100% 30%,
100% 70%,
40% 70%,
40% 100%,
0% 50%
);
clip-path: url("#left__clip-path")
}

svg .GRAV_RIGHT {
clip-path: polygon(
0% 30%,
60% 30%,
60% 0%,
100% 50%,
60% 100%,
60% 70%,
0% 70%
);
clip-path: url("#right__clip-path")
}

svg .GRAV_DOWN {
clip-path: polygon(
50% 100%,
100% 60%,
70% 60%,
70% 0,
30% 0,
30% 60%,
0 60%
);
clip-path: url("#down__clip-path")
}`}

svg {
Expand Down
6 changes: 5 additions & 1 deletion src/pages/cup/EventStandings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const EventStandings = ({ events, cup }) => {
{standings.player.map((r, no) => (
<ListRow key={r.KuskiIndex}>
<ListCell width={70}>
<Position r={r} no={no} amountEvents={events.length} />
<Position
r={r}
no={r.FinalPosition ? r.FinalPosition - 1 : no}
amountEvents={events.length}
/>
</ListCell>
<ListCell>
<Kuski kuskiData={r.KuskiData} team flag />
Expand Down
6 changes: 5 additions & 1 deletion src/pages/cup/Standings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ const Standings = props => {
{standings.player.map((r, no) => (
<ListRow key={r.KuskiIndex}>
<ListCell width={70}>
<Position r={r} no={no} amountEvents={events.length} />
<Position
r={r}
no={r.FinalPosition ? r.FinalPosition - 1 : no}
amountEvents={events.length}
/>
</ListCell>
<ListCell>
<Kuski kuskiData={r.KuskiData} team flag />
Expand Down
10 changes: 2 additions & 8 deletions src/pages/level/StatsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@ const StatsTable = ({ data, loading }) => {
};

const lastPlayed = () => {
return maxBy(
data.filter(f => f.Finished !== 'S'),
'LastPlayed',
).LastPlayed;
return maxBy(data, 'LastPlayed').LastPlayed;
};

const firstPlayed = () => {
return minBy(
data.filter(f => f.Finished !== 'S'),
'FirstPlayed',
).FirstPlayed;
return minBy(data, 'FirstPlayed').FirstPlayed;
};

return (
Expand Down
31 changes: 18 additions & 13 deletions src/pages/replay/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { MergeContainer } from 'components/RecListItem';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { Row, Column } from 'components/Containers';
import { pts } from 'utils/cups';
import { mod } from 'utils/nick';

const getLink = replay => {
let link = '';
Expand Down Expand Up @@ -299,29 +300,33 @@ const Replay = ({ ReplayUuid, RecFileName }) => {
/>
</AccordionDetails>
</Accordion>
{userid === `${replay.UploadedBy}` && type === 'replay' && (
{(userid === `${replay.UploadedBy}` || mod() === 1) && type === 'replay' && (
<Accordion>
<AccordionSummary expandIcon={<ExpandMore />}>
<Header h3>Edit replay</Header>
</AccordionSummary>
<AccordionDetails style={{ flexDirection: 'column' }}>
<TextField
name="Comment"
value={edit.Comment}
onChange={value => setEdit({ field: 'Comment', value })}
/>
{userid === `${replay.UploadedBy}` && (
<TextField
name="Comment"
value={edit.Comment}
onChange={value => setEdit({ field: 'Comment', value })}
/>
)}
<TextField
name="Driven by"
value={edit.DrivenBy}
onChange={value => setEdit({ field: 'DrivenBy', value })}
/>
<FieldBoolean
label="Unlisted"
value={edit.Unlisted}
onChange={() =>
setEdit({ field: 'Unlisted', value: 1 - edit.Unlisted })
}
/>
{userid === `${replay.UploadedBy}` && (
<FieldBoolean
label="Unlisted"
value={edit.Unlisted}
onChange={() =>
setEdit({ field: 'Unlisted', value: 1 - edit.Unlisted })
}
/>
)}
<Box padding={2}>
<Typography color="textSecondary">Tags</Typography>
{tagOptions.map(option => {
Expand Down
56 changes: 43 additions & 13 deletions src/utils/cups.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ const calcSkipStandings = (
cup,
eventIndex,
) => {
let lastPoints = 0;
let drawPos = 0;
return standings
.map(s => {
const totalEvents = forceSkip ? finishedEvents : cup.Events;
Expand All @@ -184,23 +186,51 @@ const calcSkipStandings = (
return { ...s, AllPoints, Points, AllPointsDetailed };
})
.sort((a, b) => b.Points - a.Points)
.map((s, i) => ({
...s,
Position: s.Position
? { ...s.Position, [`${eventIndex + 1}`]: i + 1 }
: { [`${eventIndex + 1}`]: i + 1 },
}));
.map((s, i) => {
let position = i + 1;
if (lastPoints === s.Points) {
if (!drawPos) {
drawPos = i;
}
position = drawPos;
} else if (drawPos) {
drawPos = 0;
}
lastPoints = s.Points;
return {
...s,
Position: s.Position
? { ...s.Position, [`${eventIndex + 1}`]: position }
: { [`${eventIndex + 1}`]: position },
FinalPosition: position,
};
});
};

const calcStandings = (standings, eventIndex) => {
let lastPoints = 0;
let drawPos = 0;
return standings
.sort((a, b) => b.Points - a.Points)
.map((s, i) => ({
...s,
Position: s.Position
? { ...s.Position, [`${eventIndex + 1}`]: i + 1 }
: { [`${eventIndex + 1}`]: i + 1 },
}));
.map((s, i) => {
let position = i + 1;
if (lastPoints === s.Points) {
if (!drawPos) {
drawPos = i;
}
position = drawPos;
} else if (drawPos) {
drawPos = 0;
}
lastPoints = s.Points;
return {
...s,
Position: s.Position
? { ...s.Position, [`${eventIndex + 1}`]: position }
: { [`${eventIndex + 1}`]: position },
FinalPosition: position,
};
});
};

export const calculateStandings = (events, cup, simple, forceSkip = false) => {
Expand Down Expand Up @@ -232,7 +262,7 @@ export const calculateStandings = (events, cup, simple, forceSkip = false) => {
const pointsDetailed = {
Points: time.Points,
LevelIndex: event.LevelIndex,
Position: index + 1,
Position: time.Position ? time.Position : index + 1,
TotalPlayers: event.CupTimes.length,
Skipped: false,
Event: eventIndex + 1,
Expand Down
Loading