make chat member power scale with amount of chat members

This commit is contained in:
Nico 2021-03-18 11:25:04 +00:00
parent cc9184340d
commit cfabbe44b1
1 changed files with 9 additions and 3 deletions

12
main.fs
View File

@ -36,9 +36,7 @@ variable membercount
\ 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
\ * learn how strings work in this language, store the message inside message
create message 0 , 0 , 0 ,
\ set-message sets the message
: set-message ( addr len -- ) message ! message 2 cells + ! message changed ;
\ get-message gets the message
@ -47,6 +45,10 @@ variable membercount
\ set an initial message
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 !
\ 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.
@ -86,7 +88,11 @@ S" you feel like throwing some stuff into the pool." set-message
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
devicerate @ 500 - devicerate ! \ increase the device rate by 500
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.
else
devicerate @ 500 - devicerate ! drop
then
1 membercount +! \ add a member to the count
membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member
membercost changed