makes adding loot working
This commit is contained in:
@@ -12,7 +12,7 @@ type OwnedBy = Select<OwnedLoot, ItemColumns>;
|
||||
/// It is also used as a public representation of Loot, since owner
|
||||
/// information is implicit.
|
||||
/// Or maybe this is a little too confusing ??
|
||||
#[derive(Debug, Queryable, Serialize)]
|
||||
#[derive(Debug, Queryable, Serialize, Deserialize, Clone)]
|
||||
pub struct Item {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
@@ -54,9 +54,6 @@ impl Loot {
|
||||
}
|
||||
}
|
||||
|
||||
/// Description of an item : (name, value in gold)
|
||||
pub type ItemDesc<'a> = (&'a str, i32);
|
||||
|
||||
/// An item being looted or bought.
|
||||
///
|
||||
/// The owner is set to 0 in case of looting,
|
||||
@@ -71,19 +68,19 @@ pub(crate) struct NewLoot<'a> {
|
||||
|
||||
impl<'a> NewLoot<'a> {
|
||||
/// A new loot going to the group (loot procedure)
|
||||
pub(crate) fn to_group(desc: ItemDesc<'a>) -> Self {
|
||||
pub(crate) fn to_group(desc: &'a Item) -> Self {
|
||||
Self {
|
||||
name: desc.0,
|
||||
base_price: desc.1,
|
||||
name: &desc.name,
|
||||
base_price: desc.base_price,
|
||||
owner_id: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// A new loot going to a specific player (buy procedure)
|
||||
pub(crate) fn to_player(player: i32, desc: ItemDesc<'a>) -> Self {
|
||||
pub(crate) fn to_player(player: i32, desc: &'a Item) -> Self {
|
||||
Self {
|
||||
name: desc.0,
|
||||
base_price: desc.1,
|
||||
name: &desc.name,
|
||||
base_price: desc.base_price,
|
||||
owner_id: player,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user