diff options
Diffstat (limited to 'frontend/app/components/Gaming')
| -rw-r--r-- | frontend/app/components/Gaming/CodePopover.tsx | 8 | ||||
| -rw-r--r-- | frontend/app/components/Gaming/ProblemColumn.tsx | 9 | ||||
| -rw-r--r-- | frontend/app/components/Gaming/ProblemColumnContent.tsx | 97 | ||||
| -rw-r--r-- | frontend/app/components/Gaming/RankingTable.tsx | 11 |
4 files changed, 87 insertions, 38 deletions
diff --git a/frontend/app/components/Gaming/CodePopover.tsx b/frontend/app/components/Gaming/CodePopover.tsx index a574a77..91245df 100644 --- a/frontend/app/components/Gaming/CodePopover.tsx +++ b/frontend/app/components/Gaming/CodePopover.tsx @@ -2,15 +2,17 @@ import { Popover } from "@base-ui-components/react/popover"; import { faCode, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { calcCodeSize } from "../../states/play"; +import type { SupportedLanguage } from "../../types/SupportedLanguage"; import BorderedContainer from "../BorderedContainer"; import CodeBlock from "../Gaming/CodeBlock"; type Props = { code: string; + language: SupportedLanguage; }; -export default function CodePopover({ code }: Props) { - const codeSize = calcCodeSize(code); +export default function CodePopover({ code, language }: Props) { + const codeSize = calcCodeSize(code, language); return ( <Popover.Root> @@ -33,7 +35,7 @@ export default function CodePopover({ code }: Props) { /> </Popover.Close> </div> - <CodeBlock code={code} language="php" /> + <CodeBlock code={code} language={language} /> </BorderedContainer> </Popover.Popup> </Popover.Positioner> diff --git a/frontend/app/components/Gaming/ProblemColumn.tsx b/frontend/app/components/Gaming/ProblemColumn.tsx index 3b7e58c..a355ac4 100644 --- a/frontend/app/components/Gaming/ProblemColumn.tsx +++ b/frontend/app/components/Gaming/ProblemColumn.tsx @@ -1,20 +1,27 @@ +import type { SupportedLanguage } from "../../types/SupportedLanguage"; import TitledColumn from "../TitledColumn"; import ProblemColumnContent from "./ProblemColumnContent"; type Props = { title: string; description: string; + language: SupportedLanguage; sampleCode: string; }; export default function ProblemColumn({ title, description, + language, sampleCode, }: Props) { return ( <TitledColumn title={title}> - <ProblemColumnContent description={description} sampleCode={sampleCode} /> + <ProblemColumnContent + description={description} + sampleCode={sampleCode} + language={language} + /> </TitledColumn> ); } diff --git a/frontend/app/components/Gaming/ProblemColumnContent.tsx b/frontend/app/components/Gaming/ProblemColumnContent.tsx index b85cc6d..0904a98 100644 --- a/frontend/app/components/Gaming/ProblemColumnContent.tsx +++ b/frontend/app/components/Gaming/ProblemColumnContent.tsx @@ -1,14 +1,77 @@ +import type { SupportedLanguage } from "../../types/SupportedLanguage"; import FoldableBorderedContainerWithCaption from "../FoldableBorderedContainerWithCaption"; import CodeBlock from "./CodeBlock"; import InlineCode from "./InlineCode"; +function PhpNotice() { + return ( + <FoldableBorderedContainerWithCaption caption="スコア計算・PHP 環境"> + <div className="text-gray-700 flex flex-col gap-2"> + <p> + スコアはコード中の全 ASCII + 空白文字を除去した後のバイト数です。また、先頭や末尾に置かれた PHP + タグ (<InlineCode code="<?php" />、<InlineCode code="<?" />、 + <InlineCode code="?>" />) はカウントされません。 + </p> + <p> + 同じスコアを出した場合、より提出が早かったプレイヤーの勝ちとなります。 + </p> + <p> + この環境の PHP バージョンは{" "} + <strong className="font-bold">8.4.4</strong> です。 mbstring + を除くほとんどの拡張は無効化されています。 + また、ファイルやネットワークアクセスはできません。 + </p> + <p> + テストの成否は、標準出力へ出力された文字列を比較して判定されます。 + 末尾の改行はあってもなくても構いません。 + 標準エラー出力の内容は無視されますが、fatal error + 等で実行が中断された場合は失敗扱いとなります。 + </p> + <p> + なお、 + <InlineCode code="error_reporting" /> は{" "} + <InlineCode code="E_ALL & ~E_WARNING & ~E_NOTICE & ~E_DEPRECATED" />{" "} + に設定されています。 + </p> + </div> + </FoldableBorderedContainerWithCaption> + ); +} + +function SwiftNotice() { + return ( + <FoldableBorderedContainerWithCaption caption="スコア計算・Swift 環境"> + <div className="text-gray-700 flex flex-col gap-2"> + <p>スコアはコード中の全 ASCII 空白文字を除去した後のバイト数です。</p> + <p> + 同じスコアを出した場合、より提出が早かったプレイヤーの勝ちとなります。 + </p> + <p> + この環境の PHP バージョンは{" "} + <strong className="font-bold">6.1.2</strong> です。 + ファイルアクセスやネットワークアクセスはできません。 + </p> + <p> + テストの成否は、標準出力へ出力された文字列を比較して判定されます。 + 末尾の改行はあってもなくても構いません。 + 標準エラー出力の内容は無視されますが、fatal error + 等で実行が中断された場合は失敗扱いとなります。 + </p> + </div> + </FoldableBorderedContainerWithCaption> + ); +} + type Props = { description: string; + language: SupportedLanguage; sampleCode: string; }; export default function ProblemColumnContent({ description, + language, sampleCode, }: Props) { return ( @@ -19,39 +82,9 @@ export default function ProblemColumnContent({ </pre> </FoldableBorderedContainerWithCaption> <FoldableBorderedContainerWithCaption caption="サンプルコード"> - <CodeBlock code={sampleCode} language="php" /> - </FoldableBorderedContainerWithCaption> - <FoldableBorderedContainerWithCaption caption="スコア計算・PHP 環境"> - <div className="text-gray-700 flex flex-col gap-2"> - <p> - スコアはコード中の全 ASCII - 空白文字を除去した後のバイト数です。また、先頭や末尾に置かれた PHP - タグ (<InlineCode code="<?php" />、<InlineCode code="<?" />、 - <InlineCode code="?>" />) はカウントされません。 - </p> - <p> - 同じスコアを出した場合、より提出が早かったプレイヤーの勝ちとなります。 - </p> - <p> - この環境の PHP バージョンは{" "} - <strong className="font-bold">8.4.4</strong> です。 mbstring - を除くほとんどの拡張は無効化されています。 - また、ファイルやネットワークアクセスはできません。 - </p> - <p> - テストの成否は、標準出力へ出力された文字列を比較して判定されます。 - 末尾の改行はあってもなくても構いません。 - 標準エラー出力の内容は無視されますが、fatal error - 等で実行が中断された場合は失敗扱いとなります。 - </p> - <p> - なお、 - <InlineCode code="error_reporting" /> は{" "} - <InlineCode code="E_ALL & ~E_WARNING & ~E_NOTICE & ~E_DEPRECATED" />{" "} - に設定されています。 - </p> - </div> + <CodeBlock code={sampleCode} language={language} /> </FoldableBorderedContainerWithCaption> + {language === "php" ? <PhpNotice /> : <SwiftNotice />} </> ); } diff --git a/frontend/app/components/Gaming/RankingTable.tsx b/frontend/app/components/Gaming/RankingTable.tsx index 3368f60..7359d40 100644 --- a/frontend/app/components/Gaming/RankingTable.tsx +++ b/frontend/app/components/Gaming/RankingTable.tsx @@ -1,6 +1,7 @@ import { useAtomValue } from "jotai"; import React from "react"; import { rankingAtom } from "../../states/watch"; +import type { SupportedLanguage } from "../../types/SupportedLanguage"; import CodePopover from "./CodePopover"; function TableHeaderCell({ children }: { children: React.ReactNode }) { @@ -29,7 +30,11 @@ function formatUnixTimestamp(timestamp: number) { return `${year}-${month}-${day} ${hours}:${minutes}`; } -export default function RankingTable() { +type Props = { + problemLanguage: SupportedLanguage; +}; + +export default function RankingTable({ problemLanguage }: Props) { const ranking = useAtomValue(rankingAtom); return ( @@ -57,7 +62,9 @@ export default function RankingTable() { {formatUnixTimestamp(entry.submitted_at)} </TableBodyCell> <TableBodyCell> - {entry.code && <CodePopover code={entry.code} />} + {entry.code && ( + <CodePopover code={entry.code} language={problemLanguage} /> + )} </TableBodyCell> </tr> ))} |
