aboutsummaryrefslogtreecommitdiff
path: root/game/menus/shop/ButtonBuySelectBubbleScript.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2025-01-09 21:14:35 +0100
committerJAROWMR <jarorutjes07@gmail.com>2025-01-09 21:14:35 +0100
commitf6683fa71fa670cfbe6aa6233fafb869295da11a (patch)
treea46ee1d8856b5f0e0298abbab9c92ba21509d830 /game/menus/shop/ButtonBuySelectBubbleScript.cpp
parent296c7b8becc04fa0eeef7c732e5c62a26de45570 (diff)
added shop functionality
Diffstat (limited to 'game/menus/shop/ButtonBuySelectBubbleScript.cpp')
-rw-r--r--game/menus/shop/ButtonBuySelectBubbleScript.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/game/menus/shop/ButtonBuySelectBubbleScript.cpp b/game/menus/shop/ButtonBuySelectBubbleScript.cpp
new file mode 100644
index 0000000..21dbe1a
--- /dev/null
+++ b/game/menus/shop/ButtonBuySelectBubbleScript.cpp
@@ -0,0 +1,36 @@
+#include "ButtonBuySelectBubbleScript.h"
+#include "../MenusConfig.h"
+#include "Config.h"
+#include "ValueBroker.h"
+#include "manager/SaveManager.h"
+#include "menus/shop/Shopconfig.h"
+
+using namespace crepe;
+using namespace std;
+
+void ButtonBuySelectBubbleScript::init() {
+ IButtonScript::init();
+ this->subscribe<ButtonPressEvent>([this](const ButtonPressEvent & e) {
+ return this->on_button_press(e);
+ });
+}
+
+bool ButtonBuySelectBubbleScript::on_button_press(const ButtonPressEvent & e) {
+ SaveManager & save = this->get_save_manager();
+ ValueBroker<int> buy_bullet = save.get<int>(BUY_BUBBLE_SAVE,0);
+ if(!buy_bullet.get()){
+ ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME,0);
+ if(coins.get() >= 1000)
+ {
+ int coin = coins.get();
+ coin -= 1000;
+ save.set(TOTAL_COINS_GAME,coin);
+ save.set(BUY_BUBBLE_SAVE,1);
+ }
+ }
+ else {
+ save.set(JETPACK_PARTICLES,1);
+ }
+ this->trigger_event<ShopUpdate>();
+ return false;
+}