Created
April 18, 2016 16:11
-
-
Save Sumolari/878eb47d383290a20aead22f59a1e6ae to your computer and use it in GitHub Desktop.
Checks if player has enough money to buy an item, and buys it if possible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "MawKit/KVDatabase.hpp" | |
bool buyIfPossible( long long price ) | |
{ | |
constexpr const char *moneyKey = "money"; | |
if ( MK::KVDatabase::getLongValueForKey( moneyKey ) > price ) { | |
MK::KVDatabase::decreaseLongValueForKey( moneyKey, price ); | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment