From 86f256ee45f5751f11fff524eac8817e25eaef03 Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Wed, 17 Mar 2021 18:04:15 +0000 Subject: [PATCH] add more comments --- main.fs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/main.fs b/main.fs index 0ce238e..8d727ba 100644 --- a/main.fs +++ b/main.fs @@ -48,13 +48,13 @@ variable membercount \ the word hire-chat-member hires a chat member. : hire-chat-member - membercost @ dup !0= swap - devices @ <= + membercost @ dup !0= swap \ checks if member cost is nonzero, leaving member cost on the stack + devices @ <= \ tests if the member cost is less than the amount of devices we have and if - devices @ membercost @ - devices ! - devicerate @ 500 - devicerate ! - 1 membercount +! - membercount @ 2 * 5 + membercost +! + devices @ membercost @ - devices ! \ remove devices that "pay" for the members + devicerate @ 500 - devicerate ! \ increase the device rate by 500 + 1 membercount +! \ add a member to the count + membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member then ; @@ -69,7 +69,8 @@ variable membercount \ TODO make this be devices/s : print-rate 2 set-precision - ." (" devicerate @ s>f 1000e f/ 1e fswap f/ f. ." devices/second)" ; + \ first convert to floating point, divide by 1000 to get seconds from milliseconds, then do 1/n to get the devices/second from seconds/device + ." (" devicerate @ s>f 1000e f/ 1e fswap f/ f. ." devices/second)" ; \ draw-devices draws the number of devices on the screen. : draw-devices @@ -83,7 +84,7 @@ variable membercount \ draw-actions draws a list of the actions you've unlocked. : draw-actions 1 3 at-xy - membercost @ dup !0= if + membercost @ dup !0= if \ if membercost is non-zero (members have been unlocked) ." (h)ire a chat member [" . ." Devices] (you have " membercount @ . ." chat members helping you)" cr else drop then 1 move-right ." (q)uit" ;