From 49a5735e07e7868195590a13c247698aaa1c5358 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 27 Aug 2022 17:41:32 +0200 Subject: [PATCH] show map info for matches --- planetwars-server/src/routes/matches.rs | 4 ++++ .../lib/components/matches/MatchList.svelte | 8 +++++++ web/pw-server/src/routes/editor.svelte | 24 ++++++++++++++----- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs index 71c4409..10b4507 100644 --- a/planetwars-server/src/routes/matches.rs +++ b/planetwars-server/src/routes/matches.rs @@ -15,6 +15,8 @@ use crate::{ DatabaseConnection, GlobalConfig, }; +use super::maps::ApiMap; + #[derive(Serialize, Deserialize)] pub struct ApiMatch { id: i32, @@ -22,6 +24,7 @@ pub struct ApiMatch { state: MatchState, players: Vec, winner: Option, + map: Option, } #[derive(Serialize, Deserialize)] @@ -102,6 +105,7 @@ pub fn match_data_to_api(data: matches::FullMatchData) -> ApiMatch { }) .collect(), winner: data.base.winner, + map: data.map.map(|m| ApiMap { name: m.name }), } } diff --git a/web/pw-server/src/lib/components/matches/MatchList.svelte b/web/pw-server/src/lib/components/matches/MatchList.svelte index 01a0b82..e38543e 100644 --- a/web/pw-server/src/lib/components/matches/MatchList.svelte +++ b/web/pw-server/src/lib/components/matches/MatchList.svelte @@ -16,6 +16,7 @@ player 2 + map {#each matches as match} goto(match_url(match))}> @@ -38,6 +39,9 @@ {match["players"][1]["bot_name"]} + + {match["map"]?.name || ""} + {/each} @@ -84,6 +88,10 @@ text-align: left; } + .col-map { + text-align: right; + } + .matches-table { margin: 12px auto; border-collapse: collapse; diff --git a/web/pw-server/src/routes/editor.svelte b/web/pw-server/src/routes/editor.svelte index b1644c8..ff8232c 100644 --- a/web/pw-server/src/routes/editor.svelte +++ b/web/pw-server/src/routes/editor.svelte @@ -12,6 +12,7 @@ import { debounce } from "$lib/utils"; import SubmitPane from "$lib/components/SubmitPane.svelte"; import OutputPane from "$lib/components/OutputPane.svelte"; + import BotName from "./bots/[bot_name].svelte"; enum ViewMode { Editor, @@ -138,11 +139,12 @@ on:click={() => selectMatch(match.id)} class:selected={match.id === selectedMatchId} > - {formatMatchTimestamp(match.timestamp)} - - - - {match["players"][1]["bot_name"]} +
{formatMatchTimestamp(match.timestamp)}
+
+ +
{match["players"][1]["bot_name"]}
+
{match["map"]?.name}
+
{/each} @@ -221,14 +223,24 @@ .match-card { padding: 10px 15px; font-size: 11pt; + display: flex; } .match-timestamp { color: #ccc; } + .match-card-body { + margin: 0 8px; + } + .match-opponent { - padding: 0 0.5em; + font-weight: 600; + color: #eee; + } + + .match-map { + color: #ccc; } .sidebar-header {