impls add player admin action

This commit is contained in:
2019-07-03 14:11:26 +02:00
parent 5a792edb20
commit c95c13bf18
6 changed files with 72 additions and 15 deletions

View File

@@ -49,6 +49,7 @@ impl Loot {
}
}
type ItemDesc<'a> = (&'a str, i32);
/// An item being looted or bought.
///
/// The owner is set to 0 in case of looting,
@@ -60,3 +61,21 @@ struct NewLoot<'a> {
base_price: i32,
owner_id: i32,
}
impl<'a> NewLoot<'a> {
fn to_group(desc: ItemDesc<'a>) -> Self {
Self {
name: desc.0,
base_price: desc.1,
owner_id: 0,
}
}
fn to_player(player: i32, desc: ItemDesc<'a>) -> Self {
Self {
name: desc.0,
base_price: desc.1,
owner_id: player,
}
}
}