Skip to content

Commit

Permalink
Fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderson1993 committed Dec 7, 2021
1 parent b0e184b commit 6622ae3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 176 deletions.
174 changes: 10 additions & 164 deletions client/src/components/Station/Effects/simplexNoise.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,175 +51,21 @@ function SimplexNoise(random) {
}
SimplexNoise.prototype = {
grad3: new Float32Array([
1,
1,
0,
-1,
1,
0,
1,
-1,
0,
1, 1, 0, -1, 1, 0, 1, -1, 0,

-1,
-1,
0,
1,
0,
1,
-1,
0,
1,
-1, -1, 0, 1, 0, 1, -1, 0, 1,

1,
0,
-1,
-1,
0,
-1,
0,
1,
1,
1, 0, -1, -1, 0, -1, 0, 1, 1,

0,
-1,
1,
0,
1,
-1,
0,
-1,
-1,
0, -1, 1, 0, 1, -1, 0, -1, -1,
]),
grad4: new Float32Array([
0,
1,
1,
1,
0,
1,
1,
-1,
0,
1,
-1,
1,
0,
1,
-1,
-1,
0,
-1,
1,
1,
0,
-1,
1,
-1,
0,
-1,
-1,
1,
0,
-1,
-1,
-1,
1,
0,
1,
1,
1,
0,
1,
-1,
1,
0,
-1,
1,
1,
0,
-1,
-1,
-1,
0,
1,
1,
-1,
0,
1,
-1,
-1,
0,
-1,
1,
-1,
0,
-1,
-1,
1,
1,
0,
1,
1,
1,
0,
-1,
1,
-1,
0,
1,
1,
-1,
0,
-1,
-1,
1,
0,
1,
-1,
1,
0,
-1,
-1,
-1,
0,
1,
-1,
-1,
0,
-1,
1,
1,
1,
0,
1,
1,
-1,
0,
1,
-1,
1,
0,
1,
-1,
-1,
0,
-1,
1,
1,
0,
-1,
1,
-1,
0,
-1,
-1,
1,
0,
-1,
-1,
-1,
0,
0, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0, -1, 1, 1, 0, -1, 1,
-1, 0, -1, -1, 1, 0, -1, -1, -1, 1, 0, 1, 1, 1, 0, 1, -1, 1, 0, -1, 1, 1, 0,
-1, -1, -1, 0, 1, 1, -1, 0, 1, -1, -1, 0, -1, 1, -1, 0, -1, -1, 1, 1, 0, 1,
1, 1, 0, -1, 1, -1, 0, 1, 1, -1, 0, -1, -1, 1, 0, 1, -1, 1, 0, -1, -1, -1,
0, 1, -1, -1, 0, -1, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0, -1,
1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 0,
]),
noise2D: function (xin, yin) {
var permMod12 = this.permMod12,
Expand Down
6 changes: 3 additions & 3 deletions client/src/docs/Development/netRequests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ used. Each file exports an object where the keys are net request names and the
values are functions that return the data.

The function, which can be an `async` function, includes
[`DataContext`](/docs/development/datacontext) as the first parameter. The second parameter
is the `params` which can be sent from the client. A third param called
`publishParams` is the params which are passed by `pubsub.publish`.
[`DataContext`](/docs/development/datacontext) as the first parameter. The
second parameter is the `params` which can be sent from the client. A third
param called `publishParams` is the params which are passed by `pubsub.publish`.

Unlike card loaders, net requests only use one function that both determines
whether the net request should get the data and what data should be returned.
Expand Down
6 changes: 2 additions & 4 deletions server/src/classes/Card.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import {cardSubscriptions} from "client/src/utils/cardData";

type CardConfig = unknown;
export class Card {
name: string;

component: keyof typeof cardSubscriptions;
component: string;

config?: CardConfig;

icon?: string | null;

constructor(params: Partial<Card>) {
this.name = params.name || "Card";
this.component = params.component || "Card";
this.component = params.component || "Login";
this.config = params.config;
this.icon = params.icon || null;
}
Expand Down
1 change: 1 addition & 0 deletions server/src/classes/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export class ServerClient extends BaseClient {
return this._cards;
}
public async initSubscriptions(socket: SocketStream = sockets[this.id]) {
if (process.env.NODE_ENV === "test") return;
// Remove all of the existing subscriptions
for (let subId of this.subscriptionListeners) {
pubsub.unsubscribe(subId);
Expand Down
13 changes: 9 additions & 4 deletions server/src/inputs/__test__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {clientInputs} from "../client";
import systems from "../../systems";
import type ShipPlugin from "server/src/classes/Plugins/Ship";
import {FlightDataModel} from "server/src/classes/FlightDataModel";
import {SocketStream} from "fastify-websocket";

class MockServerDataModel {
clients!: Record<string, ServerClient>;
Expand Down Expand Up @@ -114,6 +115,9 @@ class MockDataContext {
}) as any as FlightDataModel;
constructor() {
this.flight.initEcs(this.server);
for (let client in this.server.clients) {
this.server.clients[client].clientContext = this;
}
}
get client() {
return this.server.clients[this.clientId];
Expand All @@ -129,18 +133,19 @@ class MockDataContext {
}
}
describe("Client input", () => {
it("should assign to a client and station", () => {
it("should assign to a client and station", async () => {
const mockDataContext = new MockDataContext();
expect(() =>
expect(
clientInputs.clientSetStation(mockDataContext, {
shipId: 1,
stationId: "Test",
})
).toThrowError("No ship with that ID exists");
).rejects.toThrowError("No ship with that ID exists");

const ship = mockDataContext.flight.ecs.addEntity(
new Entity(1, {
isShip: {shipClass: "Test", category: "Test", registry: "", assets: {}},
isPlayerShip: {value: true},
stationComplement: {
stations: [
{
Expand All @@ -157,7 +162,7 @@ describe("Client input", () => {
},
})
);
clientInputs.clientSetStation(mockDataContext, {
await clientInputs.clientSetStation(mockDataContext, {
shipId: 1,
stationId: "Test",
});
Expand Down
7 changes: 6 additions & 1 deletion server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
"@thorium/cardSubscriptions": ["./client/src/utils/subscriptions"]
}
},
"include": ["src/**/*", "../shared", "../client/src/cards/**/data.ts"],
"include": [
"src/**/*",
"../shared",
"../client/src/cards/**/data.ts",
"../client/src/cards/**/data.tsx"
],
"files": [
"../client/src/utils/cardData.ts",
"../client/src/cards/dataList.ts",
Expand Down

0 comments on commit 6622ae3

Please sign in to comment.