- {#each playerLog as logTurn, i}
-
-
- {#if logTurn.action?.type === "bad_command"}
-
-
{logTurn.action.command}
-
Parse error: {logTurn.action.error}
-
- {/if}
- {#if logTurn.stderr.length > 0}
-
-
- {#each logTurn.stderr as stdErrMsg}
-
{stdErrMsg}
- {/each}
-
- {/if}
+
+ {playerLog.flatMap((turn) => turn.stderr).join("\n")}
+
+ {:else}
+
+ {#each playerLog as logTurn, i}
+
+
+ {#if logTurn.action?.type === "dispatches"}
+
+ {#each logTurn.action.dispatches as dispatch}
+
+
+ {pluralize(dispatch.ship_count, "ship")} from {dispatch.origin} to {dispatch.destination}
+
+ {#if dispatch.error}
+
{dispatch.error}
+ {/if}
+
+ {/each}
+
+ {:else if logTurn.action?.type === "bad_command"}
+
+
{logTurn.action.command}
+
Parse error: {logTurn.action.error}
+
+ {/if}
+ {#if logTurn.stderr.length > 0}
+
+
+ {#each logTurn.stderr as stdErrMsg}
+
{stdErrMsg}
+ {/each}
+
+ {/if}
+
+ {/each}
- {/each}
-
{/if}
@@ -81,6 +111,15 @@
color: red;
}
+ .dispatch {
+ display: flex;
+ justify-content: space-between;
+ }
+
+ .dispatch-error {
+ color: red;
+ }
+
.bad-command-container {
border-left: 1px solid red;
margin-left: 4px;
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;
}
}
}