add message on 50 devices

This commit is contained in:
Nico 2021-03-18 11:45:59 +00:00
parent cfabbe44b1
commit 2d91a0bb03
1 changed files with 14 additions and 3 deletions

17
main.fs
View File

@ -29,6 +29,8 @@ variable devicerate
create membercost 0 , 0 ,
\ the variable "membercount" is how many chat members you've hired. For each chat member, device gain delay decreases.
variable membercount
\ count-messages-shown contains the amount of device count milestone messages that have been shown.
variable count-messages-shown
\ message contains a string message which is printed on the screen.
\ because forth is weird, strings can be stored in variables but it's easier to just store them someplace else and then store that address and the string's length in the variable (this is what S" " does and what "type" expects)
\ as I'd like changed? etc to work on this, it needs to have three cells, arranged like this:
@ -46,8 +48,8 @@ variable membercount
S" you feel like throwing some stuff into the pool." set-message
\ FOR DEBUGGING PURPOSES - some sets that skip into the future
100 devices !
10 membercost !
\ 40 devices !
\ 10 membercost !
\ any-change? leaves a -1 on the stack if any value has changed, 0 otherwise
: any-change? ( -- flag ) membercost changed? devices changed? message changed? or or ;
@ -71,12 +73,21 @@ S" you feel like throwing some stuff into the pool." set-message
\ the word tick-up ticks the counter up
: tick-up tick 1 counter +! ;
\ set-count-message sets the message to certain things based on the amount of devices in the pool. The count-messages-shown variable is used to track how many of these have already been shown.
: set-count-message
devices @ 50 > count-messages-shown @ 1 < and if
S" The pool is starting to look a little cluttered. " set-message
1 count-messages-shown +!
then ;
\ the word game-tick runs a single tick of the game
: game-tick tick-up unlock
counter @ devicerate @ mod 0= if
1 devices +!
set-count-message
devices changed then ;
\ TODO saving
\ the word exit-game exits the game.
: exit-game page show-cursor bye ;