commit 9526dd25e6ac22eeffabf1d38d378334f3be0104 Author: Hansoo Date: Sun Jul 26 13:25:04 2020 +0900 initial commit v1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..20feacc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +package-lock.json +util/*.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..fa7f585 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Catherine League + diff --git a/client/.env b/client/.env new file mode 100644 index 0000000..988c041 --- /dev/null +++ b/client/.env @@ -0,0 +1 @@ +REACT_APP_API_URL=http://localhost:7000/ \ No newline at end of file diff --git a/client/.env.production b/client/.env.production new file mode 100644 index 0000000..08d6186 --- /dev/null +++ b/client/.env.production @@ -0,0 +1 @@ +REACT_APP_API_URL=/ \ No newline at end of file diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 0000000..4d29575 --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/client/README.md b/client/README.md new file mode 100644 index 0000000..74735dc --- /dev/null +++ b/client/README.md @@ -0,0 +1,44 @@ +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.
+You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.
+It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.
+Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). diff --git a/client/package.json b/client/package.json new file mode 100644 index 0000000..b26bb53 --- /dev/null +++ b/client/package.json @@ -0,0 +1,56 @@ +{ + "name": "catherine-league", + "version": "0.1.0", + "private": true, + "dependencies": { + "axios": "^0.19.2", + "dotenv": "^8.2.0", + "i18next": "^19.6.3", + "node-sass": "^4.13.1", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-i18next": "^11.7.0", + "react-router-dom": "^5.2.0", + "react-scripts": "3.4.1", + "react-youtube": "^7.11.3", + "semantic-ui-css": "^2.4.1", + "semantic-ui-react": "^0.88.2", + "typescript": "^3.7.5" + }, + "devDependencies": { + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.5.0", + "@testing-library/user-event": "^7.2.1", + "@types/react-router-dom": "^5.1.5", + "@types/jest": "^24.9.1", + "@types/node": "^12.12.35", + "@types/react": "^16.9.34", + "@types/react-dom": "^16.9.6", + "@types/react-youtube": "^7.6.2", + "tslint": "^5.18.0", + "tslint-config-airbnb": "^5.11.1", + "tslint-react": "^4.0.0" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject", + "lint": "tslint -c tslint.json -p tsconfig.json" + }, + "eslintConfig": { + "extends": "react-app" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} diff --git a/client/public/favicon.ico b/client/public/favicon.ico new file mode 100644 index 0000000..64b368f Binary files /dev/null and b/client/public/favicon.ico differ diff --git a/client/public/index.html b/client/public/index.html new file mode 100644 index 0000000..16c978a --- /dev/null +++ b/client/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + キャサリン faito crab + + + +
+ + + diff --git a/client/public/manifest.json b/client/public/manifest.json new file mode 100644 index 0000000..080d6c7 --- /dev/null +++ b/client/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/client/public/robots.txt b/client/public/robots.txt new file mode 100644 index 0000000..e9e57dc --- /dev/null +++ b/client/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/client/src/App.css b/client/src/App.css new file mode 100644 index 0000000..f57631b --- /dev/null +++ b/client/src/App.css @@ -0,0 +1,42 @@ +.App { + text-align: center; +} + +.App-logo { + height: 40vmin; + pointer-events: none; +} + +@media (prefers-reduced-motion: no-preference) { + .App-logo { + animation: App-logo-spin infinite 20s linear; + } +} + +.App-header { + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} + +.App-link { + color: #61dafb; +} + +@keyframes App-logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +#root { + height: 100vh; +} \ No newline at end of file diff --git a/client/src/App.test.tsx b/client/src/App.test.tsx new file mode 100644 index 0000000..4db7ebc --- /dev/null +++ b/client/src/App.test.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import App from './App'; + +test('renders learn react link', () => { + const { getByText } = render(); + const linkElement = getByText(/learn react/i); + expect(linkElement).toBeInTheDocument(); +}); diff --git a/client/src/App.tsx b/client/src/App.tsx new file mode 100644 index 0000000..90266b9 --- /dev/null +++ b/client/src/App.tsx @@ -0,0 +1,102 @@ +import React from 'react'; +import './App.css'; +import style from './web.module.scss'; +import 'semantic-ui-css/semantic.min.css'; +import { Home } from './components/home'; +import { Players } from './components/players'; +import { Scoreboard } from './components/scoreboard'; +import { Tournaments } from './components/tournaments'; +import { About } from './components/about'; +import { Guide } from './components/guide'; +import { Archive } from './components/archive'; +import { Contact } from './components/contact'; +import { NotFound } from './components/notfound'; +import { + BrowserRouter as Router, + Switch, + Route, + Link +} from 'react-router-dom'; + +function App(): JSX.Element { + return ( + +
+
+
+
+   +
+
+
+
+ + + + + + + + + + +
+
+ +
+ + + + + + + + + + + + +
+
+
+

©ATLUS ©SEGA All Rights Reserved.

+

本ページは、株式会社ATLUS様のページとは異なるユーザーサイトです。

+

問い合わせなどをATLUS様に出されないよう、ご注意ください。

+
+
+   +
+
+   +
+
+
+ + ); +} + +export default App; diff --git a/client/src/components/about.tsx b/client/src/components/about.tsx new file mode 100644 index 0000000..7f174fc --- /dev/null +++ b/client/src/components/about.tsx @@ -0,0 +1,28 @@ +import React, { FunctionComponent } from 'react'; +import style from '../web.module.scss'; + +type ComponentProps = { +}; + +export const About: FunctionComponent = (props): JSX.Element => { + + return ( +
+

About

+
+
+
+

Covid-19 の影響で、オフライン大会の実施なども困難であるため、オンラインによるランキングバトル(通称:ストレイシープ杯)を開催することになりました。

+

先日発売されたSwitch版+各自の配信設備を用いて大会を実施するため、まずは少人数で進めていきます。(まずは第0回を実験的に開催)

+

キャサリンの対戦は、決着はわかりやすいですが、使われているテクニックなどが分かるともっと楽しめると思うので、解説なども交えながら実施する予定です。

+

悪い点は改善し、良い点はつづけながら、継続的に続けていきたいと思います。

+

もっとこうしてみては?次の大会から参加したい!などございましたら問い合わせフォームからご意見下さい!

+

それでは、楽しんでいくめぇ。~

+
+
+   +
+
+
+ ); +}; diff --git a/client/src/components/archive.tsx b/client/src/components/archive.tsx new file mode 100644 index 0000000..b11cdf7 --- /dev/null +++ b/client/src/components/archive.tsx @@ -0,0 +1,69 @@ +import React, { FunctionComponent, useState, useEffect } from 'react'; +import { useTranslation } from 'react-i18next'; +import axios from 'axios'; +import style from '../web.module.scss'; +import YouTube from 'react-youtube'; + +import { IGuideItem } from '../models/IGuideItem'; + +type ComponentProps = { +}; + +export const Archive: FunctionComponent = (props): JSX.Element => { + const { t } = useTranslation(); + const [guideItems, setGuideItems] = useState([]); + + useEffect(() => { + if (guideItems.length === 0) { + const url = process.env.REACT_APP_API_URL; + const apiUrl = `${url}api/archive`; + axios.get(apiUrl) + .then((response) => { + if (response.data) { + setGuideItems(response.data); + } + }); + } + }, [guideItems, setGuideItems]); + + const renderVideo = (): JSX.Element[] => { + const result: JSX.Element[] = []; + if (guideItems.length > 0) { + const opts = { + height: '195', + width: '320' + }; + guideItems.forEach((el: IGuideItem) => { + result.push( +
+

{el.title}

+
+
+ +
+
+ ); + }); + } + + return result; + }; + + return ( +
+

{t('archive')}

+
+
+ {renderVideo()} +
+ ); +}; diff --git a/client/src/components/contact.tsx b/client/src/components/contact.tsx new file mode 100644 index 0000000..026e146 --- /dev/null +++ b/client/src/components/contact.tsx @@ -0,0 +1,61 @@ +import React, { FunctionComponent, useState, useEffect } from 'react'; +import { useTranslation } from 'react-i18next'; +import axios from 'axios'; +import style from '../web.module.scss'; + +import { IContactQuestion } from '../models/IContactQuestion'; + +type ComponentProps = { +}; + +export const Contact: FunctionComponent = (props): JSX.Element => { + const { t } = useTranslation(); + const [contactItems, setContactItems] = useState([]); + + useEffect(() => { + if (contactItems.length === 0) { + const url = process.env.REACT_APP_API_URL; + const apiUrl = `${url}api/about`; + axios.get(apiUrl) + .then((response) => { + if (response.data) { + setContactItems(response.data); + } + }); + } + }, [contactItems, setContactItems]); + + const renderQuestions = (): JSX.Element[] => { + const result: JSX.Element[] = []; + if (contactItems.length > 0) { + contactItems.forEach((el: IContactQuestion) => { + result.push( +
+

{el.question}

+
+
{el.answer}
+
+ ); + }); + } + + return result; + }; + + return ( +
+

{t('qanda')}

+
+
+   +
+ {renderQuestions()} +
+ ); +}; diff --git a/client/src/components/guide.tsx b/client/src/components/guide.tsx new file mode 100644 index 0000000..bd828c0 --- /dev/null +++ b/client/src/components/guide.tsx @@ -0,0 +1,70 @@ +import React, { FunctionComponent, useState, useEffect } from 'react'; +import { useTranslation } from 'react-i18next'; +import axios from 'axios'; +import style from '../web.module.scss'; +import YouTube from 'react-youtube'; + +import { IGuideItem } from '../models/IGuideItem'; + +type ComponentProps = { +}; + +export const Guide: FunctionComponent = (props): JSX.Element => { + const { t } = useTranslation(); + const [guideItems, setGuideItems] = useState([]); + + useEffect(() => { + if (guideItems.length === 0) { + const url = process.env.REACT_APP_API_URL; + const apiUrl = `${url}api/guide`; + axios.get(apiUrl) + .then((response) => { + if (response.data) { + setGuideItems(response.data); + } + }); + } + }, [guideItems, setGuideItems]); + + const renderVideo = (): JSX.Element[] => { + const result: JSX.Element[] = []; + if (guideItems.length > 0) { + const opts = { + height: '195', + width: '320' + }; + guideItems.forEach((el: IGuideItem) => { + result.push( +
+

{el.title}

+
+
{el.description}
+
+ +
+
+ ); + }); + } + + return result; + }; + + return ( +
+

{t('guide')}

+
+
+ {renderVideo()} +
+ ); +}; diff --git a/client/src/components/home.tsx b/client/src/components/home.tsx new file mode 100644 index 0000000..4abdc66 --- /dev/null +++ b/client/src/components/home.tsx @@ -0,0 +1,26 @@ +import React, { FunctionComponent } from 'react'; +import style from '../web.module.scss'; + +type ComponentProps = { +}; + +export const Home: FunctionComponent = (props): JSX.Element => { + + return ( +
+
+
+
+
+
+
+   +
+
+
+
+
+
+
+ ); +}; diff --git a/client/src/components/notfound.tsx b/client/src/components/notfound.tsx new file mode 100644 index 0000000..be0d039 --- /dev/null +++ b/client/src/components/notfound.tsx @@ -0,0 +1,13 @@ +import React, { FunctionComponent } from 'react'; + +type ComponentProps = { +}; + +export const NotFound: FunctionComponent = (props): JSX.Element => { + + return ( +
+ 404 +
+ ); +}; diff --git a/client/src/components/players.tsx b/client/src/components/players.tsx new file mode 100644 index 0000000..a7c2f31 --- /dev/null +++ b/client/src/components/players.tsx @@ -0,0 +1,64 @@ +import React, { FunctionComponent, useState, useEffect } from 'react'; +import { useParams } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; +import axios from 'axios'; +import style from '../web.module.scss'; + +import { IPlayerInfo } from '../models/IPlayerInfo'; + +type ComponentProps = { +}; + +export const Players: FunctionComponent = (props): JSX.Element => { + const { t } = useTranslation(); + const [playerInfo, setPlayerInfo] = useState([]); + const { tournament_key } = useParams(); + useEffect(() => { + if (playerInfo.length === 0) { + const url = process.env.REACT_APP_API_URL; + let apiUrl = `${url}api/players`; + if (tournament_key) { + apiUrl += `/${tournament_key}`; + } + axios.get(apiUrl) + .then((response) => { + if (response.data) { + setPlayerInfo(response.data); + } + }); + } + }, [tournament_key, playerInfo, setPlayerInfo]); + const renderPlayerInfo = (): JSX.Element[] => { + const result: JSX.Element[] = []; + if (playerInfo.length > 0) { + playerInfo.forEach((el: IPlayerInfo) => { + result.push( +
+
+
{t('player_name')}
+
{el.player_name}
+
{t('use_character')}
+
{el.name_jp}
+
{t('description')}
+
{el.description}
+
+ ); + }); + } + return result; + }; + return ( +
+

Players

+
+
+ {renderPlayerInfo()} +
+ ); +}; diff --git a/client/src/components/scoreboard.tsx b/client/src/components/scoreboard.tsx new file mode 100644 index 0000000..2e9eaa1 --- /dev/null +++ b/client/src/components/scoreboard.tsx @@ -0,0 +1,14 @@ +import React, { FunctionComponent } from 'react'; +import style from '../web.module.scss'; + +type ComponentProps = { +}; + +export const Scoreboard: FunctionComponent = (props): JSX.Element => { + + return ( +
+
+
+ ); +}; diff --git a/client/src/components/tournaments.tsx b/client/src/components/tournaments.tsx new file mode 100644 index 0000000..c0a22d3 --- /dev/null +++ b/client/src/components/tournaments.tsx @@ -0,0 +1,14 @@ +import React, { FunctionComponent } from 'react'; + +type ComponentProps = { +}; + +export const Tournaments: FunctionComponent = (props): JSX.Element => { + // const [openPlayer, setOpenPlayer] = useState(true); + + return ( +
+ Tournaments +
+ ); +}; diff --git a/client/src/i18n.ts b/client/src/i18n.ts new file mode 100644 index 0000000..432d5ff --- /dev/null +++ b/client/src/i18n.ts @@ -0,0 +1,25 @@ +import i18n from 'i18next'; +import { initReactI18next } from 'react-i18next'; + +import en from './locale/en.json'; +import ja from './locale/ja.json'; + +i18n.use(initReactI18next) + .init({ + fallbackLng: 'ja', + resources: { + en: { + translation: en + }, + ja: { + translation: ja + } + }, + debug: true, + interpolation: { + escapeValue: false + } + } +); + +export default i18n; diff --git a/client/src/index.css b/client/src/index.css new file mode 100644 index 0000000..ec2585e --- /dev/null +++ b/client/src/index.css @@ -0,0 +1,13 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; +} diff --git a/client/src/index.tsx b/client/src/index.tsx new file mode 100644 index 0000000..093ac27 --- /dev/null +++ b/client/src/index.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.css'; +import App from './App'; +import * as serviceWorker from './serviceWorker'; +import { I18nextProvider } from 'react-i18next'; +import i18n from './i18n'; + +ReactDOM.render( + ( + + + + + + ), + document.getElementById('root') +); + +// If you want your app to work offline and load faster, you can change +// unregister() to register() below. Note this comes with some pitfalls. +// Learn more about service workers: https://bit.ly/CRA-PWA +serviceWorker.unregister(); diff --git a/client/src/locale/en.json b/client/src/locale/en.json new file mode 100644 index 0000000..ee82983 --- /dev/null +++ b/client/src/locale/en.json @@ -0,0 +1,9 @@ +{ + "use_character": "Character", + "player_name": "Playername", + "description": "Description", + "archive": "Archive", + "guide": "Guide", + "about": "About", + "qanda": "Q&A" +} \ No newline at end of file diff --git a/client/src/locale/ja.json b/client/src/locale/ja.json new file mode 100644 index 0000000..f8f9ec6 --- /dev/null +++ b/client/src/locale/ja.json @@ -0,0 +1,9 @@ +{ + "use_character": "使用キャラクター", + "player_name": "プレイヤー名", + "description": "紹介文", + "archive": "Archive", + "guide": "Guide", + "about": "About", + "qanda": "Q&A" +} \ No newline at end of file diff --git a/client/src/logo.svg b/client/src/logo.svg new file mode 100644 index 0000000..6b60c10 --- /dev/null +++ b/client/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/client/src/models/IArchiveItem.ts b/client/src/models/IArchiveItem.ts new file mode 100644 index 0000000..ac4d834 --- /dev/null +++ b/client/src/models/IArchiveItem.ts @@ -0,0 +1,5 @@ +export interface IArchiveItem { + id: number; + title: string; + youtube_id: string; +} diff --git a/client/src/models/IContactQuestion.ts b/client/src/models/IContactQuestion.ts new file mode 100644 index 0000000..0107fb9 --- /dev/null +++ b/client/src/models/IContactQuestion.ts @@ -0,0 +1,5 @@ +export interface IContactQuestion { + id: number; + question: string; + answer: string; +} diff --git a/client/src/models/IGuideItem.ts b/client/src/models/IGuideItem.ts new file mode 100644 index 0000000..9012fc4 --- /dev/null +++ b/client/src/models/IGuideItem.ts @@ -0,0 +1,6 @@ +export interface IGuideItem { + id: number; + title: string; + description: string; + youtube_id: string; +} diff --git a/client/src/models/IPlayerInfo.ts b/client/src/models/IPlayerInfo.ts new file mode 100644 index 0000000..a729655 --- /dev/null +++ b/client/src/models/IPlayerInfo.ts @@ -0,0 +1,10 @@ +export interface IPlayerInfo { + id: number; + player_key: string; + player_name: string; + description: string; + image: string; + name_id: string; + name: string; + name_jp: string; +} diff --git a/client/src/react-app-env.d.ts b/client/src/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/client/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/client/src/serviceWorker.ts b/client/src/serviceWorker.ts new file mode 100644 index 0000000..b09523f --- /dev/null +++ b/client/src/serviceWorker.ts @@ -0,0 +1,149 @@ +// This optional code is used to register a service worker. +// register() is not called by default. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on subsequent visits to a page, after all the +// existing tabs open on the page have been closed, since previously cached +// resources are updated in the background. + +// To learn more about the benefits of this model and instructions on how to +// opt-in, read https://bit.ly/CRA-PWA + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.0/8 are considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +type Config = { + onSuccess?: (registration: ServiceWorkerRegistration) => void; + onUpdate?: (registration: ServiceWorkerRegistration) => void; +}; + +export function register(config?: Config) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL( + process.env.PUBLIC_URL, + window.location.href + ); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebook/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Let's check if a service worker still exists or not. + checkValidServiceWorker(swUrl, config); + + // Add some additional logging to localhost, pointing developers to the + // service worker/PWA documentation. + navigator.serviceWorker.ready.then(() => { + console.log( + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://bit.ly/CRA-PWA' + ); + }); + } else { + // Is not localhost. Just register service worker + registerValidSW(swUrl, config); + } + }); + } +} + +function registerValidSW(swUrl: string, config?: Config) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + if (installingWorker == null) { + return; + } + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the updated precached content has been fetched, + // but the previous service worker will still serve the older + // content until all client tabs are closed. + console.log( + 'New content is available and will be used when all ' + + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' + ); + + // Execute callback + if (config && config.onUpdate) { + config.onUpdate(registration); + } + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + + // Execute callback + if (config && config.onSuccess) { + config.onSuccess(registration); + } + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl: string, config?: Config) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl, { + headers: { 'Service-Worker': 'script' } + }) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + const contentType = response.headers.get('content-type'); + if ( + response.status === 404 || + (contentType != null && contentType.indexOf('javascript') === -1) + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl, config); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready + .then(registration => { + registration.unregister(); + }) + .catch(error => { + console.error(error.message); + }); + } +} diff --git a/client/src/setupTests.ts b/client/src/setupTests.ts new file mode 100644 index 0000000..74b1a27 --- /dev/null +++ b/client/src/setupTests.ts @@ -0,0 +1,5 @@ +// jest-dom adds custom jest matchers for asserting on DOM nodes. +// allows you to do things like: +// expect(element).toHaveTextContent(/react/i) +// learn more: https://github.com/testing-library/jest-dom +import '@testing-library/jest-dom/extend-expect'; diff --git a/client/src/static/font/indieflower.ttf b/client/src/static/font/indieflower.ttf new file mode 100644 index 0000000..1070aac Binary files /dev/null and b/client/src/static/font/indieflower.ttf differ diff --git a/client/src/static/img/00_bluecap_1204.png b/client/src/static/img/00_bluecap_1204.png new file mode 100644 index 0000000..d516445 Binary files /dev/null and b/client/src/static/img/00_bluecap_1204.png differ diff --git a/client/src/static/img/00_redcap_1204.png b/client/src/static/img/00_redcap_1204.png new file mode 100644 index 0000000..7e3da74 Binary files /dev/null and b/client/src/static/img/00_redcap_1204.png differ diff --git a/client/src/static/img/01_sheep_vincent_1204.png b/client/src/static/img/01_sheep_vincent_1204.png new file mode 100644 index 0000000..ddae072 Binary files /dev/null and b/client/src/static/img/01_sheep_vincent_1204.png differ diff --git a/client/src/static/img/01_vincent_1204.png b/client/src/static/img/01_vincent_1204.png new file mode 100644 index 0000000..c55c952 Binary files /dev/null and b/client/src/static/img/01_vincent_1204.png differ diff --git a/client/src/static/img/02_katherine_1204.png b/client/src/static/img/02_katherine_1204.png new file mode 100644 index 0000000..024d213 Binary files /dev/null and b/client/src/static/img/02_katherine_1204.png differ diff --git a/client/src/static/img/03_catherine_1204.png b/client/src/static/img/03_catherine_1204.png new file mode 100644 index 0000000..6809304 Binary files /dev/null and b/client/src/static/img/03_catherine_1204.png differ diff --git a/client/src/static/img/04_rin_1204.png b/client/src/static/img/04_rin_1204.png new file mode 100644 index 0000000..a6f6800 Binary files /dev/null and b/client/src/static/img/04_rin_1204.png differ diff --git a/client/src/static/img/05_orlando_1204.png b/client/src/static/img/05_orlando_1204.png new file mode 100644 index 0000000..44aabcf Binary files /dev/null and b/client/src/static/img/05_orlando_1204.png differ diff --git a/client/src/static/img/06_jonny_1204.png b/client/src/static/img/06_jonny_1204.png new file mode 100644 index 0000000..87889d2 Binary files /dev/null and b/client/src/static/img/06_jonny_1204.png differ diff --git a/client/src/static/img/07_tobby_1204.png b/client/src/static/img/07_tobby_1204.png new file mode 100644 index 0000000..9a52191 Binary files /dev/null and b/client/src/static/img/07_tobby_1204.png differ diff --git a/client/src/static/img/0801.png b/client/src/static/img/0801.png new file mode 100644 index 0000000..9a6b23e Binary files /dev/null and b/client/src/static/img/0801.png differ diff --git a/client/src/static/img/0802.png b/client/src/static/img/0802.png new file mode 100644 index 0000000..bb1eef9 Binary files /dev/null and b/client/src/static/img/0802.png differ diff --git a/client/src/static/img/0808.png b/client/src/static/img/0808.png new file mode 100644 index 0000000..9ffe075 Binary files /dev/null and b/client/src/static/img/0808.png differ diff --git a/client/src/static/img/0809.png b/client/src/static/img/0809.png new file mode 100644 index 0000000..ff8a603 Binary files /dev/null and b/client/src/static/img/0809.png differ diff --git a/client/src/static/img/0815.png b/client/src/static/img/0815.png new file mode 100644 index 0000000..020085d Binary files /dev/null and b/client/src/static/img/0815.png differ diff --git a/client/src/static/img/08_erika_1204.png b/client/src/static/img/08_erika_1204.png new file mode 100644 index 0000000..79aa638 Binary files /dev/null and b/client/src/static/img/08_erika_1204.png differ diff --git a/client/src/static/img/09_master_1204.png b/client/src/static/img/09_master_1204.png new file mode 100644 index 0000000..b8ba713 Binary files /dev/null and b/client/src/static/img/09_master_1204.png differ diff --git a/client/src/static/img/13_joker_1204.png b/client/src/static/img/13_joker_1204.png new file mode 100644 index 0000000..e046e3f Binary files /dev/null and b/client/src/static/img/13_joker_1204.png differ diff --git a/client/src/static/img/atlus_logo.png b/client/src/static/img/atlus_logo.png new file mode 100644 index 0000000..64ff14c Binary files /dev/null and b/client/src/static/img/atlus_logo.png differ diff --git a/client/src/static/img/background.png b/client/src/static/img/background.png new file mode 100644 index 0000000..b622c45 Binary files /dev/null and b/client/src/static/img/background.png differ diff --git a/client/src/static/img/bgbg.png b/client/src/static/img/bgbg.png new file mode 100644 index 0000000..18a5832 Binary files /dev/null and b/client/src/static/img/bgbg.png differ diff --git a/client/src/static/img/bgimage.png b/client/src/static/img/bgimage.png new file mode 100644 index 0000000..ebecce7 Binary files /dev/null and b/client/src/static/img/bgimage.png differ diff --git a/client/src/static/img/bgimagenight.png b/client/src/static/img/bgimagenight.png new file mode 100644 index 0000000..38c0fbe Binary files /dev/null and b/client/src/static/img/bgimagenight.png differ diff --git a/client/src/static/img/buynow.png b/client/src/static/img/buynow.png new file mode 100644 index 0000000..e8107a5 Binary files /dev/null and b/client/src/static/img/buynow.png differ diff --git a/client/src/static/img/cat_fb_logo.png b/client/src/static/img/cat_fb_logo.png new file mode 100644 index 0000000..f9ccb71 Binary files /dev/null and b/client/src/static/img/cat_fb_logo.png differ diff --git a/client/src/static/img/chalice.png b/client/src/static/img/chalice.png new file mode 100644 index 0000000..a5496fd Binary files /dev/null and b/client/src/static/img/chalice.png differ diff --git a/client/src/static/img/faito_crab.png b/client/src/static/img/faito_crab.png new file mode 100644 index 0000000..937651f Binary files /dev/null and b/client/src/static/img/faito_crab.png differ diff --git a/client/src/static/img/for_switch.png b/client/src/static/img/for_switch.png new file mode 100644 index 0000000..9593552 Binary files /dev/null and b/client/src/static/img/for_switch.png differ diff --git a/client/src/static/img/letterbox.png b/client/src/static/img/letterbox.png new file mode 100644 index 0000000..02aa31c Binary files /dev/null and b/client/src/static/img/letterbox.png differ diff --git a/client/src/static/img/playerbg.png b/client/src/static/img/playerbg.png new file mode 100644 index 0000000..89e0dda Binary files /dev/null and b/client/src/static/img/playerbg.png differ diff --git a/client/src/static/img/players.png b/client/src/static/img/players.png new file mode 100644 index 0000000..d8f3109 Binary files /dev/null and b/client/src/static/img/players.png differ diff --git a/client/src/static/img/rule.png b/client/src/static/img/rule.png new file mode 100644 index 0000000..b891bbd Binary files /dev/null and b/client/src/static/img/rule.png differ diff --git a/client/src/static/img/scoreboard.png b/client/src/static/img/scoreboard.png new file mode 100644 index 0000000..06e8477 Binary files /dev/null and b/client/src/static/img/scoreboard.png differ diff --git a/client/src/static/img/straysheepcup0.png b/client/src/static/img/straysheepcup0.png new file mode 100644 index 0000000..b76a07f Binary files /dev/null and b/client/src/static/img/straysheepcup0.png differ diff --git a/client/src/static/img/title_sheep.png b/client/src/static/img/title_sheep.png new file mode 100644 index 0000000..2c9673c Binary files /dev/null and b/client/src/static/img/title_sheep.png differ diff --git a/client/src/static/img/twitch.png b/client/src/static/img/twitch.png new file mode 100644 index 0000000..989a1c8 Binary files /dev/null and b/client/src/static/img/twitch.png differ diff --git a/client/src/static/img/youtube.png b/client/src/static/img/youtube.png new file mode 100644 index 0000000..c164dd7 Binary files /dev/null and b/client/src/static/img/youtube.png differ diff --git a/client/src/web.module.scss b/client/src/web.module.scss new file mode 100644 index 0000000..bff7065 --- /dev/null +++ b/client/src/web.module.scss @@ -0,0 +1,508 @@ +@font-face { + font-family: 'IndieFlower'; + src: url('./static/font/indieflower.ttf') format('truetype'); } + +.header { + background-image: url('./static/img/bgbg.png'); + background-repeat: none; + width: 100%; + height: 460px; +} +.buynow { + position: fixed; + top: 0; + bottom: 0; + right: 0; + margin: auto; + width: 235px; + height: 99px; + background-image: url('./static/img/buynow.png'); + z-index: 1; + &> a { + display:block; + width: 235px; + height: 99px; + } + &:hover { + animation: bounce 1s; + } +} +.background { + position: absolute; + top: 0; + left: 0; + right: 0; + margin: auto; + background-image: url('./static/img/bgimage.png'); + background-repeat: none; + width: 1366px; + height: 401px; + animation: upAndDown 10s linear infinite; + transition: background-image 0.5s ease-in-out; + &:hover { + transition: background-image 0.5s ease-in-out; + background-image: url('./static/img/bgimagenight.png'); + } +} +.logoHeader { + position: absolute; + top: -30px; + left: 0; + right: 0; + margin: auto; + width: 577px; + height: 401px; + background-image: url('./static/img/cat_fb_logo.png'); + background-repeat: none; + z-index: 1; +} + +.logoSwitch { + position: absolute; + top: 310px; + left: 0; + right: 0; + margin: auto; + width: 415px; + height: 64px; + background-image: url('./static/img/faito_crab.png'); + background-repeat: none; + z-index: 1; +} +.contents { + flex-grow: 1; + padding: 30px; +} +.main { + display: flex; + flex-direction: column; + width: 100%; + background-image: url('./static/img/background.png'); + background-repeat: none; + color: white; + min-height: 100vh; +} +.footer { + display: flex; + justify-content: center; + align-items: center; + flex-direction: row; + padding: 20px; + width: 100%; + background-color: black; + color: white; + bottom: 0; +} +.footerText { + float: left; + display: block; + justify-content: center; + align-items: center; + flex-direction: row; + & > p { + margin: 5px 0; + } +} + +.twitch { + float: right; + width: 113px; + height: 70px; + background-image: url('./static/img/twitch.png'); + background-size: 142px 70px; + margin: 0 20px; + background-repeat: none; + background-size: contain; + &> a { + display:block; + width: 113px; + height: 70px; + } +} +.twitchHome { + width: 113px; + height: 70px; + background-image: url('./static/img/twitch.png'); + background-size: 142px 70px; + margin: auto; + background-repeat: none; + background-size: contain; + &> a { + display:block; + width: 113px; + height: 70px; + } +} +.youtube { + float: right; + width: 100px; + height: 70px; + margin: 0 20px; + background-image: url('./static/img/youtube.png'); + background-size: contain; + &> a { + display:block; + width: 100px; + height: 70px; + } +} + +.waveContainer { + position: absolute; + top: 260px; + left: 0; + right: 0; + margin: auto; + z-index: 0; +} +.waves { + position: relative; + width: 100%; + height: 200px; + margin-bottom: -7px; + + min-height: 100px; + max-height: 200px; +} +.firstWave { + animation: moveforever 25s cubic-bezier(.55, .5, .45, .5) infinite; + animation-delay: -2s; + animation-duration: 2s; +} +.secondWave { + animation: moveforever 25s cubic-bezier(.55, .5, .45, .5) infinite; + animation-delay: -4s; + animation-duration: 5s; +} +@keyframes moveforever { + 0% { + transform: translate3d(-90px, 0, 0); + } + 100% { + transform: translate3d(85px, 0, 0); + } +} +@keyframes bounce { + 0%, 20%, 60%, 100% { + -webkit-transform: translateY(0); + transform: translateY(0); + } + + 40% { + -webkit-transform: translateY(-20px); + transform: translateY(-20px); + } + + 80% { + -webkit-transform: translateY(-10px); + transform: translateY(-10px); + } +} + +.navigation { + position: absolute; + top: 400px; + left: 0; + right: 0; + margin: auto; + z-index: 1; + display: flex; + align-items: center; + justify-content: center; + &>ul { + list-style-type: none; + &>li { + float: left; + margin-left: 10px; + margin-right: 10px; + &>a { + background-color: black; + width: 90px; + height: 30px; + display: flex; + align-items: center; + justify-content: center; + color: white; + font-size: 16px; + font-family: 'IndieFlower'; + color: white; + &:hover { + transform: rotate(-10deg); + font-weight: bold; + color: pink; + } + } + } + } +} +.characterBlock { + position: relative; + opacity: 0; + width: 980px; + height: 314px; + margin: 20px auto; + padding: 30px; + background-image: url('./static/img/playerbg.png'); + background-repeat: none; + font-family: 'M PLUS Rounded 1c'; + &:nth-child(odd) { + animation: slideInFromLeft 1s forwards; + } + &:nth-child(even) { + animation: slideInFromRight 1s forwards; + } +} +@keyframes slideInFromLeft { + 0% { + transform: translateX(-100%); + } + 100% { + opacity: 1; + transform: translateX(0); + } +} +@keyframes slideInFromRight { + 0% { + transform: translateX(100%); + } + 100% { + opacity: 1; + transform: translateX(0); + } +} +@keyframes upAndDown { + 0%, + 100% { + transform: translateY(0); + } + 50% { + transform: translateY(-5%); + } +} +@media (max-width: 600px) { + .buynow { + display: none; + } +} + +@mixin characterImage($url) { + width: 240px; + height: 240px; + margin: 0 20px 0 0; + background-image: url($url); + background-size: contain; + float: left; + +} + +.character-blue_cap { + @include characterImage('./static/img/00_bluecap_1204.png'); +} +.character-red_cap { + @include characterImage('./static/img/00_redcap_1204.png'); +} +.character-vincent_shirt { + @include characterImage('./static/img/01_vincent_1204.png'); +} +.character-vincent_sheep { + @include characterImage('./static/img/01_sheep_vincent_1204.png'); +} +.character-katherine { + @include characterImage('./static/img/02_katherine_1204.png'); +} +.character-catherine { + @include characterImage('./static/img/03_catherine_1204.png'); +} +.character-rin { + @include characterImage('./static/img/04_rin_1204.png'); +} +.character-orlando { + @include characterImage('./static/img/05_orlando_1204.png'); +} +.character-johny { + @include characterImage('./static/img/06_jonny_1204.png'); +} +.character-tobby { + @include characterImage('./static/img/07_tobby_1204.png'); +} +.character-erica { + @include characterImage('./static/img/08_erika_1204.png'); +} +.character-master { + @include characterImage('./static/img/09_master_1204.png'); +} +.character-joker { + @include characterImage('./static/img/13_joker_1204.png'); +} + +.titlePlayer { + position: relative; + display: flex; + margin-bottom: 10px; +} + +.titlePlayerBlock { + padding: 5px 10px; + background-color: white; + transform: rotate(-5deg); + color: black; + font-family: 'M PLUS Rounded 1c'; +} + +.aboutNoticeBlock { + position: relative; + width: 980px; + height: 800px; + margin: 20px auto; + padding: 50px; + background-image: url('./static/img/playerbg.png'); + background-repeat: none; + background-size: 980px 800px; + font-family: 'M PLUS Rounded 1c'; +} + +.sheepAbout { + position: relative; + width: 207px; + height: 350px; + float: left; + margin-top: 70px; + bottom: 0; + left: 0; + background-image: url('./static/img/title_sheep.png'); + background-repeat: none; +} +.guideBody { + position: relative; + margin: 20px auto; + width: 980px; +} +.centerVideo { + width: 100%; + display: flex; + justify-content: center; +} + +.aboutContactBox { + position: relative; + width: 128px; + height: 128px; + margin: 20px; + background-image: url('./static/img/letterbox.png'); + background-size: 128px 128px; + background-repeat: none; + & > a { + display: block; + width: 128px; + height: 128px; + } +} +.contactBox { + position: relative; + width: 128px; + height: 128px; + margin: 20px auto; + background-image: url('./static/img/letterbox.png'); + background-size: 128px 128px; + background-repeat: none; + & > a { + display: block; + width: 128px; + height: 128px; + } +} + +.mainBody { + position: flex; + margin: 20px auto; + width: 980px; + align-items: center; + justify-content: center; +} +.chalice { + width: 400px; + height: 340px; + margin: auto; + background-image: url('./static/img/chalice.png'); + background-size: contain; + background-repeat: none; +} +.players { + width: 900px; + height: 606px; + margin: auto; + background-image: url('./static/img/players.png'); + background-size: contain; + background-repeat: none; +} +.scoreboardImage { + width: 567px; + height: 485px; + margin: auto; + background-image: url('./static/img/scoreboard.png'); + background-size: contain; + background-repeat: none; +} +.titleImageStrayShip0 { + width: 808px; + height: 119px; + margin: auto; + background-image: url('./static/img/straysheepcup0.png'); + background-size: contain; + background-repeat: none; +} +.rule { + width: 900px; + height: 637px; + margin: auto; + background-image: url('./static/img/rule.png'); + background-size: contain; + background-repeat: none; +} + +.padding { + width: 900px; + height: 100px; + margin: auto; +} +.players0801 { + width: 899px; + height: 696px; + margin: auto; + background-image: url('./static/img/0801.png'); + background-size: contain; + background-repeat: none; +} + +.players0802 { + width: 900px; + height: 710px; + margin: auto; + background-image: url('./static/img/0802.png'); + background-size: contain; + background-repeat: none; +} +.players0808 { + width: 900px; + height: 710px; + margin: auto; + background-image: url('./static/img/0808.png'); + background-size: contain; + background-repeat: none; +} +.players0809 { + width: 900px; + height: 696px; + margin: auto; + background-image: url('./static/img/0809.png'); + background-size: contain; + background-repeat: none; +} +.players0815 { + width: 900px; + height: 696px; + margin: auto; + background-image: url('./static/img/0815.png'); + background-size: contain; + background-repeat: none; +} diff --git a/client/tsconfig.json b/client/tsconfig.json new file mode 100644 index 0000000..f2850b7 --- /dev/null +++ b/client/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react" + }, + "include": [ + "src" + ] +} diff --git a/client/tslint.json b/client/tslint.json new file mode 100644 index 0000000..6fce750 --- /dev/null +++ b/client/tslint.json @@ -0,0 +1,40 @@ +{ + "defaultSeverity": "error", + "extends": [ + "tslint:recommended", + "tslint-react" + ], + "jsRules": {}, + "rules": { + "curly": [true, "ignore-same-line"], + "typedef": [ + true, + "call-signature", + "arrow-call-signature", + "parameter", + "member-variable-declaration", + "property-declaration" + ], + "no-any": false, + "quotemark": [true, "single"], + "trailing-comma": false, + "max-line-length": false, + "ordered-imports": false, + "object-literal-sort-keys": false, + "member-ordering": false, + "no-console": false, + "align": false, + "semicolon": [true, "always"], + "whitespace": [true, "check-module"], + "interface-over-type-literal": false, + "member-access": false, + "jsx-no-lambda": false, + "jsx-no-multiline-js": false + }, + "rulesDirectory": [], + "linterOptions": { + "exclude": [ + "src/serviceWorker.ts" + ] + } +} diff --git a/infra/db.sql b/infra/db.sql new file mode 100644 index 0000000..98d1705 --- /dev/null +++ b/infra/db.sql @@ -0,0 +1,152 @@ +CREATE SCHEMA `catherine_league` DEFAULT CHARACTER SET utf8mb4 ; + +CREATE TABLE `catherine_league`.`players` ( + `id` INT NOT NULL AUTO_INCREMENT, + `player_key` VARCHAR(45) NULL, + `player_name` VARCHAR(45) NULL, + `description` LONGTEXT NULL, + `image` VARCHAR(1024) NULL, + `character_id` VARCHAR(45) NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC), + UNIQUE INDEX `player_key_UNIQUE` (`player_key` ASC)); + +INSERT INTO `catherine_league`.`players` (`player_key`, `player_name`, `description`, `character_id`) VALUES ('rino', 'リノ', '日本キャサリン・フルボディ界の絶対王者。EVOJ2019覇者、TPF4連覇中など国内公式大会では無敵、本番アメリカのEVOで3位、CCでも2位と世界でも屈指の実力者。今回のEVOJでも本命とされる「魔王」。', 6); +INSERT INTO `catherine_league`.`players` (`player_key`, `player_name`, `description`, `character_id`) VALUES ('mst', 'MST', '関東のキャサリン絶対コミュニティをさせてくれている人。その実力も国内トップクラスで、「DK侍」の異名を持つ。以前はインファイトのみを得意としていたが、最近は登りも身に着けてオールラウンダーへと変身しつつある。直近のアメリカで行われたCCでは、EVO王者のLinusを撃破。', 5); +INSERT INTO `catherine_league`.`players` (`player_key`, `player_name`, `description`, `character_id`) VALUES ('kim', 'Kim', 'キャサリン界の完璧超人。4ヶ国語を操り、料理もとても上手い。EVOJ2018で準優勝した実績もあり、その実力は国内屈指。最近ではバベルでどんどん力をつけ、総合力では日本最高かもしれない。大会で緊張してしまうらしくメンタルに不安を残す。', 2); +INSERT INTO `catherine_league`.`players` (`player_key`, `player_name`, `description`, `character_id`) VALUES ('g30', 'G30', 'ATLUSのゲームをこよなく愛する「キャサリン飲酒部部長」。その実力は折り紙つきで、打倒リノの最有力。先行したときのブロック技術は世界トップクラス。くじ運とスタミナに若干の不安を残す。Genki Stateの使い手。笑顔の悪魔。', 12); +INSERT INTO `catherine_league`.`players` (`player_key`, `player_name`, `description`, `character_id`) VALUES ('leza', 'れざえもん', 'アウター神たなかまさしと並ぶ、日本バベル界の神様。何よりその圧倒的な登り力を圧巻。対戦歴は浅いが、高すぎるキャサリン力と研究心でめきめきと頭角を現している。登りのルート構築の速さは世界一。いくら落としても復帰してくるので、L3「れざ」ボタンの装備を疑われている。', 9); +INSERT INTO `catherine_league`.`players` (`player_key`, `player_name`, `description`, `character_id`) VALUES ('takayan', 'たかやん', 'イクメンゲーマー。飲酒部らしい陽気な性格とプレイスタイルで、勢いのあるキャサリンを得意とする。上る力は若干不安があるが、インファイトには自信あり。お子さん可愛すぎる。', 10); +INSERT INTO `catherine_league`.`players` (`player_key`, `player_name`, `description`, `character_id`) VALUES ('masato', 'まさと', 'マルチ格ゲーマー。設営の実力はキャサリン界で圧倒的。練習熱心で、キャサリン歴は浅いがバベル全ステージ制覇を達成している。師匠Kimのもと研鑽に励む。怒ると金髪からピンクに変わって強くなる。', 13); + +CREATE TABLE `catherine_league`.`characters` ( + `id` INT NOT NULL AUTO_INCREMENT, + `name_id` VARCHAR(45) NULL, + `name` VARCHAR(45) NULL, + `name_jp` VARCHAR(45) NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC)); + +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('blue_cap', 'blue_sheep', '青帽子(羊)'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('red_cap', 'red_sheep', '赤帽子(羊)'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('vincent_shirt', 'vincent_shirt', 'ヴィンセント(シャーツ)'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('vincent_sheep', 'vincent_sheep', 'ヴィンセント(悪夢)'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('katherine', 'katherine', 'キャサリン(K)'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('catherine', 'catherine', 'キャサリン(C)'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('rin', 'rin', 'リン'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('orlando', 'orlando', 'オーランド'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('johny', 'johny', 'ジョニー'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('tobby', 'tobby', 'トビー'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('erica', 'erica', 'エリカ'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('master', 'master', 'マスター'); +INSERT INTO `catherine_league`.`characters` (`name_id`, `name`, `name_jp`) VALUES ('joker', 'joker', 'ジョーカー'); + +CREATE TABLE `catherine_league`.`stages` ( + `id` INT NOT NULL AUTO_INCREMENT, + `stage` VARCHAR(45) NULL, + `stage_name` VARCHAR(45) NULL, + `stage_name_jp` VARCHAR(45) NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC)); + +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('underground', 'Underground Cementery', '地下墓地'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('prison', 'Prison of Despair', '罪人監獄'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('torture', 'Torture Chamber', '拷問刑場'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('inquisition', 'Inquisition', '審問法廷'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('quadrangle', 'Quadrangle', '暴風の中庭'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('clock', 'Clock Tower', '時計塔'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('spiral', 'Spiral Corridor', '祭壇への道'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('cathedral', 'The Cathedral', '大聖堂'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('empireo', 'The Empireo', '天上'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('encounter', 'Close Encounter', '新天地'); +INSERT INTO `catherine_league`.`stages` (`stage`, `stage_name`, `stage_name_jp`) VALUES ('arrange', 'Arrange', 'アレンジ'); + +CREATE TABLE `catherine_league`.`tournaments` ( + `id` INT NOT NULL AUTO_INCREMENT, + `tournament_key` VARCHAR(45) NULL, + `name` VARCHAR(45) NULL, + `name_jp` VARCHAR(45) NULL, + `type` VARCHAR(45) NULL, + `first` INT NULL, + `second` INT NULL, + `third` INT NULL, + `finished` TINYINT NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC), + UNIQUE INDEX `tournament_key_UNIQUE` (`tournament_key` ASC)); + +CREATE TABLE `catherine_league`.`stage_to_match` ( + `id` INT NOT NULL AUTO_INCREMENT, + `match_id` INT NOT NULL, + `player_one` INT NOT NULL, + `player_two` INT NOT NULL, + `score_one` INT NULL, + `score_two` INT NULL, + `stage` INT NULL, + `create_date` DATETIME NULL DEFAULT NOW(), + `update_date` DATETIME NULL DEFAULT NOW(), + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC)); + +CREATE TABLE `catherine_league`.`match_to_round` ( + `id` INT NOT NULL AUTO_INCREMENT, + `round_id` INT NOT NULL, + `player_one` INT NOT NULL, + `player_two` INT NOT NULL, + `score_one` INT NULL, + `score_two` INT NULL, + `create_date` DATETIME NULL DEFAULT NOW(), + `update_date` DATETIME NULL DEFAULT NOW(), + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC)); + +CREATE TABLE `catherine_league`.`round_to_tournament` ( + `id` INT NOT NULL AUTO_INCREMENT, + `tournament_id` INT NOT NULL, + `create_date` DATETIME NULL DEFAULT NOW(), + `update_date` DATETIME NULL DEFAULT NOW(), + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC)); + +CREATE TABLE `catherine_league`.`player_to_tournament` ( + `id` INT NOT NULL AUTO_INCREMENT, + `tournament_id` INT NOT NULL, + `player_id` INT NOT NULL, + `create_date` DATETIME NULL DEFAULT NOW(), + `update_date` DATETIME NULL DEFAULT NOW(), + PRIMARY KEY (`id`), + UNIQUE INDEX `id_UNIQUE` (`id` ASC)); + +CREATE TABLE `catherine_league`.`contact` ( + `id` INT NOT NULL AUTO_INCREMENT, + `question` LONGTEXT NOT NULL, + `answer` LONGTEXT NOT NULL, + `create_date` DATETIME NULL DEFAULT NOW(), + `update_date` DATETIME NULL DEFAULT NOW(), + PRIMARY KEY (`id`)); + +CREATE TABLE `catherine_league`.`config` ( + `config_key` VARCHAR(45) NOT NULL, + `config_value` LONGTEXT NULL, + PRIMARY KEY (`config_key`)); + +INSERT INTO `catherine_league`.`config` (`config_key`, `config_value`) VALUES ('footer', 'ATLUS'); + +CREATE TABLE `catherine_league`.`guide` ( + `id` INT NOT NULL AUTO_INCREMENT, + `title` VARCHAR(45) NULL, + `description` LONGTEXT NULL, + `youtube_id` VARCHAR(45) NULL, + PRIMARY KEY (`id`)); + +INSERT INTO `catherine_league`.`guide` (`title`, `description`, `youtube_id`) VALUES ('格ゲー大好き茜ちゃんと競う『キャサリン・フルボディ』 【VOICEROID紹介動画】', 'mekasueさんによるキャサリン対戦とは・・・', 'oE8Xk6pGtQc'); +INSERT INTO `catherine_league`.`guide` (`title`, `description`, `youtube_id`) VALUES ('【PGW.TV】キャサリンフルボディ 「対戦時に使うテクニック紹介など」【はやお】', 'はやおプロのキャサリン対戦講座', '7fZk2Agy0S4'); + +CREATE TABLE `catherine_league`.`archive` ( + `id` INT NOT NULL AUTO_INCREMENT, + `title` VARCHAR(45) NULL, + `youtube_id` VARCHAR(45) NULL, + PRIMARY KEY (`id`)); + +INSERT INTO `catherine_league`.`archive` (`title`, `youtube_id`) VALUES ('格ゲー大好き茜ちゃんと競う『キャサリン・フルボディ』 【VOICEROID紹介動画】', 'oE8Xk6pGtQc'); +INSERT INTO `catherine_league`.`archive` (`title`, `youtube_id`) VALUES ('【PGW.TV】キャサリンフルボディ 「対戦時に使うテクニック紹介など」【はやお】', '7fZk2Agy0S4'); diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 0000000..47ec61b --- /dev/null +++ b/server/.gitignore @@ -0,0 +1,3 @@ +admin/ +client/ +build/ \ No newline at end of file diff --git a/server/package.json b/server/package.json new file mode 100644 index 0000000..d5a3428 --- /dev/null +++ b/server/package.json @@ -0,0 +1,28 @@ +{ + "name": "catherine-league-server", + "version": "1.0.0", + "description": "", + "main": "src/index.ts", + "scripts": { + "start": "ts-node-dev --respawn --transpileOnly ./src/index.ts", + "build": "tsc --resolveJsonModule", + "test": "ts-node-dev src/test.ts", + "lint": "tslint -c tslint.json -p tsconfig.json" + }, + "author": "", + "license": "ISC", + "dependencies": { + "cors": "^2.8.5", + "express": "^4.17.1", + "mysql": "^2.18.1", + "ts-node-dev": "^1.0.0-pre.44", + "uuid": "^7.0.3" + }, + "devDependencies": { + "@types/express": "^4.17.6", + "@types/mysql": "^2.1.4", + "typescript": "^3.8.3", + "tslint": "^5.18.0", + "tslint-config-airbnb": "^5.11.1" + } +} diff --git a/server/src/index.ts b/server/src/index.ts new file mode 100644 index 0000000..c1fcab2 --- /dev/null +++ b/server/src/index.ts @@ -0,0 +1,139 @@ +import express from 'express'; +import http from 'http'; +import cors from 'cors'; +import mysql from 'mysql'; +import { v1 } from 'uuid'; + +const port: number = 443; +const app: express.Express = express(); +const httpServer: http.Server = http.createServer(app); +const tournaments: Record = {}; +const players: Record = {}; +const connection = mysql.createPool({ + connectionLimit: 10, + host: 'test-db.csmrqtei38qi.ap-northeast-1.rds.amazonaws.com', + user: 'admin', + password: '12341234', + database: 'catherine_league' +}); +connection.query( + `SELECT id, tournament_key + FROM tournaments`, + (error: mysql.MysqlError | null, results: any) => { + if (error) { + return; + } + if (results.length > 0) { + results.forEach((result: any) => { + tournaments[result.tournament_key] = result.id; + }); + } + } +); +connection.query( + `SELECT id, player_key FROM players;`, + (error: mysql.MysqlError | null, results: any) => { + if (error) { + console.log(error); + return; + } + if (results.length > 0) { + results.forEach((result: any) => { + players[result.player_key] = result.id; + }); + } + } +); +if (process.env.NODE_ENV === 'development') { + app.use(cors()); + app.options('*', cors()); +} + +app.get('/api/players/:key', (req: any, res: any) => { + if (req.params && req.params.key && tournaments[req.params.key]) { + const sqlToPrepare = `SELECT p.id, p.player_key, p.player_name,p.description,p.image,c.name_id, c.name, c.name_jp + FROM players p + JOIN player_to_tournament ptt + on p.id = ptt.player_id + JOIN characters c + on c.id = p.character_id + where ptt.tournament_id = ?`; + const sql = mysql.format(sqlToPrepare, [tournaments[req.params.key]]); + connection.query(sql, + (error: mysql.MysqlError | null, results: any) => { + if (error) { + console.error(error); + // players not found + } else { + res.send(results); + } + } + ); + } else { + // send error + } +}); +app.get('/api/players', (req: any, res: any) => { + connection.query( + `SELECT p.id, p.player_key, p.player_name,p.description,p.image,c.name_id, c.name, c.name_jp + FROM players p + JOIN characters c + on c.id = p.character_id`, + (error: mysql.MysqlError | null, results: any) => { + if (error) { + console.log(error); + // players not found + } else { + res.send(results); + } + } + ); +}); +app.get('/api/guide', (req: any, res: any) => { + connection.query( + `SELECT * + FROM guide`, + (error: mysql.MysqlError | null, results: any) => { + if (error) { + console.log(error); + res.send([]); + } else { + res.send(results); + } + } + ); +}); +app.get('/api/archive', (req: any, res: any) => { + connection.query( + `SELECT * + FROM archive`, + (error: mysql.MysqlError | null, results: any) => { + if (error) { + console.log(error); + res.send([]); + } else { + res.send(results); + } + } + ); +}); +app.get('/api/contact', (req: any, res: any) => { + connection.query( + `SELECT * + FROM contact`, + (error: mysql.MysqlError | null, results: any) => { + if (error) { + console.log(error); + res.send([]); + } else { + res.send(results); + } + } + ); +}); + +app.use(express.static('client')); + +httpServer.listen(port, () => { + console.log(`listening to port ${port}`); +}); diff --git a/server/src/models/index.ts b/server/src/models/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/server/src/test.ts b/server/src/test.ts new file mode 100644 index 0000000..e69de29 diff --git a/server/tsconfig.json b/server/tsconfig.json new file mode 100644 index 0000000..359fae8 --- /dev/null +++ b/server/tsconfig.json @@ -0,0 +1,24 @@ +{ + "version": "1.5.1", + "compilerOptions": { + "target": "es2019", + "module": "commonjs", + "allowJs": true, + "declaration": false, + "declarationMap": false, + "outDir": "build", + "noImplicitAny": false, + "removeComments": true, + "noLib": false, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "sourceMap": true, + "strict": true, + "alwaysStrict": true, + "esModuleInterop": true, + "moduleResolution": "node" + }, + "include": [ + "src" + ] +} diff --git a/server/tslint.json b/server/tslint.json new file mode 100644 index 0000000..14710c9 --- /dev/null +++ b/server/tslint.json @@ -0,0 +1,37 @@ +{ + "defaultSeverity": "error", + "extends": [ + "tslint:recommended", + "tslint-config-airbnb" + ], + "jsRules": {}, + "rules": { + "curly": [true, "ignore-same-line"], + "typedef": [ + true, + "call-signature", + "arrow-call-signature", + "parameter", + "arrow-parameter", + "member-variable-declaration", + "property-declaration" + ], + "no-any": false, + "quotemark": [true, "single"], + "trailing-comma": false, + "max-line-length": false, + "ordered-imports": false, + "object-literal-sort-keys": false, + "member-ordering": false, + "no-console": false, + "align": false, + "no-default-export": true + }, + "rulesDirectory": [], + "linterOptions": { + "exclude": [ + "src/lib/**/*", + "**/*.js" + ] + } +}