diff options
author | Max-001 <80035972+Max-001@users.noreply.github.com> | 2025-01-10 14:13:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-10 14:13:46 +0100 |
commit | bb2db93bfb8dd7e080d2708548eae660e6b33913 (patch) | |
tree | 32a54bc4469cb894aa009736e070bdc382e48e76 /game/menus/shop/ButtonBuySelectBulletScript.cpp | |
parent | d20b25828b53af170a6534263e8de114e7fac121 (diff) | |
parent | 8d46ad5a20d1aa5b784291ae323e38d1e0d59351 (diff) |
Merge pull request #122 from lonkaars/jaro/game
Jaro/game
Diffstat (limited to 'game/menus/shop/ButtonBuySelectBulletScript.cpp')
-rw-r--r-- | game/menus/shop/ButtonBuySelectBulletScript.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/game/menus/shop/ButtonBuySelectBulletScript.cpp b/game/menus/shop/ButtonBuySelectBulletScript.cpp new file mode 100644 index 0000000..71d8b76 --- /dev/null +++ b/game/menus/shop/ButtonBuySelectBulletScript.cpp @@ -0,0 +1,36 @@ +#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; +} |