add proper pural to chat members, reformatting, add starting message

This commit is contained in:
Nico 2021-03-18 11:11:26 +00:00
parent 75c737516b
commit cc9184340d
1 changed files with 23 additions and 10 deletions

33
main.fs
View File

@ -30,12 +30,12 @@ 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
\ 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 (this is what S" " does)
\ 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:
\ [length change-flag address]
\ TODO this is a terrible idea. Potential better ideas:
\ * have the change flag be the first value, so then the subsequent values can be any length
\ * actually learn better how strings work in this language
\ * learn how strings work in this language, store the message inside message
create message 0 , 0 , 0 ,
@ -43,7 +43,10 @@ variable membercount
: set-message ( addr len -- ) message ! message 2 cells + ! message changed ;
\ get-message gets the message
: get-message ( -- addr len ) message @ message 2 cells + @ swap ;
\ set an initial message
S" you feel like throwing some stuff into the pool." set-message
\ 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 ;
\ clear-all clears the change flag on all values.
@ -55,8 +58,7 @@ variable membercount
: unlock-members
devices @ 5 = membercost @ 0= and if
10 membercost !
S" A friendly townie wants to help out." set-message
then ;
S" A friendly townie wants to help out." set-message then ;
\ the word unlock tests to see if any unlock conditions are matched, and unlocks them if they are.
: unlock unlock-members ;
@ -68,8 +70,10 @@ variable membercount
: tick-up tick 1 counter +! ;
\ the word game-tick runs a single tick of the game
: game-tick tick-up unlock counter @
devicerate @ mod 0= if 1 devices +! devices changed then ;
: game-tick tick-up unlock
counter @ devicerate @ mod 0= if
1 devices +!
devices changed then ;
\ TODO saving
\ the word exit-game exits the game.
@ -117,12 +121,21 @@ variable membercount
." There are " . ." devices in the javapool." then
space print-rate ;
\ draw-members draws the option for hiring a chat member
: draw-members
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
else drop then ;
\ draw-actions draws a list of the actions you've unlocked.
: draw-actions
1 4 at-xy
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 1 move-right
else drop then
draw-members cr 1 move-right
." (q)uit (without saving)" ;
\ draw-screen redraws the screen, but only if there's been a change.