diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-09 20:01:05 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-09 20:01:05 +0200 |
commit | ec1d50f655c05d9dec0c4b01fd1039e9c5525f34 (patch) | |
tree | 90973a749e5d67ddf9749b23f82a41beba0ac812 /planetwars-server/src/routes | |
parent | 7eb02a2efc8f0bb8ec411c5af0f648aeda939226 (diff) | |
download | planetwars.dev-ec1d50f655c05d9dec0c4b01fd1039e9c5525f34.tar.xz planetwars.dev-ec1d50f655c05d9dec0c4b01fd1039e9c5525f34.zip |
refactor: pass on both Bot and BotVersion to MatchPlayer
Diffstat (limited to 'planetwars-server/src/routes')
-rw-r--r-- | planetwars-server/src/routes/demo.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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), }, ], }; |