Fix linting
This commit is contained in:
parent
e5e928d99a
commit
e6376ad059
23 changed files with 33 additions and 58 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "declared-server",
|
"name": "declared-server",
|
||||||
"version": "0.0.15",
|
"version": "0.1.0",
|
||||||
"description": "Game server for decla.red",
|
"description": "Game server for decla.red",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "András Schmelczer <andras@schmelczer.dev> (https://schmelczer.dev/)",
|
"author": "András Schmelczer <andras@schmelczer.dev> (https://schmelczer.dev/)",
|
||||||
|
|
@ -29,20 +29,11 @@
|
||||||
"@types/minimist": "^1.2.0",
|
"@types/minimist": "^1.2.0",
|
||||||
"@types/node": "^14.11.2",
|
"@types/node": "^14.11.2",
|
||||||
"@types/socket.io": "^2.1.11",
|
"@types/socket.io": "^2.1.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
|
||||||
"@typescript-eslint/parser": "^3.9.1",
|
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"concurrently": "^5.3.0",
|
"concurrently": "^5.3.0",
|
||||||
"eslint": "^7.2.0",
|
|
||||||
"eslint-config-prettier": "^6.11.0",
|
|
||||||
"eslint-plugin-import": "^2.21.2",
|
|
||||||
"eslint-plugin-json-format": "^2.0.1",
|
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
|
||||||
"eslint-plugin-unused-imports": "^0.1.3",
|
|
||||||
"file-loader": "^6.1.0",
|
"file-loader": "^6.1.0",
|
||||||
"html-webpack-plugin": "^4.5.0",
|
"html-webpack-plugin": "^4.5.0",
|
||||||
"nodemon": "^2.0.4",
|
"nodemon": "^2.0.4",
|
||||||
"prettier": "^2.0.5",
|
|
||||||
"raw-loader": "^4.0.1",
|
"raw-loader": "^4.0.1",
|
||||||
"resolve-url-loader": "^3.1.1",
|
"resolve-url-loader": "^3.1.1",
|
||||||
"shared": "file:../shared",
|
"shared": "file:../shared",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Command, GameObject } from 'shared';
|
import { Command } from 'shared';
|
||||||
|
|
||||||
export class GeneratePointsCommand extends Command {
|
export class GeneratePointsCommand extends Command {
|
||||||
public constructor(public readonly decla: number, public readonly red: number) {
|
public constructor(public readonly decla: number, public readonly red: number) {
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ export class GameServer extends CommandReceiver {
|
||||||
private timeSinceLastPointUpdate = 0;
|
private timeSinceLastPointUpdate = 0;
|
||||||
|
|
||||||
private handlePhysics() {
|
private handlePhysics() {
|
||||||
let delta = this.deltaTimeCalculator.getNextDeltaTimeInSeconds();
|
const delta = this.deltaTimeCalculator.getNextDeltaTimeInSeconds();
|
||||||
if (delta > settings.targetPhysicsDeltaTimeInSeconds) {
|
if (delta > settings.targetPhysicsDeltaTimeInSeconds) {
|
||||||
this.deltaTimeCalculator.getNextDeltaTimeInSeconds(true);
|
this.deltaTimeCalculator.getNextDeltaTimeInSeconds(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export const interpolateAngles = (from: number, to: number, q: number) => {
|
export const interpolateAngles = (from: number, to: number, q: number) => {
|
||||||
const max = Math.PI * 2;
|
const max = Math.PI * 2;
|
||||||
const possibleDistance = (to - from) % max;
|
const possibleDistance = (to - from) % max;
|
||||||
const shortedDistance = ((2 * possibleDistance) % max) - possibleDistance;
|
const shorterDistance = ((2 * possibleDistance) % max) - possibleDistance;
|
||||||
return from + shortedDistance * q;
|
return from + shorterDistance * q;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import {
|
||||||
MoveActionCommand,
|
MoveActionCommand,
|
||||||
serializesTo,
|
serializesTo,
|
||||||
last,
|
last,
|
||||||
GameObject,
|
|
||||||
Circle,
|
Circle,
|
||||||
CharacterBase,
|
CharacterBase,
|
||||||
CharacterTeam,
|
CharacterTeam,
|
||||||
|
|
@ -370,10 +369,7 @@ export class CharacterPhysical extends CharacterBase implements DynamicPhysical
|
||||||
|
|
||||||
const sumForce = vec2.subtract(vec2.create(), leftFootGravity, movementForce);
|
const sumForce = vec2.subtract(vec2.create(), leftFootGravity, movementForce);
|
||||||
|
|
||||||
this.setDirection(
|
this.setDirection(vec2.length(sumForce) === 0 ? vec2.fromValues(0, -1) : sumForce);
|
||||||
vec2.length(sumForce) === 0 ? vec2.fromValues(0, -1) : sumForce,
|
|
||||||
deltaTimeInSeconds,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
const leftFootGravity = this.currentPlanet!.getForce(this.leftFoot.center);
|
const leftFootGravity = this.currentPlanet!.getForce(this.leftFoot.center);
|
||||||
const rightFootGravity = this.currentPlanet!.getForce(this.rightFoot.center);
|
const rightFootGravity = this.currentPlanet!.getForce(this.rightFoot.center);
|
||||||
|
|
@ -403,7 +399,7 @@ export class CharacterPhysical extends CharacterBase implements DynamicPhysical
|
||||||
if (vec2.length(gravity) <= 100) {
|
if (vec2.length(gravity) <= 100) {
|
||||||
this.currentPlanet = undefined;
|
this.currentPlanet = undefined;
|
||||||
}
|
}
|
||||||
this.setDirection(gravity, deltaTimeInSeconds);
|
this.setDirection(gravity);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.keepPosture(deltaTimeInSeconds);
|
this.keepPosture(deltaTimeInSeconds);
|
||||||
|
|
@ -414,7 +410,7 @@ export class CharacterPhysical extends CharacterBase implements DynamicPhysical
|
||||||
this.setPropertyUpdates(oldHead, oldLeftFoot, oldRightFoot, deltaTimeInSeconds);
|
this.setPropertyUpdates(oldHead, oldLeftFoot, oldRightFoot, deltaTimeInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private setDirection(direction: vec2, deltaTime: number) {
|
private setDirection(direction: vec2) {
|
||||||
this.direction = interpolateAngles(
|
this.direction = interpolateAngles(
|
||||||
this.direction,
|
this.direction,
|
||||||
Math.atan2(direction.y, direction.x) + Math.PI / 2,
|
Math.atan2(direction.y, direction.x) + Math.PI / 2,
|
||||||
|
|
@ -423,7 +419,7 @@ export class CharacterPhysical extends CharacterBase implements DynamicPhysical
|
||||||
}
|
}
|
||||||
|
|
||||||
private keepPosture(deltaTime: number) {
|
private keepPosture(deltaTime: number) {
|
||||||
let center = this.center;
|
const center = this.center;
|
||||||
this.springMove(
|
this.springMove(
|
||||||
this.leftFoot,
|
this.leftFoot,
|
||||||
center,
|
center,
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ export class CirclePhysical extends CommandReceiver implements Circle, DynamicPh
|
||||||
.filter((b) => b.gameObject !== this.gameObject && b.canCollide);
|
.filter((b) => b.gameObject !== this.gameObject && b.canCollide);
|
||||||
this.radius -= vec2.length(delta);
|
this.radius -= vec2.length(delta);
|
||||||
|
|
||||||
let { normal, hitSurface, hitObject } = moveCircle(this, delta, intersecting);
|
const { normal, hitSurface, hitObject } = moveCircle(this, delta, intersecting);
|
||||||
|
|
||||||
if (hitSurface) {
|
if (hitSurface) {
|
||||||
vec2.copy(this.lastNormal, normal!);
|
vec2.copy(this.lastNormal, normal!);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import {
|
||||||
settings,
|
settings,
|
||||||
serializesTo,
|
serializesTo,
|
||||||
ProjectileBase,
|
ProjectileBase,
|
||||||
GameObject,
|
|
||||||
CharacterTeam,
|
CharacterTeam,
|
||||||
PropertyUpdatesForObject,
|
PropertyUpdatesForObject,
|
||||||
UpdatePropertyCommand,
|
UpdatePropertyCommand,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { vec2 } from 'gl-matrix';
|
import { vec2 } from 'gl-matrix';
|
||||||
import { Circle, GameObject, rotate90Deg } from 'shared';
|
import { GameObject } from 'shared';
|
||||||
import { CirclePhysical } from '../../objects/circle-physical';
|
import { CirclePhysical } from '../../objects/circle-physical';
|
||||||
import { evaluateSdf } from './evaluate-sdf';
|
import { evaluateSdf } from './evaluate-sdf';
|
||||||
import { Physical } from '../physicals/physical';
|
import { Physical } from '../physicals/physical';
|
||||||
|
|
@ -23,7 +23,7 @@ export const moveCircle = (
|
||||||
|
|
||||||
const deltaLength = vec2.length(delta);
|
const deltaLength = vec2.length(delta);
|
||||||
let travelled = 0;
|
let travelled = 0;
|
||||||
let rayEnd = vec2.create();
|
const rayEnd = vec2.create();
|
||||||
let prevMinDistance = 0;
|
let prevMinDistance = 0;
|
||||||
while (travelled < deltaLength) {
|
while (travelled < deltaLength) {
|
||||||
travelled += prevMinDistance;
|
travelled += prevMinDistance;
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,9 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/socket.io-client": "^1.4.34",
|
"@types/socket.io-client": "^1.4.34",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
|
||||||
"@typescript-eslint/parser": "^3.9.1",
|
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"common-config-webpack-plugin": "^2.0.1",
|
"common-config-webpack-plugin": "^2.0.1",
|
||||||
"css-loader": "^1.0.1",
|
"css-loader": "^1.0.1",
|
||||||
"eslint": "^7.2.0",
|
|
||||||
"eslint-config-prettier": "^6.11.0",
|
|
||||||
"eslint-plugin-import": "^2.21.2",
|
|
||||||
"eslint-plugin-json-format": "^2.0.1",
|
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
|
||||||
"eslint-plugin-unused-imports": "^0.1.3",
|
|
||||||
"firebase": "^7.22.0",
|
"firebase": "^7.22.0",
|
||||||
"gl-matrix": "^3.3.0",
|
"gl-matrix": "^3.3.0",
|
||||||
"html-webpack-inline-source-plugin": "^1.0.0-beta.2",
|
"html-webpack-inline-source-plugin": "^1.0.0-beta.2",
|
||||||
|
|
@ -42,7 +34,6 @@
|
||||||
"image-config-webpack-plugin": "^2.0.0",
|
"image-config-webpack-plugin": "^2.0.0",
|
||||||
"mini-css-extract-plugin": "^0.9.0",
|
"mini-css-extract-plugin": "^0.9.0",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"prettier": "^2.0.5",
|
|
||||||
"resize-observer-polyfill": "^1.5.1",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"resolve-url-loader": "^3.1.1",
|
"resolve-url-loader": "^3.1.1",
|
||||||
"sass": "^1.27.0",
|
"sass": "^1.27.0",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { vec2 } from 'gl-matrix';
|
|
||||||
import { Renderer } from 'sdf-2d';
|
import { Renderer } from 'sdf-2d';
|
||||||
import { Command } from 'shared';
|
import { Command } from 'shared';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import {
|
||||||
deserialize,
|
deserialize,
|
||||||
TransportEvents,
|
TransportEvents,
|
||||||
SetAspectRatioActionCommand,
|
SetAspectRatioActionCommand,
|
||||||
PlayerInformation,
|
|
||||||
UpdateOtherPlayerDirections,
|
UpdateOtherPlayerDirections,
|
||||||
clamp,
|
clamp,
|
||||||
UpdateGameState,
|
UpdateGameState,
|
||||||
|
|
@ -193,7 +192,7 @@ export class Game extends CommandReceiver {
|
||||||
}px) translateX(-50%) translateY(-50%) rotate(${-angle + Math.PI / 2}rad) `;
|
}px) translateX(-50%) translateY(-50%) rotate(${-angle + Math.PI / 2}rad) `;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let id in this.arrows) {
|
for (const id in this.arrows) {
|
||||||
if (
|
if (
|
||||||
Object.prototype.hasOwnProperty.call(this.arrows, id) &&
|
Object.prototype.hasOwnProperty.call(this.arrows, id) &&
|
||||||
command.otherPlayerDirections.find((v) => v.id?.toString() === id) === undefined
|
command.otherPlayerDirections.find((v) => v.id?.toString() === id) === undefined
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { vec2 } from 'gl-matrix';
|
|
||||||
import { Circle } from 'shared';
|
import { Circle } from 'shared';
|
||||||
import { LinearExtrapolator } from './linear-extrapolator';
|
import { LinearExtrapolator } from './linear-extrapolator';
|
||||||
import { Vec2Extrapolator } from './vec2-extrapolator';
|
import { Vec2Extrapolator } from './vec2-extrapolator';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import { clamp } from 'shared';
|
|
||||||
|
|
||||||
export class LinearExtrapolator {
|
export class LinearExtrapolator {
|
||||||
private velocity = 0;
|
private velocity = 0;
|
||||||
private compensationVelocity = 0;
|
private compensationVelocity = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { vec2 } from 'gl-matrix';
|
import { vec2 } from 'gl-matrix';
|
||||||
import { Renderer } from 'sdf-2d';
|
|
||||||
import {
|
import {
|
||||||
Circle,
|
Circle,
|
||||||
Id,
|
Id,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { vec2, vec3 } from 'gl-matrix';
|
import { vec2, vec3 } from 'gl-matrix';
|
||||||
import { CircleLight, Renderer } from 'sdf-2d';
|
import { CircleLight } from 'sdf-2d';
|
||||||
import { CommandExecutors, Id, LampBase, UpdatePropertyCommand } from 'shared';
|
import { CommandExecutors, Id, LampBase } from 'shared';
|
||||||
import { RenderCommand } from '../../commands/types/render';
|
import { RenderCommand } from '../../commands/types/render';
|
||||||
|
|
||||||
export class LampView extends LampBase {
|
export class LampView extends LampBase {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { vec2 } from 'gl-matrix';
|
import { vec2 } from 'gl-matrix';
|
||||||
import { CircleLight, Renderer } from 'sdf-2d';
|
import { CircleLight } from 'sdf-2d';
|
||||||
import {
|
import {
|
||||||
CharacterTeam,
|
CharacterTeam,
|
||||||
CommandExecutors,
|
CommandExecutors,
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ export class PlanetShape extends PolygonFactory(settings.planetEdgeCount, 0) {
|
||||||
super(vertices);
|
super(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getObjectToSerialize(transform2d: mat2d, transform1d: number): any {
|
protected getObjectToSerialize(transform2d: mat2d, _: number): any {
|
||||||
const transformedVertices = (this as any).actualVertices.map((v: vec2) =>
|
const transformedVertices = (this as any).actualVertices.map((v: vec2) =>
|
||||||
vec2.transformMat2d(vec2.create(), v, transform2d),
|
vec2.transformMat2d(vec2.create(), v, transform2d),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ export abstract class SoundHandler {
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static play(sound: Sounds, volume: number = 1) {
|
public static play(sound: Sounds, volume = 1) {
|
||||||
if (!this.initialized || !OptionsHandler.options.soundsEnabled) {
|
if (!this.initialized || !OptionsHandler.options.soundsEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
package.json
14
package.json
|
|
@ -2,11 +2,21 @@
|
||||||
"name": "root",
|
"name": "root",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "^5.3.0"
|
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
||||||
|
"@typescript-eslint/parser": "^3.9.1",
|
||||||
|
"concurrently": "^5.3.0",
|
||||||
|
"eslint": "^7.2.0",
|
||||||
|
"eslint-config-prettier": "^6.11.0",
|
||||||
|
"eslint-plugin-import": "^2.21.2",
|
||||||
|
"eslint-plugin-json-format": "^2.0.1",
|
||||||
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
|
"eslint-plugin-unused-imports": "^0.1.3",
|
||||||
|
"prettier": "^2.0.5",
|
||||||
|
"typescript": "^4.0.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cd shared && npm run build && cd ../frontend && npm run build && cd ../backend && npm run build",
|
"build": "cd shared && npm run build && cd ../frontend && npm run build && cd ../backend && npm run build",
|
||||||
"lint": "eslint './**/src/**/*.{js,ts,json}' --fix",
|
"lint": "eslint ./**/src/**/*.{js,ts,json} --fix && prettier --write ./**/src/**/*.{js,ts,json}",
|
||||||
"init": "cd shared && npm install && cd ../frontend && npm install && cd ../backend && npm install",
|
"init": "cd shared && npm install && cd ../frontend && npm install && cd ../backend && npm install",
|
||||||
"start": "concurrently --kill-others-on-fail \"cd shared && npm start\" \"cd backend && npm start\" \"cd frontend && npm start\""
|
"start": "concurrently --kill-others-on-fail \"cd shared && npm start\" \"cd backend && npm start\" \"cd frontend && npm start\""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,7 @@
|
||||||
"try-build-before": "npx webpack --mode production"
|
"try-build-before": "npx webpack --mode production"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
|
||||||
"@typescript-eslint/parser": "^3.9.1",
|
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"eslint": "^7.2.0",
|
|
||||||
"eslint-config-prettier": "^6.11.0",
|
|
||||||
"eslint-plugin-import": "^2.21.2",
|
|
||||||
"eslint-plugin-json-format": "^2.0.1",
|
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
|
||||||
"eslint-plugin-unused-imports": "^0.1.3",
|
|
||||||
"file-loader": "^6.1.0",
|
"file-loader": "^6.1.0",
|
||||||
"gl-matrix": "^3.3.0",
|
"gl-matrix": "^3.3.0",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.0.5",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ export class CharacterBase extends GameObject {
|
||||||
super(id);
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
public onShoot(strength: number) {}
|
public onShoot(strength: number) {}
|
||||||
|
|
||||||
public setHealth(health: number) {
|
public setHealth(health: number) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export class PlanetBase extends GameObject {
|
||||||
this.vertices.length;
|
this.vertices.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
public generatedPoints(value: number) {}
|
public generatedPoints(value: number) {}
|
||||||
|
|
||||||
public static createPlanetVertices(
|
public static createPlanetVertices(
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { serializable } from '../../serialization/serializable';
|
||||||
import { GameObject } from '../game-object';
|
import { GameObject } from '../game-object';
|
||||||
import { Id } from '../../communication/id';
|
import { Id } from '../../communication/id';
|
||||||
import { CharacterTeam } from './character-base';
|
import { CharacterTeam } from './character-base';
|
||||||
import { CommandExecutors } from '../../commands/command-executors';
|
|
||||||
|
|
||||||
@serializable
|
@serializable
|
||||||
export class ProjectileBase extends GameObject {
|
export class ProjectileBase extends GameObject {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue