diff options
author | Diegoisawesome <Diegoisawesome@users.noreply.github.com> | 2017-11-28 10:00:55 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-28 10:00:55 -0600 |
commit | de00b4aeecc8b81cb18e0d3930699caad3fa2336 (patch) | |
tree | 62d368f42e177673f4bb99beb7f571f231142ea7 /src | |
parent | 18c6b8efc21a509121ab4d6f5b9c8523689d27a2 (diff) | |
parent | 41eb2ed59e3a54819ccf7ef6dbdcde3215331a3f (diff) |
Merge pull request #121 from PikalaxALT/coins
Coins
Diffstat (limited to 'src')
-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; +} |