From ec1d50f655c05d9dec0c4b01fd1039e9c5525f34 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 9 Jul 2022 20:01:05 +0200 Subject: refactor: pass on both Bot and BotVersion to MatchPlayer --- planetwars-server/src/routes/demo.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'planetwars-server/src/routes') diff --git a/planetwars-server/src/routes/demo.rs b/planetwars-server/src/routes/demo.rs index 4f83de0..1a6ae9a 100644 --- a/planetwars-server/src/routes/demo.rs +++ b/planetwars-server/src/routes/demo.rs @@ -37,18 +37,18 @@ pub async fn submit_bot( .opponent_name .unwrap_or_else(|| DEFAULT_OPPONENT_NAME.to_string()); - let opponent = + let opponent_bot = db::bots::find_bot_by_name(&opponent_name, &conn).map_err(|_| StatusCode::BAD_REQUEST)?; - let opponent_bot_version = - db::bots::active_bot_version(opponent.id, &conn).map_err(|_| StatusCode::BAD_REQUEST)?; + let opponent_bot_version = db::bots::active_bot_version(opponent_bot.id, &conn) + .map_err(|_| StatusCode::BAD_REQUEST)?; let player_bot_version = save_code_string(¶ms.code, None, &conn) // TODO: can we recover from this? .expect("could not save bot code"); let mut run_match = RunMatch::from_players(vec![ - MatchPlayer::from_code_bundle(&player_bot_version), - MatchPlayer::from_code_bundle(&opponent_bot_version), + MatchPlayer::from_code_bundle_version(&player_bot_version), + MatchPlayer::from_bot_version(&opponent_bot, &opponent_bot_version), ]); let match_data = run_match .store_in_database(&conn) @@ -67,7 +67,7 @@ pub async fn submit_bot( FullMatchPlayerData { base: match_data.match_players[1].clone(), bot_version: Some(opponent_bot_version), - bot: Some(opponent), + bot: Some(opponent_bot), }, ], }; -- cgit v1.2.3