This commit is contained in:
Nico 2021-03-22 15:18:28 +00:00
parent 4ec3c66df6
commit 895faaec61
1 changed files with 12 additions and 9 deletions

21
main.fs
View File

@ -131,28 +131,31 @@ S" you feel like throwing some stuff into the pool." set-message
\ the word pay pays an amount of devices
: pay ( n -- ) s>f devices f@ fswap f- devices f! ;
\ the word clear-message clears the onscreen message
: clear-message S" " set-message ;
\ the word hire-chat-member hires a chat member.
: hire-chat-member
membercost @ dup !0= swap \ checks if member cost is nonzero, leaving member cost on the stack
can-afford? \ tests if the member cost (converted to a float) is less than the amount of devices we have
membercost @ dup !0= swap \ checks if cost is nonzero, leaving member cost on the stack
can-afford?
and if
membercost @ pay
1 membercount +! \ add a member to the count
membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member
membercost 1 changed
S" " set-message \ blank the message, because we did a thing.
clear-message
then ;
\ the word build-construct builds a construct.
: build-construct
constructcost @ dup !0= swap \ checks if member cost is nonzero, leaving member cost on the stack
can-afford? \ tests if the member cost (converted to a float) is less than the amount of devices we have
constructcost @ dup !0= swap
can-afford?
and if
constructcost @ pay \ remove devices that pay for the construct
1 constructcount +! \ add a construct to the count
constructcount @ 4 * 10 + constructcost +! \ increase the cost of buying a new construct
constructcost @ pay
1 constructcount +!
constructcount @ 4 * 10 + constructcost +!
constructcount 1 changed
S" " set-message \ blank the message, because we did a thing.
clear-message
then ;