makes adding loot working

This commit is contained in:
2019-10-07 15:10:35 +02:00
parent 4f6970c423
commit 70eed30bee
8 changed files with 118 additions and 90 deletions

View File

@@ -138,7 +138,7 @@ impl<'q> AsPlayer<'q> {
if let Ok((item, diff)) = self.conn.transaction(|| {
use schema::looted::dsl::*;
let item = schema::items::table.find(item_id).first::<models::Item>(self.conn)?;
let new_item = models::item::NewLoot::to_player(self.id, (&item.name, item.base_price));
let new_item = models::item::NewLoot::to_player(self.id, &item);
diesel::insert_into(schema::looted::table)
.values(&new_item)
.execute(self.conn)?;
@@ -285,8 +285,8 @@ impl<'q> AsAdmin<'q> {
///
/// # Params
/// List of (name, base_price) values for the new items
pub fn add_loot(self, items: Vec<(&str, i32)>) -> ActionResult<()> {
for item_desc in items.into_iter() {
pub fn add_loot(self, items: Vec<models::item::Item>) -> ActionResult<()> {
for item_desc in items.iter() {
let new_item = models::item::NewLoot::to_group(item_desc);
diesel::insert_into(schema::looted::table)
.values(&new_item)