diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 868ede3..96b3af9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,40 +7,39 @@ on: branches: ['main', 'develop'] jobs: - eslint: - name: Run eslint scanning - runs-on: ubuntu-latest + eslint: + name: Run eslint scanning + runs-on: ubuntu-latest steps: - - name: Checkout code #コードを持ってくる + - name: Checkout code #コードを持ってくる uses: actions/checkout@v3 - - name: Install ESLint #ESlintをインストールする + - name: Install ESLint #ESlintをインストールする run: | npm install eslint@8.47.0 npm install @microsoft/eslint-formatter-sarif@2.1.7 - - name: Run ESLint #ESLintを実行する - run: - npx eslint ./src --ext .js,.jsx,.ts,.tsx --format @microsoft/eslint-formatter-sarif - --output-file eslint-results.sarif + - name: Run ESLint #ESLintを実行する + run: npx eslint ./src --ext .js,.jsx,.ts,.tsx --format @microsoft/eslint-formatter-sarif + --output-file eslint-results.sarif continue-on-error: true - - name: Upload analysis results to GitHub #githubに解析結果をアップロード + - name: Upload analysis results to GitHub #githubに解析結果をアップロード uses: github/codeql-action/upload-sarif@v2 with: sarif_file: eslint-results.sarif wait-for-processing: true rome: - name: Run rome scanning + name: Run rome scanning runs-on: ubuntu-latest steps: - - name: Checkout code #コードを持ってくる + - name: Checkout code #コードを持ってくる uses: actions/checkout@v3 - - name: Install Rome #romeをインストールする + - name: Install Rome #romeをインストールする run: | npm install rome@12.0.0 - - name: Run Rome #romeを実行 - run: npx rome check ./src \ No newline at end of file + - name: Run Rome #romeを実行 + run: npx rome check ./src diff --git a/doc/battle.md b/doc/battle.md new file mode 100644 index 0000000..aba7d56 --- /dev/null +++ b/doc/battle.md @@ -0,0 +1,5 @@ +バトルする +勝つ +ツイートできるようにする +負ける +励ましの言葉をヤギにかける \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c0e76b0..7dceef5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.11.16", "@mui/material": "^5.13.6", + "@swc/core": "^1.3.76", "axios": "^1.4.0", "dayjs": "^1.11.8", "firebase": "^9.23.0", @@ -1509,10 +1510,9 @@ ] }, "node_modules/@swc/core": { - "version": "1.3.66", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.66.tgz", - "integrity": "sha512-Hpf91kH5ly7fHkWnApwryTQryT+TO4kMMPH3WyciUSQOWLE3UuQz1PtETHQQk7PZ/b1QF0qQurJrgfBr5bSKUA==", - "dev": true, + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.76.tgz", + "integrity": "sha512-aYYTA2aVYkwJAZepQXtPnkUthhOfn8qd6rsh+lrJxonFrjmpI7RHt2tMDVTXP6XDX7fvnvrVtT1bwZfmBFPh0Q==", "hasInstallScript": true, "engines": { "node": ">=10" @@ -1522,16 +1522,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.66", - "@swc/core-darwin-x64": "1.3.66", - "@swc/core-linux-arm-gnueabihf": "1.3.66", - "@swc/core-linux-arm64-gnu": "1.3.66", - "@swc/core-linux-arm64-musl": "1.3.66", - "@swc/core-linux-x64-gnu": "1.3.66", - "@swc/core-linux-x64-musl": "1.3.66", - "@swc/core-win32-arm64-msvc": "1.3.66", - "@swc/core-win32-ia32-msvc": "1.3.66", - "@swc/core-win32-x64-msvc": "1.3.66" + "@swc/core-darwin-arm64": "1.3.76", + "@swc/core-darwin-x64": "1.3.76", + "@swc/core-linux-arm-gnueabihf": "1.3.76", + "@swc/core-linux-arm64-gnu": "1.3.76", + "@swc/core-linux-arm64-musl": "1.3.76", + "@swc/core-linux-x64-gnu": "1.3.76", + "@swc/core-linux-x64-musl": "1.3.76", + "@swc/core-win32-arm64-msvc": "1.3.76", + "@swc/core-win32-ia32-msvc": "1.3.76", + "@swc/core-win32-x64-msvc": "1.3.76" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -1543,13 +1543,12 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.3.66", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.66.tgz", - "integrity": "sha512-UijJsvuLy73vxeVYEy7urIHksXS+3BdvJ9s9AY+bRMSQW483NO7RLp8g4FdTyJbRaN0BH15SQnY0dcjQBkVuHw==", + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.76.tgz", + "integrity": "sha512-ovviEhZ/1E81Z9OGrO0ivLWk4VCa3I3ZzM+cd3gugglRRwVwtlIaoIYqY5S3KiCAupDd1+UCl5X7Vbio7a/V8g==", "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "darwin" @@ -1558,6 +1557,141 @@ "node": ">=10" } }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.76.tgz", + "integrity": "sha512-tcySTDqs0SHCebtW35sCdcLWsmTEo7bEwx0gNL/spetqVT9fpFi6qU8qcnt7i2KaZHbeNl9g1aadu+Yrni+GzA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.76.tgz", + "integrity": "sha512-apgzpGWy1AwoMF4urAAASsAjE7rEzZFIF+p6utuxhS7cNHzE0AyEVDYJbo+pzBdlZ8orBdzzsHtFwoEgKOjebA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.76.tgz", + "integrity": "sha512-c3c0zz6S0eludqidDpuqbadE0WT3OZczyQxe9Vw8lFFXES85mvNGtwYzyGK2o7TICpsuHrndwDIoYpmpWk879g==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.76.tgz", + "integrity": "sha512-Is3bpq7F2qtlnkzEeOD6HIZJPpOmu3q6c82lKww90Q0NnrlSluVMozTHJgwVoFZyizH7uLnk0LuNcEAWLnmJIw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.76.tgz", + "integrity": "sha512-iwCeRzd9oSvUzqt7nU6p/ztceAWfnO9XVxBn502R5gs6QCBbE1HCKrWHDO77aKPK7ss+0NcIGHvXTd9L8/wRzw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.76.tgz", + "integrity": "sha512-a671g4tW8kyFeuICsgq4uB9ukQfiIyXJT4V6YSnmqhCTz5mazWuDxZ5wKnx/1g5nXTl+U5cWH2TZaCJatp4GKA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.76.tgz", + "integrity": "sha512-+swEFtjdMezS0vKUhJC3psdSDtOJGY5pEOt4e8XOPvn7aQpKQ9LfF49XVtIwDSk5SGuWtVoLFzkSY3reWUJCyg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.76.tgz", + "integrity": "sha512-5CqwAykpGBJ3PqGLOlWGLGIPpBAG1IwWVDUfro3hhjQ7XJxV5Z1aQf5V5OJ90HJVtrEAVx2xx59UV/Dh081LOg==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.76.tgz", + "integrity": "sha512-CiMpWLLlR3Cew9067E7XxaLBwYYJ90r9EhGSO6V1pvYSWj7ET/Ppmtj1ZhzPJMqRXAP6xflfl5R5o4ee1m4WLA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@types/json-schema": { "version": "7.0.12", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", diff --git a/package.json b/package.json index 63cf384..ac0bb88 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.11.16", "@mui/material": "^5.13.6", + "@swc/core": "^1.3.76", "axios": "^1.4.0", "dayjs": "^1.11.8", "firebase": "^9.23.0", diff --git a/src/components/Battle.tsx b/src/components/Battle.tsx new file mode 100644 index 0000000..cee9f71 --- /dev/null +++ b/src/components/Battle.tsx @@ -0,0 +1,115 @@ +import { FC, useState, useEffect } from 'react'; +import Backdrop from '@mui/material/Backdrop'; +import Modal from '@mui/material/Modal'; +import Fade from '@mui/material/Fade'; +import Typography from '@mui/material/Typography'; +import backgroundImage from '../assets/tutorial.png'; +import { Button, Stack } from '@mui/material'; +import { EATLIMIT } from '../const/eatLimit'; + +const style = { + position: 'absolute' as const, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 300, + color: '#000', + + backgroundImage: `url(${backgroundImage})`, + backgroundSize: 'cover', + backgroundRepeat: 'no-repeat', + backgroundPosition: 'center', + border: '1.5px solid #FFF', + borderRadius: '10px', + boxShadow: 24, + p: 4, + outline: 'none', +}; + +type Props = { + eatCount: number; + monster: number; + open: boolean; + openclick: React.MouseEventHandler | undefined; + closeclick: React.MouseEventHandler | undefined; +}; + +const Battle: FC = ({ open, monster, openclick, closeclick, eatCount }) => { + const [monsterlabel1, setmonsterlabel1] = useState(''); + const [monsterlabel2, setmonsterlabel2] = useState(''); + const labelList = [ + 'このモンスターは', + monsterlabel1, + 'よわいようだ!', + 'ことばをたべさせて', + monsterlabel2, + 'やぎをそだてよう', + ]; + + useEffect(() => { + switch (monster) { + case 1: + setmonsterlabel1('よろこびのかんじょうに'); + setmonsterlabel2('やぎをよろこびのかんじょうに'); + break; + case 2: + setmonsterlabel1('いかりのかんじょうに'); + setmonsterlabel2('やぎをいかりのかんじょうに'); + break; + case 3: + setmonsterlabel1('かなしいのかんじょうに'); + setmonsterlabel2('やぎをかなしいのかんじょうに'); + break; + case 4: + setmonsterlabel1('たのしいのかんじょうに'); + setmonsterlabel2('やぎをたのしいかんじょうに'); + break; + } + }, []); + + return ( +
+ {eatCount > EATLIMIT ? null : ( + + + + + モンスターがあらわれた!! + + + {labelList.map((label) => ( + + {label} + + ))} + + + + + + + + )} +
+ ); +}; +export default Battle; diff --git a/src/components/Battleaction.tsx b/src/components/Battleaction.tsx new file mode 100644 index 0000000..008458a --- /dev/null +++ b/src/components/Battleaction.tsx @@ -0,0 +1,131 @@ +import { FC, useState, useEffect } from 'react'; +import Backdrop from '@mui/material/Backdrop'; +import Modal from '@mui/material/Modal'; +import Fade from '@mui/material/Fade'; +import Typography from '@mui/material/Typography'; +import backgroundImage from '../assets/tutorial.png'; +import { Button, Stack } from '@mui/material'; +import { EATLIMIT } from '../const/eatLimit'; +import { EmotionDataType } from '../types/EmotionDataType'; + +import yagi_yorokobi from '../assets/yagi_yorokobi.png'; +import yagi_ikari from '../assets/yagi_iakri.png'; +import yagi_kanasimi from '../assets/yagi_kanasimi.png'; +import yagi_tanosii from '../assets/yagi_tanosii.png'; +import yagi_yorokobi_right from '../assets/yagi_yorokobi_right.png'; +import yagi_ikari_right from '../assets/yagi_iakri_right.png'; +import yagi_kanasimi_right from '../assets/yagi_kanasimi_right.png'; +import yagi_tanosii_right from '../assets/yagi_tanosii_right.png'; + +const style = { + position: 'absolute' as const, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 300, + color: '#000', + + backgroundImage: `url(${backgroundImage})`, + backgroundSize: 'cover', + backgroundRepeat: 'no-repeat', + backgroundPosition: 'center', + border: '1.5px solid #FFF', + borderRadius: '10px', + boxShadow: 24, + p: 4, + outline: 'none', +}; + +type Props = { + monster: number; + eatCount: number; + open: boolean; + emotionData: EmotionDataType; + openclick: React.MouseEventHandler | undefined; + closeclick: React.MouseEventHandler | undefined; +}; + +const Battleresult: FC = (Props) => { + const [monsterimg, setmonsterimg] = useState(''); + const [yagiimg, setyagiimg] = useState(''); + const emoId = Props.emotionData.emoId; + useEffect(() => { + switch (Props.monster) { + case 1: + setmonsterimg(yagi_yorokobi_right); + break; + case 2: + setmonsterimg(yagi_ikari_right); + break; + case 3: + setmonsterimg(yagi_kanasimi_right); + break; + case 4: + setmonsterimg(yagi_tanosii_right); + break; + } + + switch (emoId) { + case 1: + setyagiimg(yagi_yorokobi); + break; + case 2: + setyagiimg(yagi_ikari); + break; + case 3: + setyagiimg(yagi_kanasimi); + break; + case 4: + setyagiimg(yagi_tanosii); + break; + } + }, []); + return ( +
+ {Props.eatCount > EATLIMIT ? ( + + + + + {/* + */} + + + + + ) : null} +
+ ); +}; +export default Battleresult; diff --git a/src/components/Battleresult.tsx b/src/components/Battleresult.tsx new file mode 100644 index 0000000..0d76938 --- /dev/null +++ b/src/components/Battleresult.tsx @@ -0,0 +1,93 @@ +import { FC, useState, useEffect } from 'react'; +import Backdrop from '@mui/material/Backdrop'; +import Modal from '@mui/material/Modal'; +import Fade from '@mui/material/Fade'; +import Typography from '@mui/material/Typography'; +import backgroundImage from '../assets/tutorial.png'; +import { Button, Stack } from '@mui/material'; +import { EATLIMIT } from '../const/eatLimit'; +import { EmotionDataType } from '../types/EmotionDataType'; + +const style = { + position: 'absolute' as const, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 300, + color: '#000', + + backgroundImage: `url(${backgroundImage})`, + backgroundSize: 'cover', + backgroundRepeat: 'no-repeat', + backgroundPosition: 'center', + border: '1.5px solid #FFF', + borderRadius: '10px', + boxShadow: 24, + p: 4, + outline: 'none', +}; + +type Props = { + monster: number; + eatCount: number; + open: boolean; + emotionData: EmotionDataType; + openclick: React.MouseEventHandler | undefined; + closeclick: React.MouseEventHandler | undefined; +}; + +const Battleresult: FC = (Props) => { + const [label, setlabel] = useState(''); + const emoId = Props.emotionData.emoId; + useEffect(() => { + if (Props.monster === emoId) { + setlabel('ヤギはたたかいにかったようだ!やぎをほめよう!'); + } else { + setlabel('ヤギはたたかいにまけてしまった!やぎをはげまそう!'); + } + }, []); + + return ( +
+ {Props.eatCount > EATLIMIT ? ( + + + + + ヤギはモンスターとたたかった! + + + + {label} + + + + + + + + + ) : null} +
+ ); +}; +export default Battleresult; diff --git a/src/components/Form.tsx b/src/components/Form.tsx index 897f4fe..7c400de 100644 --- a/src/components/Form.tsx +++ b/src/components/Form.tsx @@ -8,6 +8,7 @@ type Props = { inputText: string; handleChange: (event: React.ChangeEvent) => void; handleSubmit: (event: React.MouseEvent) => void; + handleBattleChange: React.MouseEventHandler | undefined; isDisableTextField: boolean; }; @@ -59,15 +60,24 @@ const Form: FC = (props) => { {props.isDisableTextField ? ( - + <> + + + ) : (