will need to clean up db API

This commit is contained in:
2020-01-05 15:37:40 +01:00
parent a47646bd5f
commit 6149dfd297
2 changed files with 82 additions and 45 deletions

View File

@@ -98,6 +98,31 @@ pub enum ApiActions {
//SetClaimsTimeout(pub i32),
}
pub enum ApiEndpoints {
InventoryList,
InventoryCheck(Vec<String>),
InventoryAdd(String, i32), // db::Inventory(conn)::add(new_item)
ShopList, // db::Shop(conn)::list()
BuyItems(i32, BuySellParams), // db::Shop(conn)::buy(params)
RefreshShop(ItemList), // db::Shop(conn)::replace_list(items)
// db::Players::get returns AsPlayer<'q>
PlayerList, //db::Players(conn)::list()
PlayerAdd(NewPlayer), //db::Players(conn)::add(player)
PlayerFetch(i32), // db::Players(conn)::get(id)
PlayerClaims(i32), // db::Players(conn)::get(id).claims()
PlayerNotifications(i32), // db::Players(conn)::get(id).notifications()
PlayerLoot(i32),// db::Players(conn)::get(id).loot()
PlayerUpdateWealth(i32, f64), // db::Players(conn)::get(id).update_wealth(f64)
SellItems(i32, BuySellParams), // db::Players(conn)::get(id).sell(params)
ClaimItems(i32, IdList), // db::Players(conn)::get(id).claim(items)
UndoLastAction(i32), // db::Players(conn)::get(id).undo_last()
AddLoot(NewGroupLoot), // db::Group(conn)::add_loot(loot)
ResolveClaims, // db::Group(conn)::resolve_claims()
}
pub fn execute(
conn: &DbConnection,
query: ApiActions,
@@ -143,7 +168,7 @@ pub fn execute(
None
}
ApiActions::FetchPlayer(id) => {
response.set_value(Value::Player(db::Players(conn).find(id)?));
response.set_value(Value::Players(conn)(db::Players(conn).find(id)?));
None
}
ApiActions::FetchPlayerClaims(id) => {