From 28b3699b3be17ac9330d2af909fc14344e93e8e2 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sun, 22 Jun 2025 15:58:49 -0500 Subject: [PATCH] working buy system --- src/methods/buy.rs | 6 ++++-- src/response.rs | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/methods/buy.rs b/src/methods/buy.rs index 771a160..57aa5eb 100644 --- a/src/methods/buy.rs +++ b/src/methods/buy.rs @@ -14,10 +14,12 @@ pub fn buy_cloak(session: &Session, cloak: String) -> Result { .players .update_one( filter, - doc! { "$inc": { "points": -100 }, "$push": { "cloaks": cloak } }, + doc! { "$inc": { "coins": -100 }, "$push": { "cloaks": cloak.clone() } }, ) .run()?; - Ok(crate::response::Response::Success) + Ok(crate::response::Response::SuccessfulTransaction(format!( + "cloak={cloak}" + ))) } else { Err(crate::response::Error::TransactionError( "Not enough coins".to_string(), diff --git a/src/response.rs b/src/response.rs index 285d3e7..a9bb112 100644 --- a/src/response.rs +++ b/src/response.rs @@ -35,6 +35,7 @@ impl std::fmt::Display for PlayerResponse { pub enum Response { Pong, Success, + SuccessfulTransaction(String), Player(PlayerResponse), Players(Vec), } @@ -56,6 +57,7 @@ impl std::fmt::Display for Response { .join("\n") ) } + Response::SuccessfulTransaction(s) => write!(f, "successful_transaction@{s}"), } } }