starts improving REST Api
This commit is contained in:
@@ -120,13 +120,10 @@ impl<'q> AsPlayer<'q> {
|
||||
Ok(models::Item::owned_by(self.id).load(self.conn)?)
|
||||
}
|
||||
/// Buy an item and add it to this player chest
|
||||
///
|
||||
/// TODO: Items should be picked from a custom list
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This currently panics if player wealth fails to be updated, as this is
|
||||
/// a serious error.
|
||||
/// # Returns
|
||||
/// Result containing the difference in coins after operation
|
||||
pub fn buy<'a>(self, name: &'a str, price: i32) -> ActionResult<(i32, i32, i32, i32)> {
|
||||
self.conn.transaction(|| {
|
||||
let new_item = models::item::NewLoot::to_player(self.id, (name, price));
|
||||
@@ -139,14 +136,11 @@ impl<'q> AsPlayer<'q> {
|
||||
})?;
|
||||
self.update_wealth(-(price as f32))
|
||||
})
|
||||
|
||||
}
|
||||
/// Sell an item from this player chest
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This currently panics if player wealth fails to be updated, as this is
|
||||
/// a serious error.
|
||||
/// # Returns
|
||||
/// Result containing the difference in coins after operation
|
||||
pub fn sell(
|
||||
self,
|
||||
loot_id: i32,
|
||||
|
||||
Reference in New Issue
Block a user