make pay and can-afford? words work wwith other currencies
This commit is contained in:
parent
044647bde5
commit
5e5b1bd398
16
main.fs
16
main.fs
|
@ -123,11 +123,11 @@ S" you feel like throwing some stuff into the pool." set-message
|
||||||
\ the word exit-game exits the game.
|
\ the word exit-game exits the game.
|
||||||
: exit-game page show-cursor bye ;
|
: exit-game page show-cursor bye ;
|
||||||
|
|
||||||
\ the word can-afford? tests if you could afford n devices.
|
\ the word can-afford? tests if you could afford n of a currency.
|
||||||
: can-afford? ( n -- flag ) s>f devices f@ f<= ;
|
: can-afford? ( n currency -- flag ) f@ s>f f>= ;
|
||||||
|
|
||||||
\ the word pay pays an amount of devices
|
\ the word pay pays an amount of a currency.
|
||||||
: pay ( n -- ) s>f devices f@ fswap f- devices f! ;
|
: pay ( n currency -- ) dup f@ swap s>f fswap f- f! ;
|
||||||
|
|
||||||
\ the word clear-message clears the onscreen message
|
\ the word clear-message clears the onscreen message
|
||||||
: clear-message S" " set-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.
|
\ the word hire-chat-member hires a chat member.
|
||||||
: hire-chat-member
|
: hire-chat-member
|
||||||
membercost @ dup !0= swap \ checks if cost is nonzero, leaving member cost on the stack
|
membercost @ dup !0= swap \ checks if cost is nonzero, leaving member cost on the stack
|
||||||
can-afford?
|
devices can-afford?
|
||||||
and if
|
and if
|
||||||
membercost @ pay
|
membercost @ devices pay
|
||||||
1 membercount +! \ add a member to the count
|
1 membercount +! \ add a member to the count
|
||||||
membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member
|
membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member
|
||||||
membercost 1 changed
|
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.
|
\ the word build-construct builds a construct.
|
||||||
: build-construct
|
: build-construct
|
||||||
constructcost @ dup !0= swap
|
constructcost @ dup !0= swap
|
||||||
can-afford?
|
devices can-afford?
|
||||||
and if
|
and if
|
||||||
constructcost @ pay
|
constructcost @ devices pay
|
||||||
1 constructcount +!
|
1 constructcount +!
|
||||||
constructcount @ 4 * 10 + constructcost +!
|
constructcount @ 4 * 10 + constructcost +!
|
||||||
constructcount 1 changed
|
constructcount 1 changed
|
||||||
|
|
Reference in New Issue