make pay and can-afford? words work wwith other currencies

This commit is contained in:
Nico 2021-03-25 10:11:14 +00:00
parent 044647bde5
commit 5e5b1bd398
1 changed files with 8 additions and 8 deletions

16
main.fs
View File

@ -123,11 +123,11 @@ S" you feel like throwing some stuff into the pool." set-message
\ the word exit-game exits the game.
: exit-game page show-cursor bye ;
\ the word can-afford? tests if you could afford n devices.
: can-afford? ( n -- flag ) s>f devices f@ f<= ;
\ the word can-afford? tests if you could afford n of a currency.
: can-afford? ( n currency -- flag ) f@ s>f f>= ;
\ the word pay pays an amount of devices
: pay ( n -- ) s>f devices f@ fswap f- devices f! ;
\ the word pay pays an amount of a currency.
: pay ( n currency -- ) dup f@ swap s>f fswap f- f! ;
\ the word clear-message clears the onscreen message
: clear-message S" " set-message ;
@ -135,9 +135,9 @@ S" you feel like throwing some stuff into the pool." set-message
\ the word hire-chat-member hires a chat member.
: hire-chat-member
membercost @ dup !0= swap \ checks if cost is nonzero, leaving member cost on the stack
can-afford?
devices can-afford?
and if
membercost @ pay
membercost @ devices pay
1 membercount +! \ add a member to the count
membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member
membercost 1 changed
@ -147,9 +147,9 @@ S" you feel like throwing some stuff into the pool." set-message
\ the word build-construct builds a construct.
: build-construct
constructcost @ dup !0= swap
can-afford?
devices can-afford?
and if
constructcost @ pay
constructcost @ devices pay
1 constructcount +!
constructcount @ 4 * 10 + constructcost +!
constructcount 1 changed