diff options
author | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-01 21:27:29 +0100 |
---|---|---|
committer | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-01 21:27:29 +0100 |
commit | 039c9f4bd8ee6bfb299d4422372804c569eddebd (patch) | |
tree | 1fcbc98aee0b462095feda36ac57c73c535a626b /src/coins.c | |
parent | 646664ff29afd8627626274a4fc12b05d584fe2c (diff) | |
parent | 0250aefb73a995a6812a657193abeb96eb34d489 (diff) |
merge with master
Diffstat (limited to 'src/coins.c')
-rw-r--r-- | src/coins.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/coins.c b/src/coins.c index e1694b29c..50c31cac0 100644 --- a/src/coins.c +++ b/src/coins.c @@ -2,8 +2,9 @@ #include "coins.h" #include "text.h" #include "window.h" -#include "text_window.h" +#include "strings.h" #include "string_util.h" +#include "new_menu_helpers.h" #include "menu.h" #include "international_string_util.h" @@ -11,10 +12,6 @@ EWRAM_DATA u8 sCoinsWindowId = 0; -extern void sub_819746C(u8 windowId, bool8 copyToVram); - -extern const u8 gText_Coins[]; - void PrintCoinsString(u32 coinAmount) { u32 xAlign; @@ -53,7 +50,6 @@ void SetCoins(u16 coinAmount) gSaveBlock1Ptr->coins = coinAmount ^ gSaveBlock2Ptr->encryptionKey; } -/* Can't match it lol bool8 GiveCoins(u16 toAdd) { u16 newAmount; @@ -67,10 +63,22 @@ bool8 GiveCoins(u16 toAdd) } else { - newAmount = ownedCoins + toAdd; - if (newAmount > MAX_COINS) - newAmount = MAX_COINS; + ownedCoins += toAdd; + if (ownedCoins > MAX_COINS) + ownedCoins = MAX_COINS; + newAmount = ownedCoins; } SetCoins(newAmount); return TRUE; -}*/ +} + +bool8 TakeCoins(u16 toSub) +{ + u16 ownedCoins = GetCoins(); + if (ownedCoins >= toSub) + { + SetCoins(ownedCoins - toSub); + return TRUE; + } + return FALSE; +} |