make chat member power scale with amount of chat members
This commit is contained in:
parent
cc9184340d
commit
cfabbe44b1
12
main.fs
12
main.fs
|
@ -36,9 +36,7 @@ variable membercount
|
||||||
\ TODO this is a terrible idea. Potential better ideas:
|
\ 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
|
\ * 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
|
\ * learn how strings work in this language, store the message inside message
|
||||||
|
|
||||||
create message 0 , 0 , 0 ,
|
create message 0 , 0 , 0 ,
|
||||||
|
|
||||||
\ set-message sets the message
|
\ set-message sets the message
|
||||||
: set-message ( addr len -- ) message ! message 2 cells + ! message changed ;
|
: set-message ( addr len -- ) message ! message 2 cells + ! message changed ;
|
||||||
\ get-message gets the message
|
\ get-message gets the message
|
||||||
|
@ -47,6 +45,10 @@ variable membercount
|
||||||
\ set an initial message
|
\ set an initial message
|
||||||
S" you feel like throwing some stuff into the pool." set-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? leaves a -1 on the stack if any value has changed, 0 otherwise
|
||||||
: any-change? ( -- flag ) membercost changed? devices changed? message changed? or or ;
|
: any-change? ( -- flag ) membercost changed? devices changed? message changed? or or ;
|
||||||
\ clear-all clears the change flag on all values.
|
\ 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
|
devices @ <= \ tests if the member cost is less than the amount of devices we have
|
||||||
and if
|
and if
|
||||||
devices @ membercost @ - devices ! \ remove devices that "pay" for the member
|
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
|
1 membercount +! \ add a member to the count
|
||||||
membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member
|
membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member
|
||||||
membercost changed
|
membercost changed
|
||||||
|
|
Reference in New Issue