Browse Source

Initial Commit

master
Dale 1 year ago
commit
e979c91cc7
Signed by: Deiru GPG Key ID: AA250C0277B927E1
  1. 23
      .gitignore
  2. 50
      README.md
  3. 46
      package.json
  4. BIN
      public/favicon.ico
  5. 43
      public/index.html
  6. BIN
      public/logo192.png
  7. BIN
      public/logo512.png
  8. 25
      public/manifest.json
  9. 3
      public/robots.txt
  10. 29
      src/config.ts
  11. 4
      src/declarations.d.ts
  12. 55
      src/game.ts
  13. 22
      src/index.tsx
  14. 1
      src/react-app-env.d.ts
  15. 13
      src/skills.ts
  16. 42
      src/store.ts
  17. 25
      tsconfig.json
  18. 11177
      yarn.lock

23
.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*

50
README.md

@ -0,0 +1,50 @@
# Discoteque Seed
This is an example seed project that you can use to kickstart your game.
It contains sample started project as described in [Discoteque](https://code.gensokyo.social/Gensokyo.social/discoteque) readme.
# Create React App README
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `yarn start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `yarn test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `yarn build`
Builds the app for production to the `build` folder.<br />
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.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn 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/).

46
package.json

@ -0,0 +1,46 @@
{
"name": "disco-test",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"discoteque": "^1.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.1",
"react-scripts": "3.4.3",
"react-toastify": "^6.0.8",
"redux": "^4.0.5",
"typescript": "~3.7.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
},
"devDependencies": {
"@types/react-redux": "^7.1.9"
}
}

BIN
public/favicon.ico

43
public/index.html

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

BIN
public/logo192.png

After

Width: 192  |  Height: 192  |  Size: 5.2 KiB

BIN
public/logo512.png

After

Width: 512  |  Height: 512  |  Size: 9.4 KiB

25
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"
}

3
public/robots.txt

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

29
src/config.ts

@ -0,0 +1,29 @@
import { EngineConfig } from "discoteque/lib/engine/types";
import { IGameState, reducer } from "./store";
import skills, { GameSkills, skillDescriptions } from "./skills";
import { nodes, actors, locations } from "./game";
const config: EngineConfig<IGameState, undefined, GameSkills> = {
// Pass the initial skills
skills: skills,
// Define how many points player can spend on start
skillPointsOnStart: 3,
// Define starting node
startNode: 'loc_discoville',
// Define time object
chrono: {
time: 750,
},
// Give skills some desctiptions
skillDescriptoins: skillDescriptions,
// Provide game's reducer
reducer: reducer,
// Supply the actual script (nodes)
nodes: [
...nodes,
...actors,
...locations,
],
};
export default config;

4
src/declarations.d.ts

@ -0,0 +1,4 @@
declare module "*.woff2" {
const font: string;
export default font;
}

55
src/game.ts

@ -0,0 +1,55 @@
import { INode, IActor, ILocation } from 'discoteque/lib/engine/types';
import { setState } from 'discoteque/lib/engine/lib/store';
import { IGameState, setCheck } from './store';
import { awardSkill, toast } from 'discoteque/lib/engine/lib/utils';
// Create Nodes
export const nodes: INode<IGameState>[] = [
{ id: 'beginning', kind: 'node', next: 'choice', lines: [
{ actorId: 'char_exampler', text: 'Hi! This is an example of Discoteque!' },
{ actorId: 'char_exampler', text: 'Let\'s try picking options' },
] },
{ id: 'choice', kind: 'node', next: 'choice', lines: [
// Make player pick an answer
{ text: 'Your choice?', options: [
// This answer is gated behind a skill check (dice throw)
{ text: 'Let\'s test a skill', value: 'test_success', skill: { name: 'test', difficulty: 15, failTo: 'test_fail' } },
{ text: 'Let me out!', value: 'exit' },
] }
] },
{ id: 'test_success', kind: 'node', next: 'choice', lines: [
(_, { myCheck }, dispatch) => {
if (!myCheck) {
dispatch(setCheck(true))
return { actorId: 'char_exampler', text: "Yay! You passed a check!" }
} else {
return { text: 'You think you\'ve already passed this check, so no need to do it again' }
}
},
]},
{ id: 'test_fail', kind: 'node', next: 'choice', lines: [
({ skillPoints }, _, dispatch) => {
awardSkill(dispatch, skillPoints);
return { actorId: 'char_exampler', text: 'You\'ve failed... Not a problem! Take a skill point and I\'ll give another if you fail again!' };
}
] },
{ id: 'exit', kind: 'node', next: 'choice', lines: [
(_, _gameState, dispatch) => {
dispatch(setState({ ui: { isOver: true } }));
return { actorId: 'char_exampler' , text: 'Bye-bye!' };
},
] }
];
// Create actors
export const actors: IActor<IGameState>[] = [
{ id: 'char_exampler', kind: 'actor', name: 'Exampler!', lines: [] },
];
// Create locations
export const locations: ILocation<IGameState>[] = [
{ id: 'loc_discoville', kind: 'location', name: 'Discoville!', next: 'beginning', lines: [
{ text: 'It\'s a beautiful day at Discoville today!' },
{ text: 'A friendly feller is approaching you.' }
] },
];

22
src/index.tsx

@ -0,0 +1,22 @@
import makeApp from 'discoteque/lib';
import { injectGlobal } from 'emotion';
import config from './config';
import 'react-toastify/dist/ReactToastify.css';
// Set up default font
import font from "discoteque/src/assets/fonts/AnticSlab-Regular.woff2";
injectGlobal`
@font-face {
font-family: 'Antic Slab Regular';
src: url(${font}) format('woff2');
}
body {
font-family: 'Antic Slab Regular';
}
`;
// Import your config file
// Make an app. Mounting onto DOM is already handled by App.
makeApp(config);

1
src/react-app-env.d.ts

@ -0,0 +1 @@
/// <reference types="react-scripts" />

13
src/skills.ts

@ -0,0 +1,13 @@
import { SkillSet } from "discoteque/lib/engine/types";
export type GameSkills = 'test';
export const skills: SkillSet<GameSkills> = {
test: 5,
};
export const skillDescriptions: Record<GameSkills, string> = {
test: 'This is a test skill',
}
export default skills;

42
src/store.ts

@ -0,0 +1,42 @@
import { createStore, Action } from 'redux';
import { resetGame } from 'discoteque/lib/engine/lib/utils';
export interface IGameState {
myCheck: boolean;
}
const defaultState: IGameState = {
myCheck: false,
};
type ACTION = 'INIT' | 'set-check';
interface IGameAction extends Action {
type: ACTION;
}
interface ISetCheckAction extends IGameAction {
check: boolean;
}
interface InitAction extends IGameAction {
data: { gameState: IGameState };
}
export const setCheck = (check: boolean): ISetCheckAction => ({
type: 'set-check', check,
});
export const reducer = (state: IGameState = defaultState, action: IGameAction): IGameState => {
switch (action.type) {
case 'set-check':
const checkAction = action as ISetCheckAction;
return ({ ...state, myCheck: checkAction.check });
case 'INIT':
const initAction = action as InitAction;
return resetGame(state, initAction);
default:
return state;
}
}
export default createStore(reducer);

25
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"
]
}

11177
yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save