diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-05-29 11:41:52 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-05-29 11:41:52 +0200 |
commit | 6e1167ee9e4ce2bef3c4a7f38efc362be1d750cd (patch) | |
tree | e50eef4b59704f552158829793c745fe90452bff /planetwars-server/src/modules/matches.rs | |
parent | 80c60ac69c9b0d86a4536eeac82cf266eb4430bc (diff) | |
download | planetwars.dev-6e1167ee9e4ce2bef3c4a7f38efc362be1d750cd.tar.xz planetwars.dev-6e1167ee9e4ce2bef3c4a7f38efc362be1d750cd.zip |
save match winner in database
Diffstat (limited to 'planetwars-server/src/modules/matches.rs')
-rw-r--r-- | planetwars-server/src/modules/matches.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/planetwars-server/src/modules/matches.rs b/planetwars-server/src/modules/matches.rs index 201c6d4..a254bac 100644 --- a/planetwars-server/src/modules/matches.rs +++ b/planetwars-server/src/modules/matches.rs @@ -6,7 +6,10 @@ use runner::MatchOutcome; use tokio::task::JoinHandle; use crate::{ - db::{self, matches::MatchData}, + db::{ + self, + matches::{MatchData, MatchResult}, + }, util::gen_alphanumeric, ConnectionPool, BOTS_DIR, MAPS_DIR, MATCHES_DIR, }; @@ -95,8 +98,11 @@ async fn run_match_task( .await .expect("could not get database connection"); - db::matches::set_match_state(match_id, db::matches::MatchState::Finished, &conn) - .expect("could not update match state"); + let result = MatchResult::Finished { + winner: outcome.winner.map(|w| (w - 1) as i32), // player numbers in matchrunner start at 1 + }; + + db::matches::save_match_result(match_id, result, &conn).expect("could not save match result"); return outcome; } |