diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-11 21:32:30 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-11 21:32:30 +0100 |
commit | a6803980f1e74ecf1abb007b7c77f00d2cd92c43 (patch) | |
tree | 425ca961b27117d6e5d5fa0ae5cfca93351e0b33 /game/menus/shop/ButtonBuySelectBulletScript.cpp | |
parent | 6bc0025e4c24ed6659d993f3469c10615fb0e273 (diff) | |
parent | 525636bb2158ecea68ebb9d6b8d2dc722524c5e5 (diff) |
merge master into loek/doxygen
Diffstat (limited to 'game/menus/shop/ButtonBuySelectBulletScript.cpp')
-rw-r--r-- | game/menus/shop/ButtonBuySelectBulletScript.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/game/menus/shop/ButtonBuySelectBulletScript.cpp b/game/menus/shop/ButtonBuySelectBulletScript.cpp new file mode 100644 index 0000000..d30849c --- /dev/null +++ b/game/menus/shop/ButtonBuySelectBulletScript.cpp @@ -0,0 +1,34 @@ +#include "ButtonBuySelectBulletScript.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 ButtonBuySelectBulletScript::init() { + IButtonScript::init(); + this->subscribe<ButtonPressEvent>([this](const ButtonPressEvent & e) { + return this->on_button_press(e); + }); +} + +bool ButtonBuySelectBulletScript::on_button_press(const ButtonPressEvent & e) { + SaveManager & save = this->get_save_manager(); + ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE, 0); + if (!buy_bullet.get()) { + ValueBroker<int> coins = save.get<int>(TOTAL_COINS_GAME, 0); + if (coins.get() >= 0) { + int coin = coins.get(); + coin -= 0; + save.set(TOTAL_COINS_GAME, coin); + save.set(BUY_BULLET_SAVE, 1); + } + } else { + save.set(JETPACK_PARTICLES, 0); + } + this->trigger_event<ShopUpdate>(); + return false; +} |