aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/modules/bot_api.rs
diff options
context:
space:
mode:
Diffstat (limited to 'planetwars-server/src/modules/bot_api.rs')
-rw-r--r--planetwars-server/src/modules/bot_api.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/planetwars-server/src/modules/bot_api.rs b/planetwars-server/src/modules/bot_api.rs
index 732aa21..962b33d 100644
--- a/planetwars-server/src/modules/bot_api.rs
+++ b/planetwars-server/src/modules/bot_api.rs
@@ -102,10 +102,10 @@ impl pb::bot_api_service_server::BotApiService for BotApiServer {
let match_request = req.get_ref();
- let opponent = db::bots::find_bot_by_name(&match_request.opponent_name, &conn)
+ let opponent_bot = db::bots::find_bot_by_name(&match_request.opponent_name, &conn)
.map_err(|_| Status::not_found("opponent not found"))?;
- let opponent_code_bundle = db::bots::active_bot_version(opponent.id, &conn)
- .map_err(|_| Status::not_found("opponent has no code"))?;
+ let opponent_bot_version = db::bots::active_bot_version(opponent_bot.id, &conn)
+ .map_err(|_| Status::not_found("no opponent version found"))?;
let player_key = gen_alphanumeric(32);
@@ -114,8 +114,13 @@ impl pb::bot_api_service_server::BotApiService for BotApiServer {
router: self.router.clone(),
});
let mut run_match = RunMatch::from_players(vec![
- MatchPlayer::from_bot_spec(remote_bot_spec),
- MatchPlayer::from_bot_version(&opponent, &opponent_code_bundle),
+ MatchPlayer::BotSpec {
+ spec: remote_bot_spec,
+ },
+ MatchPlayer::BotVersion {
+ bot: Some(opponent_bot),
+ version: opponent_bot_version,
+ },
]);
let created_match = run_match
.store_in_database(&conn)