-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(example game): adding client and server folders for psychic
- Loading branch information
Showing
20 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# psychic-client | ||
|
||
## Overview | ||
|
||
The psychic client is an example of the @haste-sdk/client package. It utilizes the haste arcade api to demonstrate how to leverge a shared leaderboard and secure ILP interactions. | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md) for an overview of the haste-sdk repository. | ||
|
||
<Add deploy badge here> | ||
|
||
## Table of Contents | ||
|
||
- [Background and Use Case](#background) | ||
- [Setup](#setup) | ||
- [Usage](#usage) | ||
- [Deploy](#deploy) | ||
- [Documentation](#documentation) | ||
- [License](#license) | ||
- [Contributing](#contributing) | ||
- [Authors](#authors) | ||
|
||
## Background | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md#Background) for a detailed background. | ||
|
||
## Setup | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md#Setup) for a detailed setup guide. | ||
|
||
## Usage | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md#Usage) for a detailed usage guide. | ||
|
||
### Testing | ||
|
||
@haste-sdk/psychic-client utilizes Jest for running tests. To run all tests in the psychic-client package use the following command | ||
|
||
`npm run test` | ||
|
||
## Documentation | ||
|
||
Currently there is no documentation setup, but please check back in the future. | ||
|
||
## License | ||
|
||
haste-sdk is currently licensed under [MIT](https://github.com/playhaste/haste-sdk/blob/main/LICENSE) | ||
|
||
## Contributing | ||
|
||
Please read our contribution [policy](https://github.com/playhaste/haste-sdk/blob/main/CONTRIBUTING.md). | ||
|
||
## Authors | ||
|
||
- Keith LaForce ([klaforce](https://github.com/klaforce/)) | ||
- Eric LaForce ([elaforc](https://github.com/elaforc/)) | ||
- Dan Wagner ([danwag06](https://github.com/danwag06)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/src'], | ||
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'], | ||
transform: { | ||
'^.+\\.(ts|tsx)$': 'ts-jest', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@haste-sdk/psychic-client", | ||
"version": "0.0.0", | ||
"description": "The psychic client is an example of the @haste-sdk/client package. It utilizes the haste arcade api to demonstrate how to leverge a shared leaderboard and secure ILP interactions.", | ||
"contributors": [ | ||
"Keith LaForce <keith@playhaste.com>", | ||
"Eric LaForce <eric@playhaste.com>", | ||
"Dan Wagner <dan@playhaste.com>" | ||
], | ||
"homepage": "https://playhaste.com", | ||
"license": "MIT", | ||
"main": "dist/index", | ||
"types": "dist/index", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/playhaste/haste-sdk.git" | ||
}, | ||
"scripts": { | ||
"build": "rimraf dist && tsc -p tsconfig.build.json", | ||
"clean": "rimraf -rf ./dist ./coverage", | ||
"test": "jest --coverage=true", | ||
"lint": "eslint src --ext .ts", | ||
"pretty": "prettier --write \"src/**/*.ts\"" | ||
}, | ||
"lint-staged": { | ||
"*.ts": "eslint src --ext .ts --fix" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/playhaste/haste-sdk/issues" | ||
}, | ||
"dependencies": { | ||
"@haste-sdk/domain": "0.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.22", | ||
"@types/node": "^14.14.37", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"eslint": "^7.23.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-config-standard": "^16.0.2", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.3.3", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-promise": "^4.3.1", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.4", | ||
"prettier": "^2.2.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^4.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Game, Player, Score } from '@haste-sdk/domain'; | ||
import { getHighScore } from '../..'; | ||
|
||
const game = new Game('testgame'); | ||
|
||
const initializeTestGame = () => { | ||
game.addLeader(new Player('test@gmail.com'), new Score(0)); | ||
game.addLeader(new Player('test@gmail1.com'), new Score(1)); | ||
game.addLeader(new Player('test@gmail2.com'), new Score(2)); | ||
game.addLeader(new Player('test@gmail3.com'), new Score(3)); | ||
game.addLeader(new Player('test@gmail4.com'), new Score(4)); | ||
}; | ||
|
||
beforeEach(() => { | ||
initializeTestGame(); | ||
}); | ||
|
||
test('getHighScore', () => { | ||
expect(getHighScore(game)).toBe(4); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Game } from '@haste-sdk/domain'; | ||
|
||
export function getHighScore(game: Game): number { | ||
if (game.name === 'test') { | ||
return 32; | ||
} | ||
const scores = game.getScores().map((g) => g.score.getScore()); | ||
return Math.max(...scores); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { getHighScore } from './game'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './game'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# psychic-server | ||
|
||
## Overview | ||
|
||
The psychic server is an example of the @haste-sdk/server package. It utilizes the haste arcade api to demonstrate how to leverge a shared leaderboard and payouts. | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md) for an overview of the haste-sdk repository. | ||
|
||
<Add deploy badge here> | ||
|
||
## Table of Contents | ||
|
||
- [Background and Use Case](#background) | ||
- [Setup](#setup) | ||
- [Usage](#usage) | ||
- [Deploy](#deploy) | ||
- [Documentation](#documentation) | ||
- [License](#license) | ||
- [Contributing](#contributing) | ||
- [Authors](#authors) | ||
|
||
## Background | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md#Background) for a detailed background. | ||
|
||
## Setup | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md#Setup) for a detailed setup guide. | ||
|
||
## Usage | ||
|
||
See [here](https://github.com/playhaste/haste-sdk/blob/main/README.md#Usage) for a detailed usage guide. | ||
|
||
### Testing | ||
|
||
@haste-sdk/psychic-server utilizes Jest for running tests. To run all tests in the psychic-server package use the following command | ||
|
||
`npm run test` | ||
|
||
## Documentation | ||
|
||
Currently there is no documentation setup, but please check back in the future. | ||
|
||
## License | ||
|
||
haste-sdk is currently licensed under [MIT](https://github.com/playhaste/haste-sdk/blob/main/LICENSE) | ||
|
||
## Contributing | ||
|
||
Please read our contribution [policy](https://github.com/playhaste/haste-sdk/blob/main/CONTRIBUTING.md). | ||
|
||
## Authors | ||
|
||
- Keith LaForce ([klaforce](https://github.com/klaforce/)) | ||
- Eric LaForce ([elaforc](https://github.com/elaforc/)) | ||
- Dan Wagner ([danwag06](https://github.com/danwag06)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/src'], | ||
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'], | ||
transform: { | ||
'^.+\\.(ts|tsx)$': 'ts-jest', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@haste-sdk/psychic-server", | ||
"version": "0.0.0", | ||
"description": "The psychic server is an example of the @haste-sdk/server package. It utilizes the haste arcade api to demonstrate how to leverge a shared leaderboard and payouts.", | ||
"contributors": [ | ||
"Keith LaForce <keith@playhaste.com>", | ||
"Eric LaForce <eric@playhaste.com>", | ||
"Dan Wagner <dan@playhaste.com>" | ||
], | ||
"homepage": "https://playhaste.com", | ||
"license": "MIT", | ||
"main": "dist/index", | ||
"types": "dist/index", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/playhaste/haste-sdk.git" | ||
}, | ||
"scripts": { | ||
"build": "rimraf dist && tsc -p tsconfig.build.json", | ||
"clean": "rimraf -rf ./dist ./coverage", | ||
"test": "jest --coverage=true", | ||
"lint": "eslint src --ext .ts", | ||
"pretty": "prettier --write \"src/**/*.ts\"" | ||
}, | ||
"lint-staged": { | ||
"*.ts": "eslint src --ext .ts --fix" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/playhaste/haste-sdk/issues" | ||
}, | ||
"dependencies": { | ||
"@haste-sdk/domain": "0.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.22", | ||
"@types/node": "^14.14.37", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"eslint": "^7.23.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-config-standard": "^16.0.2", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.3.3", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-promise": "^4.3.1", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.4", | ||
"prettier": "^2.2.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^4.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Game, Player, Score } from '@haste-sdk/domain'; | ||
import { getHighScore } from '../..'; | ||
|
||
const game = new Game('testgame'); | ||
|
||
const initializeTestGame = () => { | ||
game.addLeader(new Player('test@gmail.com'), new Score(0)); | ||
game.addLeader(new Player('test@gmail1.com'), new Score(1)); | ||
game.addLeader(new Player('test@gmail2.com'), new Score(2)); | ||
game.addLeader(new Player('test@gmail3.com'), new Score(3)); | ||
game.addLeader(new Player('test@gmail4.com'), new Score(4)); | ||
}; | ||
|
||
beforeEach(() => { | ||
initializeTestGame(); | ||
}); | ||
|
||
test('getHighScore', () => { | ||
expect(getHighScore(game)).toBe(4); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Game } from '@haste-sdk/domain'; | ||
|
||
export function getHighScore(game: Game): number { | ||
if (game.name === 'test') { | ||
return 32; | ||
} | ||
const scores = game.getScores().map((g) => g.score.getScore()); | ||
return Math.max(...scores); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { getHighScore } from './game'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './game'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json" | ||
} |