refactors, makes Loot private to module

This commit is contained in:
2019-10-14 16:28:18 +02:00
parent b2e319dc15
commit c72169281d
3 changed files with 54 additions and 26 deletions

View File

@@ -247,21 +247,19 @@ impl<'q> AsAdmin<'q> {
///
/// When a player gets an item, it's debt is increased by this item sell value
pub fn resolve_claims(self) -> ActionResult<()> {
let data = models::claim::Claims(self.0).grouped_by_loot()?;
let data = models::claim::Claims(self.0).grouped_by_item()?;
dbg!(&data);
for (loot, claims) in data {
for (item, claims) in data {
match claims.len() {
1 => {
let claim = claims.get(0).unwrap();
let player_id = claim.player_id;
self.0.transaction(|| {
loot.set_owner(claim.player_id)
.execute(self.0)?;
claim.resolve_claim(self.0)?;
//models::item::LootManager(self.0, 0).set_owner(claim.loot_id, claim.player_id)?;
models::player::AsPlayer(self.0, player_id)
.update_debt(loot.sell_value())?;
models::claim::Claims(self.0).remove(player_id, claim.loot_id)?;
Ok(())
.update_debt(item.sell_value())
})?;
},
_ => (),