aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/lib/log_parser.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/pw-server/src/lib/log_parser.ts')
-rw-r--r--web/pw-server/src/lib/log_parser.ts24
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;
}
}
}