Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dummy PR for review #1

Open
wants to merge 66 commits into
base: review
Choose a base branch
from
Open

Dummy PR for review #1

wants to merge 66 commits into from

Conversation

leanil
Copy link
Member

@leanil leanil commented Nov 20, 2022

No description provided.

Copy link
Member Author

@leanil leanil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Összességében egy első játékszervernek teljesen rendben van a kód, szép munka 👍
A hibakezeléssel itt is több szinten kell majd még foglalkoznunk, hogy a szerver se haldokoljon és a játékosoknak is legyen valami fogalma hogy mi a baj a botjukkal (vissza kéne küldeni hibaüzeneteket a botnak és / vagy kiírni a vizualizálóval).
Azt a néhány komolyabb hibát / átgondolni valót ami találtam ❗ -el jelöltem. A többi csak elírás, tipp, ízlés kérdése.

.gitignore Show resolved Hide resolved
BotWraper.ts Outdated
import { stringify } from 'node:querystring';
import { Queue } from 'queue-typescript';

export enum ErrorCode {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Success is error code? 🤔
Nem inkább ExitCode?

tsconfig.json Outdated
@@ -8,7 +8,7 @@
"outDir": "./dist",
"rootDir": "./",
"sourceMap": true,
"target": "ESNext",
"target": "ES6",
"moduleResolution": "node"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"moduleResolution": "node"
"moduleResolution": "node",
"strict": true

Recommended, a TS szerint is https://www.typescriptlang.org/tsconfig#strict

BotWraper.ts Outdated

export class Data {
id: number;
data?: string;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data?: string;
data: string | null;

Az, hogy TLE-nél data: null-t adsz vissza, az tök jó. A null egy explicit semmi, az undefined meg csak úgy "épp nem jutott oda adat".
Viszont itt a ? lényegében string | undefined-ot jelent, strict módban szól is miatta a compiler.
https://www.typescriptlang.org/docs/handbook/2/objects.html#optional-properties

BotWraper.ts Outdated
error_code: ErrorCode;
active: boolean;
process: ChildProcess;
std_out: Queue<string>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miért Queue? Nekem úgy tűnik, mintha a sima array is elég lenne.

nanowar.ts Outdated
// Add planets to
planetWaitingList[planet].push(user);
console.log("Arrived:", planetWaitingList);
state.tick.troops.splice(i, 1); // Removing troop from list
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha a tick.troops egy endTick szerint indexelt Map lenne, akkor

  1. itt egy lépésben ki tudnád törölni az összeset aki ebben a körben érkezett meg O(n^2) helyett
  2. a for ciklusban sem kellene az összes troopot végignézni

nanowar.ts Outdated Show resolved Hide resolved
nanowar.ts Outdated Show resolved Hide resolved
nanowar.ts Outdated Show resolved Hide resolved
nanowar.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants