Merge branch 'develop'

This commit is contained in:
zkldi
2022-02-15 05:28:13 +00:00
8 changed files with 98 additions and 85 deletions
+19 -59
View File
@@ -2,59 +2,14 @@ import QuickTooltip from "components/layout/misc/QuickTooltip";
import Divider from "components/util/Divider";
import Muted from "components/util/Muted";
import useUGPTSettings from "components/util/useUGPTSettings";
import React from "react";
import { UserContext } from "context/UserContext";
import React, { useContext } from "react";
import { PoyashiBPI } from "rg-stats";
import { ChartDocument, integer, PBScoreDocument, ScoreDocument } from "tachi-common";
import { GetGradeFromPercent, IsNullish } from "util/misc";
import MiniTable from "../components/MiniTable";
import DeltaCell from "./DeltaCell";
import ScoreCell from "./ScoreCell";
// import { BPI_COLOURS } from "util/constants/colours";
// tried it - doesn't look good. - zkldi
// import colorInterpolate from "color-interpolate";
// const scale = colorInterpolate([
// BPI_COLOURS.ZERO,
// BPI_COLOURS.TEN,
// BPI_COLOURS.TWENTY,
// BPI_COLOURS.THIRTY,
// BPI_COLOURS.FOURTY,
// BPI_COLOURS.FIFTY,
// BPI_COLOURS.SIXTY,
// BPI_COLOURS.SEVENTY,
// BPI_COLOURS.EIGHTY,
// BPI_COLOURS.NINETY,
// BPI_COLOURS.MAX,
// ]);
// function GetColor(bpi: number) {
// if (bpi < 0) {
// return BPI_COLOURS.NEGATIVE;
// } else if (bpi < 10) {
// return BPI_COLOURS.ZERO;
// } else if (bpi < 20) {
// return BPI_COLOURS.TEN;
// } else if (bpi < 30) {
// return BPI_COLOURS.TWENTY;
// } else if (bpi < 40) {
// return BPI_COLOURS.THIRTY;
// } else if (bpi < 50) {
// return BPI_COLOURS.FOURTY;
// } else if (bpi < 60) {
// return BPI_COLOURS.FIFTY;
// } else if (bpi < 70) {
// return BPI_COLOURS.SIXTY;
// } else if (bpi < 80) {
// return BPI_COLOURS.SEVENTY;
// } else if (bpi < 90) {
// return BPI_COLOURS.EIGHTY;
// } else if (bpi < 100) {
// return BPI_COLOURS.NINETY;
// } else {
// return BPI_COLOURS.MAX;
// }
// }
export default function BPICell({
score,
@@ -63,6 +18,7 @@ export default function BPICell({
score: ScoreDocument<"iidx:SP" | "iidx:DP"> | PBScoreDocument<"iidx:SP" | "iidx:DP">;
chart: ChartDocument<"iidx:SP" | "iidx:DP">;
}) {
const { user } = useContext(UserContext);
const { settings } = useUGPTSettings<"iidx:SP" | "iidx:DP">();
const bpi = score.calculatedData.BPI;
@@ -72,6 +28,7 @@ export default function BPICell({
return <td>N/A</td>;
}
const isRequestingUser = user?.id === score.userID;
const bpiTarget = settings?.preferences.gameSpecific.bpiTarget ?? 0;
let bpiTargetScore = 0;
let targetDelta: number | null = 0;
@@ -92,7 +49,6 @@ export default function BPICell({
}
const kavgDelta = score.scoreData.score - kaidenAverage!;
const wrDelta = score.scoreData.score - worldRecord!;
const { score: WRAverageCell, delta: WRDeltaCell } = FormatAverage(
worldRecord!,
@@ -126,12 +82,12 @@ export default function BPICell({
]}
>
<tr>
{TGAverageCell}
{isRequestingUser ? TGAverageCell : null}
{KDAverageCell}
{WRAverageCell}
</tr>
<tr>
{TGDeltaCell}
{isRequestingUser ? TGDeltaCell : null}
{KDDeltaCell}
{WRDeltaCell}
</tr>
@@ -154,19 +110,23 @@ export default function BPICell({
<br />
<div>
<BPITargetCell bpiTarget={bpiTarget} targetDelta={targetDelta} />
{bpiTarget !== 0 && (
{isRequestingUser ? (
<>
<BPITargetCell bpiTarget={bpiTarget} targetDelta={targetDelta} />
{bpiTarget !== 0 && (
<>
<br />
<Muted>
皆伝{kavgDelta < 0 ? kavgDelta : `+${kavgDelta}`}
</Muted>
</>
)}
</>
) : (
<>
<br />
<Muted>皆伝{kavgDelta < 0 ? kavgDelta : `+${kavgDelta}`}</Muted>
</>
)}
{/* {bpiTarget !== 100 && (
<>
<br />
<Muted>WR{wrDelta < 0 ? wrDelta : `+${wrDelta}`}</Muted>
</>
)} */}
</div>
</td>
</QuickTooltip>
@@ -12,6 +12,7 @@ export default function JubeatJudgementCell({
return (
<td>
<strong>
<span style={{ color: COLOUR_SET.pink }}>0</span>-
<span style={{ color: COLOUR_SET.gold }}>0</span>-
<span style={{ color: COLOUR_SET.blue }}>0</span>-
<span style={{ color: COLOUR_SET.purple }}>0</span>-
@@ -21,18 +22,14 @@ export default function JubeatJudgementCell({
);
}
// safety
if (score.scoreData.lamp === "FULL COMBO") {
score.scoreData.judgements.miss = 0;
}
const judgements = score.scoreData.judgements;
if (
IsNullish(judgements.miss) ||
IsNullish(judgements.great) ||
IsNullish(judgements.good) ||
IsNullish(judgements.poor)
IsNullish(judgements.poor) ||
IsNullish(judgements.perfect)
) {
return <td>No Data.</td>;
}
@@ -40,6 +37,7 @@ export default function JubeatJudgementCell({
return (
<td>
<strong>
<span style={{ color: COLOUR_SET.pink }}>{judgements.perfect}</span>-
<span style={{ color: COLOUR_SET.gold }}>{judgements.great}</span>-
<span style={{ color: COLOUR_SET.blue }}>{judgements.good}</span>-
<span style={{ color: COLOUR_SET.purple }}>{judgements.poor}</span>-
@@ -19,11 +19,6 @@ export default function MusecaJudgementCell({
);
}
// safety
if (score.scoreData.lamp === "CONNECT ALL") {
score.scoreData.judgements.miss = 0;
}
const judgements = score.scoreData.judgements;
if (IsNullish(judgements.miss) || IsNullish(judgements.near)) {
@@ -9,13 +9,19 @@ export default function PopnJudgementCell({
}) {
const judgements = score.scoreData.judgements;
if (IsNullish(judgements.bad) || IsNullish(judgements.great) || IsNullish(judgements.good)) {
if (
IsNullish(judgements.bad) ||
IsNullish(judgements.great) ||
IsNullish(judgements.good) ||
IsNullish(judgements.cool)
) {
return <td>No Data.</td>;
}
return (
<td>
<strong>
<span style={{ color: COLOUR_SET.purple }}>{judgements.cool}</span>-
<span style={{ color: COLOUR_SET.gold }}>{judgements.great}</span>-
<span style={{ color: COLOUR_SET.red }}>{judgements.good}</span>-
<span style={{ color: COLOUR_SET.blue }}>{judgements.bad}</span>
@@ -19,11 +19,6 @@ export default function SDVXJudgementCell({
);
}
// safety
if (score.scoreData.lamp === "ULTIMATE CHAIN") {
score.scoreData.judgements.miss = 0;
}
const judgements = score.scoreData.judgements;
if (IsNullish(judgements.miss) || IsNullish(judgements.near)) {
@@ -1,5 +1,6 @@
import useUGPTSettings from "components/util/useUGPTSettings";
import React from "react";
import { UserContext } from "context/UserContext";
import React, { useContext } from "react";
import { Volforce } from "rg-stats";
import { ChartDocument, GetGamePTConfig, PBScoreDocument, ScoreDocument } from "tachi-common";
import { IsNullish } from "util/misc";
@@ -19,6 +20,7 @@ export default function VF6Cell({
score: ScoreDocument<VF6IDStrings> | PBScoreDocument<VF6IDStrings>;
chart: ChartDocument<VF6IDStrings>;
}) {
const { user } = useContext(UserContext);
const { settings } = useUGPTSettings<VF6IDStrings>();
if (IsNullish(score.calculatedData.VF6)) {
@@ -31,7 +33,7 @@ export default function VF6Cell({
const targets: Record<string, number | null> = {};
if (vf6Target) {
if (vf6Target && score.userID === user?.id) {
for (const lamp of ["CLEAR", "EXCESSIVE CLEAR", "ULTIMATE CHAIN"] as const) {
if (score.scoreData.lampIndex <= gptConfig.lamps.indexOf(lamp)) {
const expectedScore = InverseVF6(vf6Target, lamp, chart.levelNum);
@@ -12,6 +12,7 @@ export default function WaccaJudgementCell({
return (
<td>
<strong>
<span style={{ color: COLOUR_SET.vibrantPink }}>0</span>-
<span style={{ color: COLOUR_SET.gold }}>0</span>-
<span style={{ color: COLOUR_SET.blue }}>0</span>-
<span style={{ color: COLOUR_SET.red }}>0</span>
@@ -20,20 +21,21 @@ export default function WaccaJudgementCell({
);
}
// safety
if (score.scoreData.lamp === "FULL COMBO") {
score.scoreData.judgements.miss = 0;
}
const judgements = score.scoreData.judgements;
if (IsNullish(judgements.miss) || IsNullish(judgements.great) || IsNullish(judgements.good)) {
if (
IsNullish(judgements.miss) ||
IsNullish(judgements.great) ||
IsNullish(judgements.good) ||
IsNullish(judgements.marvelous)
) {
return <td>No Data.</td>;
}
return (
<td>
<strong>
<span style={{ color: COLOUR_SET.vibrantPink }}>{judgements.marvelous}</span>-
<span style={{ color: COLOUR_SET.gold }}>{judgements.great}</span>-
<span style={{ color: COLOUR_SET.blue }}>{judgements.good}</span>-
<span style={{ color: COLOUR_SET.red }}>{judgements.miss}</span>
@@ -97,7 +97,6 @@ export function GetGPTCoreHeaders<Dataset extends FolderDataset | PBDataset | Sc
case "jubeat":
case "wacca":
case "chunithm":
case "popn":
case "maimai":
return [
ScoreHeader,
@@ -109,5 +108,61 @@ export function GetGPTCoreHeaders<Dataset extends FolderDataset | PBDataset | Sc
LampHeader,
RatingHeader,
];
case "popn":
return [
ScoreHeader,
[
"Judgements",
"Hits",
NumericSOV(x => kMapToScoreOrPB(x)?.scoreData.percent ?? -Infinity),
],
[
"Lamp",
"Lamp",
(a, b) => {
const aSc = kMapToScoreOrPB(a) as
| ScoreDocument<"popn:9B">
| PBScoreDocument<"popn:9B">;
const bSc = kMapToScoreOrPB(b) as
| ScoreDocument<"popn:9B">
| PBScoreDocument<"popn:9B">;
if (!aSc || !bSc) {
return -Infinity;
}
if (aSc.scoreData.lampIndex === bSc.scoreData.lampIndex) {
if (
!aSc.scoreData.hitMeta.specificClearType ||
!bSc.scoreData.hitMeta.specificClearType
) {
return -Infinity;
}
return (
popnClearTypeToInt[aSc.scoreData.hitMeta.specificClearType] -
popnClearTypeToInt[bSc.scoreData.hitMeta.specificClearType]
);
}
return aSc.scoreData.lampIndex - bSc.scoreData.lampIndex;
},
],
RatingHeader,
];
}
}
const popnClearTypeToInt = {
failedCircle: 0,
failedDiamond: 1,
failedStar: 2,
easyClear: 3,
clearCircle: 4,
clearDiamond: 5,
clearStar: 6,
fullComboCircle: 7,
fullComboDiamond: 8,
fullComboStar: 9,
perfect: 10,
} as const;