aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/routes/golf/play/apps
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/routes/golf/play/apps')
-rw-r--r--frontend/src/routes/golf/play/apps/Connecting.tsx12
-rw-r--r--frontend/src/routes/golf/play/apps/Failed.tsx12
-rw-r--r--frontend/src/routes/golf/play/apps/Finished.tsx30
-rw-r--r--frontend/src/routes/golf/play/apps/Gaming.tsx34
-rw-r--r--frontend/src/routes/golf/play/apps/Starting.tsx15
-rw-r--r--frontend/src/routes/golf/play/apps/Waiting.tsx12
6 files changed, 115 insertions, 0 deletions
diff --git a/frontend/src/routes/golf/play/apps/Connecting.tsx b/frontend/src/routes/golf/play/apps/Connecting.tsx
new file mode 100644
index 0000000..594a291
--- /dev/null
+++ b/frontend/src/routes/golf/play/apps/Connecting.tsx
@@ -0,0 +1,12 @@
+type Props = {
+ gameId: number;
+ playerId: number;
+};
+
+export default (_props: Props) => {
+ return (
+ <div>
+ 接続中です......
+ </div>
+ );
+}
diff --git a/frontend/src/routes/golf/play/apps/Failed.tsx b/frontend/src/routes/golf/play/apps/Failed.tsx
new file mode 100644
index 0000000..6ea56e6
--- /dev/null
+++ b/frontend/src/routes/golf/play/apps/Failed.tsx
@@ -0,0 +1,12 @@
+type Props = {
+ gameId: number;
+ playerId: number;
+};
+
+export default (_props: Props) => {
+ return (
+ <div>
+ エラー
+ </div>
+ );
+}
diff --git a/frontend/src/routes/golf/play/apps/Finished.tsx b/frontend/src/routes/golf/play/apps/Finished.tsx
new file mode 100644
index 0000000..9922e07
--- /dev/null
+++ b/frontend/src/routes/golf/play/apps/Finished.tsx
@@ -0,0 +1,30 @@
+type Props = {
+ gameId: number;
+ playerId: number;
+ result: { yourScore: number | null, opponentScore: number | null };
+};
+
+export default ({ result }: Props) => {
+ const { yourScore, opponentScore } = result;
+ const yourScoreToCompare = yourScore ?? Infinity;
+ const opponentScoreToCompare = opponentScore ?? Infinity;
+ const resultText = yourScoreToCompare === opponentScoreToCompare ? '引き分け' : (yourScoreToCompare < opponentScoreToCompare ? 'あなたの勝ち' : 'あなたの負け');
+ return (
+ <>
+ <div>
+ 対戦終了
+ </div>
+ <div>
+ <div>
+ {resultText}
+ </div>
+ <div>
+ あなたのスコア: {yourScore ?? 'なし'}
+ </div>
+ <div>
+ 相手のスコア: {opponentScore ?? 'なし'}
+ </div>
+ </div>
+ </>
+ );
+}
diff --git a/frontend/src/routes/golf/play/apps/Gaming.tsx b/frontend/src/routes/golf/play/apps/Gaming.tsx
new file mode 100644
index 0000000..27488e3
--- /dev/null
+++ b/frontend/src/routes/golf/play/apps/Gaming.tsx
@@ -0,0 +1,34 @@
+import React from 'react';
+
+type Props = {
+ gameId: number;
+ playerId: number;
+ problem: string | null;
+ onCodeChange: (data: { code: string }) => void;
+ score: number | null;
+};
+
+export default ({ problem, onCodeChange, score }: Props) => {
+ const handleTextChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
+ onCodeChange({ code: e.target.value });
+ };
+
+ return (
+ <div style={{ display: 'flex' }}>
+ <div style={{ flex: 1, padding: '10px', borderRight: '1px solid #ccc' }}>
+ <div>
+ {problem}
+ </div>
+ <div>
+ {score == null ? 'Score: -' : `Score: ${score} byte`}
+ </div>
+ </div>
+ <div style={{ flex: 1, padding: '10px' }}>
+ <textarea
+ style={{ width: '100%', height: '100%' }}
+ onChange={handleTextChange}
+ />
+ </div>
+ </div>
+ );
+};
diff --git a/frontend/src/routes/golf/play/apps/Starting.tsx b/frontend/src/routes/golf/play/apps/Starting.tsx
new file mode 100644
index 0000000..1c8fadd
--- /dev/null
+++ b/frontend/src/routes/golf/play/apps/Starting.tsx
@@ -0,0 +1,15 @@
+type Props = {
+ gameId: number;
+ playerId: number;
+ timeLeft: number | null;
+};
+
+export default ({ timeLeft }: Props) => {
+ return (
+ <>
+ <div>
+ 対戦相手が見つかりました。{timeLeft} 秒後にゲームを開始します。
+ </div>
+ </>
+ );
+}
diff --git a/frontend/src/routes/golf/play/apps/Waiting.tsx b/frontend/src/routes/golf/play/apps/Waiting.tsx
new file mode 100644
index 0000000..8112c22
--- /dev/null
+++ b/frontend/src/routes/golf/play/apps/Waiting.tsx
@@ -0,0 +1,12 @@
+type Props = {
+ gameId: number;
+ playerId: number;
+};
+
+export default (_props: Props) => {
+ return (
+ <div>
+ 対戦相手が現れるのを待っています......
+ </div>
+ );
+}