Skip to content

Commit 2336db9

Browse files
committed
Monster refactor + new games
1 parent 526e0aa commit 2336db9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+10124
-1440
lines changed

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16.12.0

.vscode/settings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{
2-
"typescript.tsdk": "node_modules\\typescript\\lib"
3-
}
1+
{
2+
"editor.formatOnSave": false
3+
}

LICENCE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Martin Rue
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# MancJS: Code Golf
2+
3+
A [code golf](https://en.wikipedia.org/wiki/Code_golf) game server for JavaScript.
4+
5+
## Running
6+
7+
+ Clone the repo
8+
+ Install dependencies via `npm install`
9+
+ Set the `CG_ADMIN` environment variable to secure access the the `/admin` page
10+
+ Start the server locally via `npm start`
11+
12+
## URLs
13+
14+
### /
15+
16+
The submission page where players can submit solutions to the current game. Players must enter an email address (used only to render gravatar images) and a team name.
17+
18+
### /admin
19+
20+
The admin page for creating new games. Stopped games prevent new submissions and allow players to view other player submissions.
21+
22+
#### Security
23+
24+
The admin page is protected with HTTP basic auth. The username is `admin` and the password is the value of the `CG_ADMIN` environment variable.
25+
26+
## Notes
27+
28+
Changing the title of the game on the admin page and starting the game again will clear current entries and begin a new game. All other modifications update the current game.
29+
30+
## Playing
31+
32+
#### Runtime
33+
34+
Node `v16.12.0` with no context and strict mode enforced.
35+
36+
#### Submissions
37+
38+
Players must write a script containing their solution. The solution must be a single synchronous function exported as the value of `module.exports`. The exported function will be called by the game server on each submission. Example:
39+
40+
```js
41+
const play = (input) => {
42+
return "your answer";
43+
};
44+
45+
module.exports = play;
46+
```
47+
48+
Players can submit updated solutions as often as they like on the submission page.
49+
50+
#### Rules
51+
52+
- Your solution must be a single synchronous function assigned to `module.exports`
53+
- Your code must run in strict mode – use node's `--use_strict` flag to test your script
54+
- All JavaScript language features available in Node.js `v16.12.0` are available, with game-specific exceptions
55+
- Scripts are timed-out and fail after 5 seconds of execution time
56+
- Comments, line breaks and whitespace **do not count** towards your score
57+
- The aim is to solve the problem with the shortest possible code (fewest "strokes")

jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

0 commit comments

Comments
 (0)