Skip to content

Commit

Permalink
Merge branch 'develop' into feature/item-groups
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/engine/config/item-config.ts
  • Loading branch information
Promises committed Nov 22, 2022
2 parents fc31042 + f8bc7bf commit 9ba6abd
Show file tree
Hide file tree
Showing 126 changed files with 17,289 additions and 6,051 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@babel/preset-typescript",
[ "@babel/preset-env", {
"targets": {
"node": "14"
"node": "16"
},
"modules": "commonjs"
} ]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ jobs:
- name: Run Linter
run: npm run lint

- name: Run Typecheck
run: npm run typecheck

- name: Build Project
run: npm run build
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ yarn-error.log*

# Editor directories.ts and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/.vs

/coverage/
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.tabSize": 4,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true
}
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,44 @@ We do have a few coding styles and lint rules we'd like all contributors to adhe
- Use TypeScript getters/setters instead of specific getter/setter methods
- `public get myVar(): number` instead of `public getMyVar(): number`
- `public set myVar(myVar: number)` instead of `public setMyVar(myVar: number)`

## Testing

Unit tests can be written using Jest. To execute the test suite, run `npm test`

- Test files should be located next to the file under test, and called `file-name.test.ts`
- Tests should use the `when / then` pattern made up of composable `describe` statements
- Make use of `beforeEach` to set up state before each test

After running the tests, you can find code coverage in the `./coverage/` folder.

### When / Then testing pattern

Tests should be broken down into a series of `describe` statements, which set up their own internal state when possible.

```ts
describe('when there is a player', () => {
let player: Player

beforeEach(() => {
player = createMockPlayer()
})

describe('when player is wearing a hat', () => {
beforeEach(() => {
player.equipment().set(0, someHatItem)
})

test('should return true', () => {
const result = isWearingHat(player)

expect(result).toEqual(true)
})
})
})
```

There are two main benefits to this kind of design:

- 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
- 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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14
FROM node:16
WORKDIR /usr/src/app
COPY package.json ./
COPY package-lock.json ./
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
![RuneJS](https://i.imgur.com/pmkdSfc.png)
[![RuneJS Discord Server](https://img.shields.io/discord/678751302297059336?label=RuneJS%20Discord&logo=discord)](https://discord.gg/5P74nSh)

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

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

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

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

**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!**

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

## Setup

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

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

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

## Additional Commands
* `npm run start:game` Launches the game server by itself without building
* `npm run start:game:dev` Builds and launches the game server by itself in watch mode
* `npm run start:login` Launches the login server by itself without building
* `npm run start:update` Launches the update server by itself without building
* `npm run start:infra` Launches both the login and update server without building
* `npm run start:standalone` Launches all three servers concurrently without building
* `npm run game` Launches the game server by itself without building
* `npm run game:dev` Builds and launches the game server by itself in watch mode
* `npm run login` Launches the login server by itself without building
* `npm run update` Launches the update server by itself without building
* `npm run infra` Launches both the login and update server without building
* `npm run standalone` Launches all three servers concurrently without building
* `npm run build:watch` Builds the application and watches for changes
* `npm run build` Builds the application
* `npm run lint` Runs the linter against the codebase to look for code style issues
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: "3.8"

services:
rune-js-server:
image: node:14
container_name: server
runejs_game_server:
image: node:16
container_name: runejs_game_server
ports:
- "43594:43594"
volumes:
Expand All @@ -13,4 +13,4 @@ services:

networks:
default:
name: rune_js_network
name: runejs_network
194 changes: 194 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

export default {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "C:\\Users\\james\\AppData\\Local\\Temp\\jest",

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],

// Indicates which provider should be used to instrument code for coverage
// coverageProvider: "babel",

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// The default configuration for fake timers
// fakeTimers: {
// "enableGlobally": false
// },

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// 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.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "mjs",
// "cjs",
// "jsx",
// "ts",
// "tsx",
// "json",
// "node"
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: undefined,

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state before every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state and implementation before every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
// testEnvironment: "jest-environment-node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: [
"**/*.test.ts"
],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "\\\\node_modules\\\\",
// "\\.pnp\\.[^\\\\]+$"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
Loading

0 comments on commit 9ba6abd

Please sign in to comment.