adds cors to test in dev environment

This commit is contained in:
2019-07-03 14:32:35 +02:00
parent c95c13bf18
commit b8968aebbd
5 changed files with 19 additions and 5 deletions

View File

@@ -115,15 +115,17 @@ impl<'q> AsPlayer<'q> {
/// Adds the value in gold to the player's wealth.
///
/// Value can be negative to substract wealth.
pub fn update_wealth(self, value: f32) -> ActionResult {
pub fn update_wealth(self, value_in_gp: f32) -> ActionResult {
use schema::players::dsl::*;
let current_wealth = players.find(self.id)
let current_wealth = players
.find(self.id)
.select((cp, sp, gp, pp))
.first::<models::WealthUpdate>(self.conn)?;
// TODO: improve this
// should be move inside a WealthUpdate method
let update =
models::WealthUpdate::from_gp(current_wealth.to_gp() + value);
let update = models::WealthUpdate::from_gp(
current_wealth.to_gp() + value_in_gp
);
diesel::update(players)
.filter(id.eq(self.id))
.set(&update)