From 699603d46600aa10c366a5fb96eb13290da1ba1c Mon Sep 17 00:00:00 2001 From: nihilazo Date: Thu, 18 Mar 2021 15:19:19 +0000 Subject: [PATCH] fix chat member speed scaling --- main.fs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/main.fs b/main.fs index 00b7f3d..ff58bac 100644 --- a/main.fs +++ b/main.fs @@ -94,13 +94,15 @@ S" you feel like throwing some stuff into the pool." set-message \ the word hire-chat-member hires a chat member. +\ TODO something funky is going on with the rate past a certain point. find out where and why. +\ goes negative at 12 members, seems to be doing weird stuff before that with speeds. : hire-chat-member 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 ! \ remove devices that "pay" for the member membercount @ dup !0= if \ membercount is nonzero - devicerate @ swap 500 swap / - devicerate ! \ decrease the device delay by 500/membercount. TODO There is certainly a more elegent way to do this stack manipulation. + devicerate @ swap 1 + 500 swap / - devicerate ! else devicerate @ 500 - devicerate ! drop then @@ -110,19 +112,26 @@ S" you feel like throwing some stuff into the pool." set-message S" " set-message \ blank the message, because we did a thing. then ; +\ the word debug-console is used for entering debug mode. +\ TODO write debug mode. Ideally this could just be a forth console. +: debug-console + page + ." Entering debug/cheat mode!" + page ; \ the word handle-input handles input every time around the game loop. : handle-input key? if key case [char] q of exit-game endof [char] h of hire-chat-member endof + [char] D of debug-console endof endcase then ; \ print-rate prints the current device output rate on the screen. : print-rate 2 set-precision \ 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)" ; + ." (" devicerate @ s>f 1000e f/ 1e fswap f/ f. ." devices/second)"; \ draw-message draws the stored message on the screen. : draw-message @@ -143,11 +152,7 @@ S" you feel like throwing some stuff into the pool." set-message clear-line membercost @ dup !0= if \ if membercost is non-zero (members have been unlocked) ." (h)ire a chat member [" . ." Devices]" - membercount @ dup 1 = if - space ." (you have 1 chat member helping you)" drop - else - space ." (you have " . ." chat members helping you)" - then + space ." (" membercount @ 0 .R ." )" else drop then ; \ draw-actions draws a list of the actions you've unlocked.