adds cors to test in dev environment
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user