adds docs, removes some useless pub statements
This commit is contained in:
@@ -13,14 +13,16 @@ type OwnedBy = Select<OwnedLoot, ItemColumns>;
|
||||
pub struct Item {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub base_price: i32,
|
||||
base_price: i32,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
/// Returns this item value
|
||||
pub fn value(&self) -> i32 {
|
||||
self.base_price
|
||||
}
|
||||
|
||||
/// Returns this item sell value
|
||||
pub fn sell_value(&self) -> i32 {
|
||||
self.base_price / 2
|
||||
}
|
||||
@@ -33,10 +35,12 @@ impl Item {
|
||||
pub struct Inventory<'q>(pub &'q DbConnection);
|
||||
|
||||
impl<'q> Inventory<'q> {
|
||||
/// Get all items from Inventory
|
||||
pub fn all(&self) -> QueryResult<Vec<Item>> {
|
||||
items::table.load::<Item>(self.0)
|
||||
}
|
||||
|
||||
/// Find an item in Inventory
|
||||
pub fn find(&self, item_id: i32) -> QueryResult<Item> {
|
||||
items::table.find(item_id).first::<Item>(self.0)
|
||||
}
|
||||
@@ -86,7 +90,7 @@ impl Loot {
|
||||
}
|
||||
}
|
||||
|
||||
/// Manager for a player's loot
|
||||
/// Manager for a *single* player loot
|
||||
pub struct LootManager<'q>(pub &'q DbConnection, pub i32);
|
||||
|
||||
impl<'q> LootManager<'q> {
|
||||
@@ -96,6 +100,9 @@ impl<'q> LootManager<'q> {
|
||||
}
|
||||
|
||||
/// Finds an item by id
|
||||
///
|
||||
/// Returns a NotFound error if an item is found by it
|
||||
/// does not belong to this player
|
||||
pub fn find(&self, loot_id: i32) -> QueryResult<Item> {
|
||||
Ok(Loot::find(loot_id).first(self.0).and_then(|loot: Loot| {
|
||||
if loot.owner != self.1 {
|
||||
|
||||
Reference in New Issue
Block a user