Skip to content

Commit 9ba6abd

Browse files
committed
Merge branch 'develop' into feature/item-groups
# Conflicts: # src/engine/config/item-config.ts
2 parents fc31042 + f8bc7bf commit 9ba6abd

File tree

126 files changed

+17289
-6051
lines changed

Some content is hidden

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

126 files changed

+17289
-6051
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"@babel/preset-typescript",
55
[ "@babel/preset-env", {
66
"targets": {
7-
"node": "14"
7+
"node": "16"
88
},
99
"modules": "commonjs"
1010
} ]

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ jobs:
2525
- name: Run Linter
2626
run: npm run lint
2727

28+
- name: Run Typecheck
29+
run: npm run typecheck
30+
2831
- name: Build Project
2932
run: npm run build

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ yarn-error.log*
1818

1919
# Editor directories.ts and files
2020
.idea
21-
.vscode
2221
*.suo
2322
*.ntvs*
2423
*.njsproj
2524
*.sln
2625
*.sw?
2726
/.vs
27+
28+
/coverage/

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"editor.tabSize": 4,
3+
"files.trimTrailingWhitespace": true,
4+
"files.trimFinalNewlines": true,
5+
"files.insertFinalNewline": true
6+
}

CONTRIBUTING.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,44 @@ We do have a few coding styles and lint rules we'd like all contributors to adhe
3535
- Use TypeScript getters/setters instead of specific getter/setter methods
3636
- `public get myVar(): number` instead of `public getMyVar(): number`
3737
- `public set myVar(myVar: number)` instead of `public setMyVar(myVar: number)`
38+
39+
## Testing
40+
41+
Unit tests can be written using Jest. To execute the test suite, run `npm test`
42+
43+
- Test files should be located next to the file under test, and called `file-name.test.ts`
44+
- Tests should use the `when / then` pattern made up of composable `describe` statements
45+
- Make use of `beforeEach` to set up state before each test
46+
47+
After running the tests, you can find code coverage in the `./coverage/` folder.
48+
49+
### When / Then testing pattern
50+
51+
Tests should be broken down into a series of `describe` statements, which set up their own internal state when possible.
52+
53+
```ts
54+
describe('when there is a player', () => {
55+
let player: Player
56+
57+
beforeEach(() => {
58+
player = createMockPlayer()
59+
})
60+
61+
describe('when player is wearing a hat', () => {
62+
beforeEach(() => {
63+
player.equipment().set(0, someHatItem)
64+
})
65+
66+
test('should return true', () => {
67+
const result = isWearingHat(player)
68+
69+
expect(result).toEqual(true)
70+
})
71+
})
72+
})
73+
```
74+
75+
There are two main benefits to this kind of design:
76+
77+
- It serves as living documentation: from reading the `beforeEach` block you can clearly see how the prerequisite of "player is wearing a hat" is achieved
78+
- It allows for easy expansion of test cases: future developers can add further statements inside "when player is wearing a hat" if they want to make use of that setup

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:14
1+
FROM node:16
22
WORKDIR /usr/src/app
33
COPY package.json ./
44
COPY package-lock.json ./

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
![RuneJS](https://i.imgur.com/pmkdSfc.png)
1+
[![RuneJS Discord Server](https://img.shields.io/discord/678751302297059336?label=RuneJS%20Discord&logo=discord)](https://discord.gg/5P74nSh)
22

3-
# RuneJS
3+
[![RuneJS](https://i.imgur.com/QSXNzwC.png)](https://github.com/runejs/)
44

5-
[![RuneJS Discord Server](https://img.shields.io/discord/678751302297059336?label=RuneJS%20Discord&logo=discord)](https://discord.gg/5P74nSh)
5+
# RuneJS Game Server
66

7-
RuneJS is a RuneScape game server written entirely using TypeScript and JavaScript. The aim of this project is to create a game server that is both fun and easy to use, while also providing simple content development systems.
7+
RuneJS is a RuneScape game server written in TypeScript and JavaScript. The aim of this project is to create a game server that is both fun and easy to use, while also providing simple content development systems.
88

9-
The server runs on the 435 revision of the game, which was a game update made on October 31st, 2006. There are not any plans to convert it to other versions at this time.
9+
The game server currently runs a build of RuneScape from October 30th-31st, 2006 (game build #435). No other builds are supported at this time, but may become available in the future.
1010

1111
**RuneJS is completely open-source and open to all pull requests and/or issues. Many plugins have been added by contributor pull requests and we're always happy to have more!**
1212

1313
![RuneJS Lumbridge](https://i.imgur.com/KVCqKSb.png)
1414

1515
## Setup
1616

17-
1. Download and install NodeJS **version 14 or higher**: https://nodejs.org/en/
17+
1. Download and install NodeJS **version 16 or higher**: https://nodejs.org/en/
1818
2. Clone the Github Repo: https://github.com/runejs/server
1919
3. Install dependencies by navigating to the project in your Terminal or command prompt and running the command npm install
20-
4. Copy the `data/config/server-config.example.yaml` and paste it into the same folder using the name `server-config.yaml`
21-
5. Go into your new `server-config.yaml` file and modify your RSA modulus and exponent with the ones matching your game client
20+
4. Copy the `config/server-config.example.json` and paste it into the same folder using the name `server-config.json`
21+
5. *Optional:* Go into the new `server-config.json` file and modify the RSA modulus and exponent with the ones matching your desired game client
2222
- You may also modify the server's port and host address from this configuration file
2323
6. Run the game server with `npm start`
2424

@@ -27,8 +27,8 @@ The game server will spin up and be accessible via port 43594.
2727
### Setup using docker
2828

2929
1. Download and install Docker and Docker Compose: first https://docs.docker.com/get-docker/ then https://docs.docker.com/compose/install/
30-
2. Copy the `config/server-config.example.yaml` and paste it into the same folder using the name `server-config.yaml`
31-
3. Go into your new `server-config.yaml` file and modify your RSA modulus and exponent with the ones matching your game client
30+
2. Copy the `config/server-config.example.json` and paste it into the same folder using the name `server-config.json`
31+
3. Go into your new `server-config.json` file and modify your RSA modulus and exponent with the ones matching your game client
3232
- You may also modify the server's port and host address from this configuration file
3333
4. Build the docker image with `docker-compose build`
3434
5. Run the game server with `docker-compose up'
@@ -40,12 +40,12 @@ The game server will spin up and be accessible via port 43594.
4040
The [RuneScape Java Client #435](https://github.com/runejs/refactored-client-435) must be used to log into a RuneJS game server.
4141

4242
## Additional Commands
43-
* `npm run start:game` Launches the game server by itself without building
44-
* `npm run start:game:dev` Builds and launches the game server by itself in watch mode
45-
* `npm run start:login` Launches the login server by itself without building
46-
* `npm run start:update` Launches the update server by itself without building
47-
* `npm run start:infra` Launches both the login and update server without building
48-
* `npm run start:standalone` Launches all three servers concurrently without building
43+
* `npm run game` Launches the game server by itself without building
44+
* `npm run game:dev` Builds and launches the game server by itself in watch mode
45+
* `npm run login` Launches the login server by itself without building
46+
* `npm run update` Launches the update server by itself without building
47+
* `npm run infra` Launches both the login and update server without building
48+
* `npm run standalone` Launches all three servers concurrently without building
4949
* `npm run build:watch` Builds the application and watches for changes
5050
* `npm run build` Builds the application
5151
* `npm run lint` Runs the linter against the codebase to look for code style issues

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
version: "3.8"
22

33
services:
4-
rune-js-server:
5-
image: node:14
6-
container_name: server
4+
runejs_game_server:
5+
image: node:16
6+
container_name: runejs_game_server
77
ports:
88
- "43594:43594"
99
volumes:
@@ -13,4 +13,4 @@ services:
1313

1414
networks:
1515
default:
16-
name: rune_js_network
16+
name: runejs_network

jest.config.ts

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property and type check, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
export default {
7+
// All imported modules in your tests should be mocked automatically
8+
// automock: false,
9+
10+
// Stop running tests after `n` failures
11+
// bail: 0,
12+
13+
// The directory where Jest should store its cached dependency information
14+
// cacheDirectory: "C:\\Users\\james\\AppData\\Local\\Temp\\jest",
15+
16+
// Automatically clear mock calls, instances, contexts and results before every test
17+
clearMocks: true,
18+
19+
// Indicates whether the coverage information should be collected while executing the test
20+
collectCoverage: true,
21+
22+
// An array of glob patterns indicating a set of files for which coverage information should be collected
23+
// collectCoverageFrom: undefined,
24+
25+
// The directory where Jest should output its coverage files
26+
coverageDirectory: "coverage",
27+
28+
// An array of regexp pattern strings used to skip coverage collection
29+
// coveragePathIgnorePatterns: [
30+
// "\\\\node_modules\\\\"
31+
// ],
32+
33+
// Indicates which provider should be used to instrument code for coverage
34+
// coverageProvider: "babel",
35+
36+
// A list of reporter names that Jest uses when writing coverage reports
37+
// coverageReporters: [
38+
// "json",
39+
// "text",
40+
// "lcov",
41+
// "clover"
42+
// ],
43+
44+
// An object that configures minimum threshold enforcement for coverage results
45+
// coverageThreshold: undefined,
46+
47+
// A path to a custom dependency extractor
48+
// dependencyExtractor: undefined,
49+
50+
// Make calling deprecated APIs throw helpful error messages
51+
// errorOnDeprecated: false,
52+
53+
// The default configuration for fake timers
54+
// fakeTimers: {
55+
// "enableGlobally": false
56+
// },
57+
58+
// Force coverage collection from ignored files using an array of glob patterns
59+
// forceCoverageMatch: [],
60+
61+
// A path to a module which exports an async function that is triggered once before all test suites
62+
// globalSetup: undefined,
63+
64+
// A path to a module which exports an async function that is triggered once after all test suites
65+
// globalTeardown: undefined,
66+
67+
// A set of global variables that need to be available in all test environments
68+
// globals: {},
69+
70+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71+
// maxWorkers: "50%",
72+
73+
// An array of directory names to be searched recursively up from the requiring module's location
74+
// moduleDirectories: [
75+
// "node_modules"
76+
// ],
77+
78+
// An array of file extensions your modules use
79+
// moduleFileExtensions: [
80+
// "js",
81+
// "mjs",
82+
// "cjs",
83+
// "jsx",
84+
// "ts",
85+
// "tsx",
86+
// "json",
87+
// "node"
88+
// ],
89+
90+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
91+
// moduleNameMapper: {},
92+
93+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
94+
// modulePathIgnorePatterns: [],
95+
96+
// Activates notifications for test results
97+
// notify: false,
98+
99+
// An enum that specifies notification mode. Requires { notify: true }
100+
// notifyMode: "failure-change",
101+
102+
// A preset that is used as a base for Jest's configuration
103+
// preset: undefined,
104+
105+
// Run tests from one or more projects
106+
// projects: undefined,
107+
108+
// Use this configuration option to add custom reporters to Jest
109+
// reporters: undefined,
110+
111+
// Automatically reset mock state before every test
112+
// resetMocks: false,
113+
114+
// Reset the module registry before running each individual test
115+
// resetModules: false,
116+
117+
// A path to a custom resolver
118+
// resolver: undefined,
119+
120+
// Automatically restore mock state and implementation before every test
121+
// restoreMocks: false,
122+
123+
// The root directory that Jest should scan for tests and modules within
124+
// rootDir: undefined,
125+
126+
// A list of paths to directories that Jest should use to search for files in
127+
// roots: [
128+
// "<rootDir>"
129+
// ],
130+
131+
// Allows you to use a custom runner instead of Jest's default test runner
132+
// runner: "jest-runner",
133+
134+
// The paths to modules that run some code to configure or set up the testing environment before each test
135+
// setupFiles: [],
136+
137+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
138+
// setupFilesAfterEnv: [],
139+
140+
// The number of seconds after which a test is considered as slow and reported as such in the results.
141+
// slowTestThreshold: 5,
142+
143+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
144+
// snapshotSerializers: [],
145+
146+
// The test environment that will be used for testing
147+
// testEnvironment: "jest-environment-node",
148+
149+
// Options that will be passed to the testEnvironment
150+
// testEnvironmentOptions: {},
151+
152+
// Adds a location field to test results
153+
// testLocationInResults: false,
154+
155+
// The glob patterns Jest uses to detect test files
156+
testMatch: [
157+
"**/*.test.ts"
158+
],
159+
160+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
161+
// testPathIgnorePatterns: [
162+
// "\\\\node_modules\\\\"
163+
// ],
164+
165+
// The regexp pattern or array of patterns that Jest uses to detect test files
166+
// testRegex: [],
167+
168+
// This option allows the use of a custom results processor
169+
// testResultsProcessor: undefined,
170+
171+
// This option allows use of a custom test runner
172+
// testRunner: "jest-circus/runner",
173+
174+
// A map from regular expressions to paths to transformers
175+
// transform: undefined,
176+
177+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
178+
// transformIgnorePatterns: [
179+
// "\\\\node_modules\\\\",
180+
// "\\.pnp\\.[^\\\\]+$"
181+
// ],
182+
183+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
184+
// unmockedModulePathPatterns: undefined,
185+
186+
// Indicates whether each individual test should be reported during the run
187+
// verbose: undefined,
188+
189+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
190+
// watchPathIgnorePatterns: [],
191+
192+
// Whether to use watchman for file crawling
193+
// watchman: true,
194+
};

0 commit comments

Comments
 (0)