diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-09-18 13:16:57 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-09-18 13:16:57 +0200 |
commit | 3138eca6d041aafc5dbee2480b966591f84154f9 (patch) | |
tree | f2d7eb55b125e555c1b874dbacf755d9c4c2891d /web/pw-server/src/lib/log_parser.ts | |
parent | 3be0cfa0ea61a3c56e0efc7169be5f3e0d7009d3 (diff) | |
download | planetwars.dev-3138eca6d041aafc5dbee2480b966591f84154f9.tar.xz planetwars.dev-3138eca6d041aafc5dbee2480b966591f84154f9.zip |
show dispatches and timeouts in outputpane
Diffstat (limited to 'web/pw-server/src/lib/log_parser.ts')
-rw-r--r-- | web/pw-server/src/lib/log_parser.ts | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/web/pw-server/src/lib/log_parser.ts b/web/pw-server/src/lib/log_parser.ts index 77c459f..da1d3c0 100644 --- a/web/pw-server/src/lib/log_parser.ts +++ b/web/pw-server/src/lib/log_parser.ts @@ -5,7 +5,11 @@ export type PlayerLogTurn = { stderr: string[]; }; -type PlayerAction = BadCommand; +type PlayerAction = Timeout | BadCommand | Dispatches; + +type Timeout = { + type: "timeout"; +}; type BadCommand = { type: "bad_command"; @@ -13,6 +17,18 @@ type BadCommand = { error: string; }; +type Dispatches = { + type: "dispatches"; + dispatches: Dispatch[]; +}; + +type Dispatch = { + origin: string; + destination: string; + ship_count: number; + error?: string; +}; + function createEmptyLogTurn(): PlayerLogTurn { return { stderr: [], @@ -43,9 +59,13 @@ export function parsePlayerLog(playerId: number, logText: string): PlayerLog { case "stderr": { let msg = logMessage["message"]; turn.stderr.push(msg); + break; } - case "bad_command": { + case "timeout": + case "bad_command": + case "dispatches": { turn.action = logMessage; + break; } } } |