adds UpdateResult class of queries

This commit is contained in:
2019-10-29 16:19:00 +01:00
parent 089aaf9a6d
commit ee0b7b2b7a
4 changed files with 64 additions and 59 deletions

View File

@@ -113,9 +113,7 @@ pub fn execute(
None
}
ApiActions::UpdateWealth(id, amount) => {
response.push_update(Update::Wealth(
db::AsPlayer(conn, id).update_wealth(amount)?,
));
response.push_update(db::AsPlayer(conn, id).update_wealth(amount)?);
response.notify(format!("Mis à jour ({}po)!", amount));
Some((id, "Argent mis à jour"))
}
@@ -165,15 +163,17 @@ pub fn execute(
.fold(db::Wealth::from_gp(0.0), |acc, i| acc + i);
match id {
0 => {
let players = params.players.expect("The player list should be passed in !");
let share = db::split_and_share(
conn,
total_amount.to_gp() as i32,
params.players.expect("Should not be None"),
&players,
)?;
response.notify(format!(
"Les objets ont été vendus, chaque joueur a reçu {} po",
share.to_gp()
));
//response.push_update(Update::GroupShare(players, share));
response.push_update(Update::Wealth(share));
}
_ => {